Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Keycloak 如果“登录”;“所需用户操作”;存在_Keycloak - Fatal编程技术网

Keycloak 如果“登录”;“所需用户操作”;存在

Keycloak 如果“登录”;“所需用户操作”;存在,keycloak,Keycloak,如果一个现有的KeyClope用户有一个或多个必需的用户操作,我会遇到以下问题 我们使用keydrope(3.4.2.Final)RESTAPI登录到keydrope。但是,如果用户被锁定或存在任何必需的用户操作,则KeyClope始终返回代码401(无效的授权)。因此,我无法确定主要问题是什么 对于锁定,我不需要验证用户的密码,使用任何密码(调用attackdetection rest api),我可以告诉最终用户帐户已锁定,但对于所需的用户操作不同,用户必须成功登录,然后我才能处理下一步 例

如果一个现有的KeyClope用户有一个或多个必需的用户操作,我会遇到以下问题

我们使用keydrope(3.4.2.Final)RESTAPI登录到keydrope。但是,如果用户被锁定或存在任何必需的用户操作,则KeyClope始终返回代码401(无效的授权)。因此,我无法确定主要问题是什么

对于锁定,我不需要验证用户的密码,使用任何密码(调用attackdetection rest api),我可以告诉最终用户帐户已锁定,但对于所需的用户操作不同,用户必须成功登录,然后我才能处理下一步

例如,更新密码:

使用用户名/密码->成功登录或用户名/密码验证->处理用户操作->更新密码->用户登录登录登录


如果有任何想法,我将不胜感激。

以防万一还有人关心答案: 您可以使用KeyClope的AdminRESTAPI更新用户

PUT /auth/admin/realms/myrealm/users/myKeycloakUserId { "id": "myKeycloakUserId", "createdTimestamp": 1547730135139, "username": "myusername", "enabled": true, "totp": false, "emailVerified": true, "firstName": "myfirstname", "lastName": "mylastname", "email": "myemail", "attributes": { "privacyStatementAcceptedDate": [ "2019-01-17T13:02:15.189Z" ], "welcomeEmailDate": [ "2019-01-17T13:02:30.370Z" ], "gender": [ "female" ], "legalAgeConfirmedDate": [ "2019-01-17T13:02:15.189Z" ], "termsAcceptedDate": [ "2019-01-17T13:02:15.189Z" ] }, "disableableCredentialTypes": [ "password" ], "requiredActions": [], "notBefore": 0, "access": { "manageGroupMembership": true, "view": true, "mapRoles": true, "impersonate": true, "manage": true } }
我在Java客户端库中努力为用户清除所需操作,这对我很有帮助。:)
org.keycloak.admin.client.Keycloak keycloak = KeycloakBuilder.builder()
    .serverUrl(KEYCLOAK_ADMIN_BASEURL))
    .realm(KEYCLOAK_ADMIN_REALM))
    .grantType(OAuth2Constants.CLIENT_CREDENTIALS)
    .clientId(KEYCLOAK_ADMIN_CLIENTID))
    .clientSecret(KEYCLOAK_ADMIN_CLIENTSECRET))
    .build();

final UserResource keycloakUserResource = keycloak.realm(
            configurationService.getValue(KEYCLOAK_ADMIN_REALM)).users().get(
            keycloakUserId);
//load the users user-representation from Keycloak
final UserRepresentation userRepresentation = keycloakUserResource.toRepresentation();
if (userRepresentation == null) {
    throw new Exception("Failed to load the UserRepresentation for the current User");
}

//adapt the user-representation
userRepresentation.setRequiredActions(Collections.emptyList());

//update user in Keycloak
keycloakUserResource.update(userRepresentation);