我正在用spring boot和创建/sso/login和/sso/logout urls的keycloak-spring-boot-starter来保护web应用程序的构建。但我也想提供一个到钥匙罩注册页面的链接-但没有/sso/register链接。
如何实现此链接?我在keycloak-adapter源码中找不到实现login/logout资源的地方,所以指向它可能就足够了。
发布于 2021-03-25 18:23:40
你可以像下面的代码一样创建你自己的注册链接;
String nonce = UUID.randomUUID().toString();
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
String input = nonce + clientId;
byte[] check = md.digest(input.getBytes(StandardCharsets.UTF_8));
String hash = Base64Url.encode(check);
return KeycloakUriBuilder.fromUri(keycloakEndpoint)
.path("/realms/{realm-name}/protocol/openid-connect/registrations")
.queryParam("response_type", "code") // Autherization Code Flow
.queryParam("scope", "openid") // Add additional scopes if needed
.queryParam("nonce", nonce)
.queryParam("hash", hash)
.queryParam("client_id", clientId)
.queryParam("redirect_uri", "http://sample.javaspringboot.com/" + "redirect/" + redirectUrl).build(realm).toString();https://stackoverflow.com/questions/46322687
复制相似问题