【问题标题】:How to change the response_type to id_token in authorization URL for implicit Oauth2 flow如何在隐式 Oauth2 流的授权 URL 中将 response_type 更改为 id_token
【发布时间】:2021-04-11 02:16:54
【问题描述】:

我有以下 OpenAPI 配置

   new OpenAPI()
                .components(
                        new Components()
                                .addSecuritySchemes("oAuthScheme", new SecurityScheme()
                                        .type(SecurityScheme.Type.OAUTH2)
                                        .description("This API uses OAuth 2 with the implicit grant flow.")
                                        .flows(new OAuthFlows()
                                                .implicit(new OAuthFlow()
                                                        .authorizationUrl("http://example.com/oauth2/default/v1/authorize")
                                                        .scopes(new Scopes()
                                                                .addString("openid", "read user information")
                                                        )

                                                )
                                        )
                                )
                )

当我点击 swagger UI 上的授权按钮时,它正在生成以下 URL

http://example.com/oauth2/default/v1/authorize?nonce=nonce&response_type=token&client_id=client-id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fswagger-ui%2Foauth2-redirect.html&scope=openid&state=U2F0IEphbiAwMiAyMDIxID

我希望 response_type 作为 id_token 来代替令牌。有什么办法可以改变吗?

【问题讨论】:

    标签: swagger-ui springdoc springdoc-openapi-ui


    【解决方案1】:

    您似乎正在使用 openidconnect。

    您应该切换到 SecurityScheme = OPENIDCONNECT 并填写您的 openIdConnectUrl 网址。结果,您将在响应中获得 id_token。

    【讨论】:

    • 当安全方案是 OpenIDConnect 时,在单击授权隐式流时生成的 URL 将 response_type 作为令牌。
    猜你喜欢
    • 1970-01-01
    • 2017-05-03
    • 2023-04-11
    • 2016-05-24
    • 2019-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多