Keycloak 设置用户配置 OTP 所需的操作

问题描述 投票:0回答:1

如何通过keycloak API为用户设置所需的操作?我在他们的管理休息 API 文档中没有找到它。只有

PUT /{realm}/users/{userId}/execute-actions-email

但它通过电子邮件工作,这不符合我的要求。我想强迫用户 在下次登录时配置 OTP。 谁能告诉我

{userId}

之后的网址应该是什么

我已经尝试过这个网址

PUT /{realm}/users/{userId}/settings

但这对我不起作用。

authentication keycloak totp
1个回答
0
投票

REST API

PUT /{realm}/users/{userId}

Payload

{
    "id": {user id},
    "username": {user name},
    "email": {user email},
    "emailVerified": false,
    "createdTimestamp": {Epoch & Unix Timestamp},
    "enabled": true,
    "totp": false,
    "disableableCredentialTypes": [],
    "requiredActions": [
        "CONFIGURE_TOTP"
    ],
    "notBefore": 0,
    "access": {
        "manageGroupMembership": true,
        "view": true,
        "mapRoles": true,
        "impersonate": true,
        "manage": true
    },
    "attributes": {},
    "firstName": {first name},
    "lastName": {last name}
}

示例

{
    "id": "0baf6148-01f1-4bad-a781-da1bfd36d234",
    "username": "user1",
    "email": "[email protected]",
    "emailVerified": false,
    "createdTimestamp": 1731062915931,
    "enabled": true,
    "totp": false,
    "disableableCredentialTypes": [],
    "requiredActions": [
        "CONFIGURE_TOTP"
    ],
    "notBefore": 0,
    "access": {
        "manageGroupMembership": true,
        "view": true,
        "mapRoles": true,
        "impersonate": true,
        "manage": true
    },
    "attributes": {},
    "firstName": "",
    "lastName": ""
}

user actions list

VERIFY_EMAIL, UPDATE_PROFILE, CONFIGURE_TOTP, UPDATE_PASSWORD, TERMS_AND_CONDITIONS

结果

当他/她登录时,显示 OTP 配置屏幕。 enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.