Swagger UI で OIDC の Implicit FlowなAPIを呼びだす。
Swagger UI で OIDC の Implicit Flow な認証を必要とする API を呼びだそうとすると、response_typeにid_tokenが無いぞ。とか、nonceが無いぞ。とか言ってうまく呼びだせない。
issueを見るとOIDC対応はOAS3からだよと書いてあって、終わっているんだかどうだかよくわからない状況になっています。
参考
– https://github.com/swagger-api/swagger-ui/issues/3906
– https://github.com/swagger-api/swagger-ui/issues/3517
OIDCサーバーの実装にもよると思うけれど、IdentityServer 4 を使っている環境では authorizationUrl をこんな風に指定してあげたらどうにか動くようになった。
securityDefinitions:
bearer:
type: oauth2
description: MyApi
flow: implicit
authorizationUrl: 'https://myidp/connect/authorize?nonce=xxxxxxxxx&response_type=id_token'
scopes:
openid: openid token
profile: profile
あっ、Swaggerをホストしているサーバーをlocalhost:3000とかで起動するなら、Identity Server側のRedirectUrisに http://localhost:3000/oauth2-redirect.html を入れる必要がありますね。
docker-composeで起動するならこんな感じですかね
version: "3"
services:
swagger:
image: swaggerapi/swagger-ui
volumes:
- ./swagger.yml:/usr/share/nginx/html/swagger.yaml
environment:
API_URL: swagger.yaml
OAUTH_CLIENT_ID: xxxxxxxx
OAUTH_CLIENT_SECRET: xxxxxxxx
OAUTH_SCOPES: openid profile
ports:
- "3000:8080"
カテゴリー:未分類
コメント (0)
Trackbacks (0)
コメントを残す
トラックバック