Quarkus OIDC 客户端授权配置
Quarkus OIDC Client Grant Configuration
遵循指南https://quarkus.io/guides/security-openid-connect-client#use-oidcclients,尤其是示例
@Path("/clients")
public class OidcClientResource {
@Inject
OidcClients clients;
@GET
public String getResponse() {
OidcClientConfig cfg = new OidcClientConfig();
cfg.setId("myclient");
cfg.setAuthServerUrl("http://localhost:8081/auth/realms/quarkus/");
cfg.setClientId("quarkus");
cfg.getCredentials().setSecret("secret");
Uni<OidcClient> client = clients.newClient(cfg);
// use this client to get the token
}
}
未指定如何设置 grant_type
。做了一些调查,class OidcClientConfig
有一个没有 getters/setters 的字段 grant
并且设置授权的唯一方法是直接访问它并设置 Type
枚举像
cfg.grant.setType(OidcClientConfig.Grant.Type.CODE)
它有效,但我想知道这是否只是一个剩余物,或者预期用途是否不同。
感谢支持!
此 PR https://github.com/quarkusio/quarkus/pull/22860 将有助于编写 cfg.getGrant().setType(OidcClientConfig.Grant.Type.CODE)
之类的代码,谢谢
遵循指南https://quarkus.io/guides/security-openid-connect-client#use-oidcclients,尤其是示例
@Path("/clients")
public class OidcClientResource {
@Inject
OidcClients clients;
@GET
public String getResponse() {
OidcClientConfig cfg = new OidcClientConfig();
cfg.setId("myclient");
cfg.setAuthServerUrl("http://localhost:8081/auth/realms/quarkus/");
cfg.setClientId("quarkus");
cfg.getCredentials().setSecret("secret");
Uni<OidcClient> client = clients.newClient(cfg);
// use this client to get the token
}
}
未指定如何设置 grant_type
。做了一些调查,class OidcClientConfig
有一个没有 getters/setters 的字段 grant
并且设置授权的唯一方法是直接访问它并设置 Type
枚举像
cfg.grant.setType(OidcClientConfig.Grant.Type.CODE)
它有效,但我想知道这是否只是一个剩余物,或者预期用途是否不同。
感谢支持!
此 PR https://github.com/quarkusio/quarkus/pull/22860 将有助于编写 cfg.getGrant().setType(OidcClientConfig.Grant.Type.CODE)
之类的代码,谢谢