我正在尝试使用OIDC承载来保护Quarkus(V1.13.7)REST服务。我正在遵循他们的使用OpenID Connect to Protect Service Applications指南,但我运气不佳。
每当我将Authorization:Bearer{ValidAccessStoken}
包含在对受保护资源的请求的标题中(使用@rolesAllowed
注释),我就会得到一个403禁止
响应,响应主体为空。如果我省略了这个头,我可以访问不受保护的资源,但受保护的资源,毫无疑问,给401未经授权的
,同样是一个空的主体。
以下是我使用的应用程序属性:
# DB configuration
quarkus.datasource.db-kind = postgresql
quarkus.datasource.username = bla
quarkus.datasource.password = bla_bla
quarkus.hibernate-orm.database.generation = update
quarkus.datasource.jdbc.url = jdbc:postgresql://blablabla
# Logging
%dev.quarkus.log.level=ALL
%dev.quarkus.log.category."io.quarkus.oidc".level=FINEST
%dev.quarkus.log.category."io.quarkus.security".level=FINEST
# OIDC config
demo.oidc-provider=valid.provider.url.com/bla
demo.oidc-clientid=validClientId
demo.oidc-clientsecret=validClientSecret
demo.oidc-issuer=${demo.oidc-provider}
quarkus.oidc.application-type=service
quarkus.oidc.auth-server-url=${demo.oidc-provider}
quarkus.oidc.client-id=${demo.oidc-clientid}
quarkus.oidc.credentials.client-secret.value=${demo.oidc-clientsecret}
quarkus.oidc.token.issuer=${demo.oidc-issuer}
quarkus.oidc.authentication.user-info-required=true
quarkus.oidc.roles.source=userinfo
quarkus.oidc.roles.role-claim-path=userroles
quarkus.oidc.discovery-enabled=false
quarkus.oidc.introspection-path=/introspect
quarkus.oidc.user-info-path=/userinfo
注意日志记录部分。尽管它被配置为记录所有内容,但当我得到403响应时,它只打印以下内容:
2021-08-04 11:22:10,147 FINEST [io.ver.ext.web.imp.RouterImpl] (vert.x-eventloop-thread-6) Router: 1653352852 accepting request GET http://localhost:8080/my/api/resource/path
2021-08-04 11:22:10,171 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Route matches: RouteState{path='null', order=-2147483648, enabled=true, methods=null, consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.quarkus.vertx.http.runtime.VertxHttpRecorder$5@76ec9770], failureHandlers=null, added=true, pattern=null, groups=null, useNormalisedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=false}
2021-08-04 11:22:10,171 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Calling the handler
2021-08-04 11:22:10,200 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Route matches: RouteState{path='null', order=-200, enabled=true, methods=null, consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2@79d5df9a], failureHandlers=null, added=true, pattern=null, groups=null, useNormalisedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=false}
2021-08-04 11:22:10,202 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Calling the handler
2021-08-04 11:22:10,203 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Route matches: RouteState{path='null', order=-100, enabled=true, methods=null, consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$3@1e4e05ec], failureHandlers=null, added=true, pattern=null, groups=null, useNormalisedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=false}
2021-08-04 11:22:10,206 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Calling the handler
2021-08-04 11:22:10,207 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Route matches: RouteState{path='null', order=-2, enabled=true, methods=null, consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.quarkus.vertx.http.runtime.VertxHttpRecorder$4@6bf0fbda], failureHandlers=null, added=true, pattern=null, groups=null, useNormalisedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=false}
2021-08-04 11:22:10,208 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Calling the handler
2021-08-04 11:22:10,209 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Route matches: RouteState{path='null', order=10000, enabled=true, methods=null, consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.quarkus.vertx.http.runtime.StaticResourcesRecorder$$Lambda$785/0x0000000800786840@6ed633ec, io.quarkus.vertx.http.runtime.StaticResourcesRecorder$$Lambda$785/0x0000000800786840@57426aed, io.quarkus.vertx.http.runtime.StaticResourcesRecorder$$Lambda$789/0x0000000800785840@7d171a43], failureHandlers=null, added=true, pattern=null, groups=null, useNormalisedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=false}
2021-08-04 11:22:10,210 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Calling the handler
2021-08-04 11:22:10,210 FINEST [io.ver.ext.web.han.imp.StaticHandlerImpl] (vert.x-eventloop-thread-6) File to serve is /my/api/resource/path
2021-08-04 11:22:10,215 FINEST [io.ver.ext.web.han.imp.StaticHandlerImpl] (vert.x-eventloop-thread-6) File to serve is /my/api/resource/path
2021-08-04 11:22:10,218 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Route matches: RouteState{path='/', order=10001, enabled=true, methods=null, consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.quarkus.resteasy.runtime.standalone.VertxRequestHandler@43d422b0], failureHandlers=null, added=true, pattern=null, groups=null, useNormalisedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=true, exclusive=false, exactPath=false}
2021-08-04 11:22:10,219 FINEST [io.ver.ext.web.imp.RoutingContextImplBase] (vert.x-eventloop-thread-6) Calling the handler
2021-08-04 11:22:10,222 DEBUG [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002315: PathInfo: /my/api/resource/path
我已经尝试使用Quarkus异常映射来捕捉问题并检查异常,但是无论我如何配置异常映射,它都不会被调用。根据quarkus git回购的第8570期:
[...]要映射身份验证失败和授权,则需要禁用主动auth,然后可以使用异常映射器来生成AuthenticationFailedException,因为它将从拦截器生成,而不是在安全处理的早期生成。
因此,我在应用程序属性中添加了Quarkus.http.auth.proactive=false
,现在Quarkus返回一个500内部错误
,该错误表示它不能在我不知道哪个线程上调用getidentity()
,我应该插入这个标识或其他类似的标识。问题是,我并没有试图在任何地方获得这个身份(至少现在还没有),所以这个失败是在他们自己的内部代码中。因此,我放弃了使用异常映射的尝试。
此时,验证令牌的OidcProvider类将一些验证委托给底层的jose-jwt验证器。
通过启用以下日志记录类别,可以看到令牌无效的一些信息:
quarkus.log.category."io.quarkus.oidc".level=TRACE
# The category io.quarkus.oidc already contains the errors generated by the jose-jwt library
将出现的错误通常与配置错误、过期令牌或无效签名有关。您将无法看到有关允许访问资源的角色的错误。
我将打开一个增强,以统一或至少包含尽可能多的错误,或改进有关此主题的文档。
也许他们可以做点什么,或者给我们指明一个更好的方向。
我在一个网站上工作,跟踪待办事项列表,并从服务器上提取它。下面有两个示例ajax调用。任务GET调用工作正常,但添加POST不工作。出于某种原因,它给我一个403禁止的错误,结果,不执行代码。 在Django框架中发出ajax Post请求时,我看到了403禁止的错误,我阅读了@yohn发布的链接,但我不理解如何实现这个解决方案。
问题内容: 我制作了供个人使用的python脚本,但不适用于Wikipedia … 这项工作: 这不起作用: 这是错误: 问题答案: 在当前代码内: Python 2.X 的Python 3.X 带有Selenium的Python 3.X(执行Javascript函数) 修改后的版本起作用的原因是因为Wikipedia检查User-Agent是“流行的浏览器”
当我运行应用程序时,gradle无法构建 编译器消息:file:///c:/users/wellick/documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_sticky_header-0.3.4/lib/src/widgets/sticky_header_layout_builder.dart:147:16:错误:无法将参数类型
问题 解释器因为某个分段错误、总线错误、访问越界或其他致命错误而突然间奔溃。 你想获得Python堆栈信息,从而找出在发生错误的时候你的程序运行点。 解决方案 faulthandler 模块能被用来帮你解决这个问题。 在你的程序中引入下列代码: import faulthandler faulthandler.enable() 另外还可以像下面这样使用 -Xfaulthandler 来运行Pyth
什么原因
有人能帮我找出我的SSLHandshake有什么问题吗? 我有一个Java客户端应用程序(使用Spring WS-security)试图将数据发送到服务器(不在我的控制范围内),我设置了以下内容 具有来自服务器的证书的客户端信任库 Java密钥库与我的私人密钥输入证书 在我的调试SSL握手日志(某些部分缩写)下面,我似乎找不到任何错误。。这是服务器端需要调查的事情吗?(我不确定,他们也不确定,这就