springdoc - SpringDoc Oauth2 需要隐式流随机数参数并且身份验证失败
问题描述
我可以启用授权按钮,但是当我单击授权按钮时,对于 oauth2 隐式流程,它会抱怨缺少 nonce 参数。
The 'nonce' parameter is required for authorize requests with either the 'id_token' or 'token' response types
这是我用来创建隐式流的代码
new OpenAPI()
.addSecurityItem(new SecurityRequirement().addList(securitySchemeName))
.components(new Components()
.addSecuritySchemes(securitySchemeName,
new SecurityScheme()
.name(securitySchemeName)
.type(SecurityScheme.Type.OAUTH2)
.description("This API uses OAuth 2 with the implicit grant flow.")
.flows(new OAuthFlows()
.implicit(new OAuthFlow()
.authorizationUrl(authorizeUri)
.scopes(new Scopes()
.addString("read", "read")))
在 Springfox 中添加 nonce 参数,您为 SecurityConfiguration 创建一个 bean 并使用 additionalQueryStringsParams() 方法。
SecurityConfiguration#additionalQueryStringParams()
您将在其中添加 nonce 作为键和值对中的随机字符串。我尝试使用 OAuthFlows 和 SecurityScheme 上的扩展,但它似乎仍然无法正常工作。
我不确定我错过了什么,感谢任何帮助。
解决方案
好的,我想通了,没有添加额外查询参数的功能。您只需自己将其硬编码到字符串中,然后将其添加到 url。
.authorizaitonUrl(authroizeUri + "?nonce=\"asdf\"")
推荐阅读
- javascript - chrome扩展拒绝执行内联脚本
- python - 准确度/损失图中的数字缺失点
- jquery - jQuery Lightbox 2 在随机图像中显示边框
- node.js - 子模块是否存在相反或相反的情况?
- php - 如何在对 XPLAN API 的 CURL 请求中构造 edai.Search 方法的第三个参数?
- dns - 为 DNS 区域文件提取域
- google-app-engine - appIdentityService.signForApp (Java) 和 app_identity.sign_blob (Python) 结果不同
- ajax - ajax成功后如何替换当前表
- mysql - 限制Mysql需要从表中返回n%的随机记录
- java - JAVA - 为什么从 SOAP UI 获取 ElementNSImpl