通过密钥斗篷登录时出现“缺少参数client_assertion_type”
我尝试了多种设置,但只设法使其与public access_type + keycloak.json一起使用
yml文件(部分):
deployment:
demo-0.0.1.war:
web:
login-config:
auth-method: MP-JWT
security-constraints:
- url-pattern: "/*"
roles: [hello, hello2]
keycloak:
secure-deployments:
demo-0.0.1.war:
realm: microprofile-test
auth-server-url: "http://localhost:8080/auth"
ssl-required: none
resource: mp-keycloak
credentials:
secret:
value: xxxxxx-xxxx-xxxxx-xxx-xxxxxxxxx
verify-token-audience: true
use-resource-role-mapping: true
confidential-port: 0
我只需要能够将配置文件写入yml文件中(或通过其他任何允许我无需更改代码即可更改身份验证提供程序的方式-仅通过更改设置即可)。
编辑:我在密钥斗篷中使用带有秘密的JWT令牌
非常感谢!
编辑: 我发现密钥斗篷正在发送令牌(经过邮递员测试)。 但是当我运行该应用程序时,不会注入jwt。
Java代码:
@DenyAll
@RequestScoped
@DeclareRoles({"hello", "hello2"})
@Path("/config")
public class ConfigEndpoint {
@Inject
@ConfigProperty(name = "myVariable", defaultValue = "default value")
private String foo;
@Inject
private JsonWebToken jwtPrincipal;
@Inject
@Claim("roles")
private JsonArray jsonRoles;
@GET
@RolesAllowed("hello")
@Produces(MediaType.TEXT_PLAIN)
public Response getProperty(@Context HttpHeaders headers) {
String ret = jwtPrincipal == null ? "Not injected / No token" : jwtPrincipal.getName();
System.out.println(headers.getRequestHeaders());
System.out.println(jsonRoles);
return Response.ok(ret).build();
}
}
P.S .:我也在用荆棘。
编辑:我设法使其工作到可以使用基本令牌而不是承载令牌的地步。不知道为什么会这样。