小编Zaf*_*fer的帖子

如何使 NextAuth.js 与 Next.js 网站中的 SSG(生成的静态站点)配合使用

Next.js 允许您使用服务器端 (SSR) 或静态客户端 (SSG) 渲染来构建站点,但当您运行时,next build && next export它会删除/api路由。

例如,由于 NextAuth.js 依赖于这些路由/api/auth/signin,因此如何为 SSG 实现 NextAuth.js?

authentication next.js next-auth static-site-generation

9
推荐指数
1
解决办法
3741
查看次数

使用工作负载联合身份验证在 Python 中验证 Google-Cloud-Storage

是否可以使用 Google 工作负载联合身份验证的 OIDC 方法来验证我的 Python 应用程序的 Google Cloud Storage 包。

我想做这样的事情:

import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(os.path.dirname(os.path.dirname(__file__))) + "/keys/credentials.json"
from google.cloud import storage

import google.oauth2.id_token
import google.auth.transport.requests

request = google.auth.transport.requests.Request()
target_audience = "https://pubsub.googleapis.com"

obtained_id_token = google.oauth2.id_token.fetch_id_token(request, target_audience)

storage_client = storage.Client(credentials=obtained_id_token)
Run Code Online (Sandbox Code Playgroud)

这会产生以下错误:

ValueError: This library only supports credentials from google-auth-library-python. See https://google-auth.readthedocs.io/en/latest/ for help on authentication with this library.

python google-cloud-storage google-cloud-platform openid-connect

5
推荐指数
1
解决办法
4679
查看次数

最好使用 SERIAL PRIMARY KEY 或 GENERATED ALWAYS AS IDENTITY 作为 PostgreSQL 中的主键

不确定哪个选项是最新的最佳实践?我继续阅读本教程:

https://www.postgresqltutorial.com/postgresql-identity-column/

PostgreSQL 版本 10 引入了一个新的约束 GENERATED AS IDENTITY,它允许您自动为列分配一个唯一的数字。

GENERATED AS IDENTITY 约束是旧的SERIAL 列的符合SQL 标准的变体。

在示例中,他们使用身份作为主键:

CREATE TABLE color (
    color_id INT GENERATED ALWAYS AS IDENTITY,
    color_name VARCHAR NOT NULL
);
Run Code Online (Sandbox Code Playgroud)

当您按照以下方式引用此表以获取外键时:

CREATE TABLE pallet (
    id INT GENERATED ALWAYS AS IDENTITY,
    color_1 REFERENCES color
    color_2 REFERENCES color
);
Run Code Online (Sandbox Code Playgroud)

它现在会知道身份是主键吗?:

postgresql primary-key identity-column

3
推荐指数
1
解决办法
988
查看次数

Google Cloud Code 的 Cloud Run 扩展将 Docker 镜像存储在 Cloud Storage 而不是 Artifact Registry

为什么当我使用 Visual Studio Code 扩展“Cloud Code”来部署 Cloud Run 服务时,它似乎将图像内容存储在 Cloud Storage(通过 Container Registry)中。

我可以让它将图像存储在 Google Cloud Artifact Registry 中吗?

google-cloud-platform google-cloud-run google-cloud-code google-artifact-registry

0
推荐指数
1
解决办法
80
查看次数