Google Cloud Endpoints 使用 Auth0 保护所有路径
Google Cloud Endpoints secure all paths with Auth0
我尝试使用 security swagger 对象来保护我的所有路径,使用 API 密钥可以正常工作,但是我如何使用 auth0 或自定义身份验证来做到这一点?
security:
- api_key: []
securityDefinitions:
api_key:
type: "apiKey"
name: "key"
in: "query"
这不起作用
x-security:
- auth0_jwk:
audiences:
- "xxxxxxxxxxxxxxxx"
securityDefinitions:
auth0_jwk:
# Replace YOUR-ACCOUNT-NAME with your Auth0 account name.
authorizationUrl: "https://YOUR-ACCOUNT-NAME.auth0.com/authorize"
flow: "implicit"
type: "oauth2"
x-issuer: "https://YOUR-ACCOUNT-NAME.auth0.com/"
# Replace YOUR-ACCOUNT-NAME with your service account's email address.
x-jwks_uri: "https://YOUR-ACCOUNT-NAME.auth0.com/.well-known/jwks.json"
或这个
security:
- auth0_jwk:[
"xxxxxxxxxxxxxxxx"
]
securityDefinitions:
auth0_jwk:
# Replace YOUR-ACCOUNT-NAME with your Auth0 account name.
authorizationUrl: "https://YOUR-ACCOUNT-NAME.auth0.com/authorize"
flow: "implicit"
type: "oauth2"
x-issuer: "https://YOUR-ACCOUNT-NAME.auth0.com/"
# Replace YOUR-ACCOUNT-NAME with your service account's email address.
x-jwks_uri: "https://YOUR-ACCOUNT-NAME.auth0.com/.well-known/jwks.json"
"x-security" 的 swagger 配置在我看来是正确的。如果没有错误消息,我不确定您的问题到底是什么。然而,人们在使用 auth0 认证时常犯的一个常见错误是,他们没有正确设置 JWT 签名算法。默认情况下,JWT 签名算法设置为 "HS256"(对称密钥加密)。如果需要使用"RS256"(非对称密钥加密),需要进入应用设置页面,在高级配置下,OAuth下,将‘JsonWebToken签名算法’设置为RS256。
解决方案很简单,我使用 express-swaggerize 作为我的 api 并且验证不知道 x-security 并告诉我错误是不允许的,这就是问题所在。
对此感到抱歉post
我尝试使用 security swagger 对象来保护我的所有路径,使用 API 密钥可以正常工作,但是我如何使用 auth0 或自定义身份验证来做到这一点?
security:
- api_key: []
securityDefinitions:
api_key:
type: "apiKey"
name: "key"
in: "query"
这不起作用
x-security:
- auth0_jwk:
audiences:
- "xxxxxxxxxxxxxxxx"
securityDefinitions:
auth0_jwk:
# Replace YOUR-ACCOUNT-NAME with your Auth0 account name.
authorizationUrl: "https://YOUR-ACCOUNT-NAME.auth0.com/authorize"
flow: "implicit"
type: "oauth2"
x-issuer: "https://YOUR-ACCOUNT-NAME.auth0.com/"
# Replace YOUR-ACCOUNT-NAME with your service account's email address.
x-jwks_uri: "https://YOUR-ACCOUNT-NAME.auth0.com/.well-known/jwks.json"
或这个
security:
- auth0_jwk:[
"xxxxxxxxxxxxxxxx"
]
securityDefinitions:
auth0_jwk:
# Replace YOUR-ACCOUNT-NAME with your Auth0 account name.
authorizationUrl: "https://YOUR-ACCOUNT-NAME.auth0.com/authorize"
flow: "implicit"
type: "oauth2"
x-issuer: "https://YOUR-ACCOUNT-NAME.auth0.com/"
# Replace YOUR-ACCOUNT-NAME with your service account's email address.
x-jwks_uri: "https://YOUR-ACCOUNT-NAME.auth0.com/.well-known/jwks.json"
"x-security" 的 swagger 配置在我看来是正确的。如果没有错误消息,我不确定您的问题到底是什么。然而,人们在使用 auth0 认证时常犯的一个常见错误是,他们没有正确设置 JWT 签名算法。默认情况下,JWT 签名算法设置为 "HS256"(对称密钥加密)。如果需要使用"RS256"(非对称密钥加密),需要进入应用设置页面,在高级配置下,OAuth下,将‘JsonWebToken签名算法’设置为RS256。
解决方案很简单,我使用 express-swaggerize 作为我的 api 并且验证不知道 x-security 并告诉我错误是不允许的,这就是问题所在。
对此感到抱歉post