【发布时间】:2019-07-13 21:17:13
【问题描述】:
我正在尝试使用 JWT 身份验证在 thorntail 中设置 JAX-RS 服务。一切正常(我可以注入Principal 并且用户设置正确),除了在身份验证失败的情况下,仍然会在没有任何 401-HTTP-Header 的情况下发送答案。我所做的是:
- 已将
@LoginConfig(authMethod = "MP-JWT", realmName = "my-domain")添加到我的Application-Class 中 -
配置安全域
security: security-domains: my-domain: jaspi-authentication: login-module-stacks: roles-token-stack: login-modules: jwt-jaspi-login-module: code: org.wildfly.swarm.microprofile.jwtauth.deployment.auth.jaas.JWTLoginModule flag: required auth-modules: http: code: org.wildfly.extension.undertow.security.jaspi.modules.HTTPSchemeServerAuthModule module: org.wildfly.extension.undertow flag: required login-module-stack-ref: roles-token-stack 配置的 JWT 特定的东西(似乎可以工作,所以我在这里跳过)
我还需要做什么才能使其正常工作?我需要向我的端点添加任何注释吗?正如我所说,我想在身份验证失败的情况下返回 401。
到目前为止,我发现:JASPICAuthenticationMechanism.isMandatory 需要返回 true 才能使其正常工作。如果是这种情况,JWTAuthMechanism.sendChallenge 会在JWTAuthMechanism.authenticate 失败后触发,因此会向客户端发送 401。但我不知道,在什么情况下isMandatory 会返回 true。
感谢您在这种情况下的任何帮助!
【问题讨论】:
标签: security jwt undertow jaspic thorntail