|
|
|
@ -10,7 +10,9 @@ import ( |
|
|
|
|
|
|
|
const ( |
|
|
|
userPath = "/auth/admin/realms/:realm/users" |
|
|
|
usersAdminExtensionAPIPath = "/auth/realms/:realmReq/api/admin/realms/:realm/users" |
|
|
|
adminExtensionAPIPath = "/auth/realms/:realmReq/api/admin/realms/:realm" |
|
|
|
usersAdminExtensionAPIPath = adminExtensionAPIPath + "/users" |
|
|
|
sendEmailAdminExtensionAPIPath = adminExtensionAPIPath + "/send-email" |
|
|
|
userCountPath = userPath + "/count" |
|
|
|
userIDPath = userPath + "/:id" |
|
|
|
userGroupsPath = userIDPath + "/groups" |
|
|
|
@ -18,7 +20,8 @@ const ( |
|
|
|
executeActionsEmailPath = userIDPath + "/execute-actions-email" |
|
|
|
sendReminderEmailPath = "/auth/realms/:realm/onboarding/sendReminderEmail" |
|
|
|
smsAPI = "/auth/realms/:realm/smsApi" |
|
|
|
sendNewEnrolmentCode = smsAPI + "/sendNewCode" |
|
|
|
sendSmsCode = smsAPI + "/sendNewCode" |
|
|
|
sendSMSPath = smsAPI + "/sendSms" |
|
|
|
shadowUser = userIDPath + "/federated-identity/:provider" |
|
|
|
) |
|
|
|
|
|
|
|
@ -94,11 +97,11 @@ func (c *Client) ExecuteActionsEmail(accessToken string, realmName string, userI |
|
|
|
return c.put(accessToken, plugins...) |
|
|
|
} |
|
|
|
|
|
|
|
// SendNewEnrolmentCode sends a new enrolment code and return it
|
|
|
|
func (c *Client) SendNewEnrolmentCode(accessToken string, realmName string, userID string) (keycloak.SmsCodeRepresentation, error) { |
|
|
|
// SendSmsCode sends a SMS code and return it
|
|
|
|
func (c *Client) SendSmsCode(accessToken string, realmName string, userID string) (keycloak.SmsCodeRepresentation, error) { |
|
|
|
var paramKV []string |
|
|
|
paramKV = append(paramKV, "userid", userID) |
|
|
|
var plugins = append(createQueryPlugins(paramKV...), url.Path(sendNewEnrolmentCode), url.Param("realm", realmName)) |
|
|
|
var plugins = append(createQueryPlugins(paramKV...), url.Path(sendSmsCode), url.Param("realm", realmName)) |
|
|
|
var resp = keycloak.SmsCodeRepresentation{} |
|
|
|
|
|
|
|
_, err := c.post(accessToken, &resp, plugins...) |
|
|
|
@ -124,3 +127,15 @@ func (c *Client) LinkShadowUser(accessToken string, reqRealmName string, userID |
|
|
|
_, err := c.post(accessToken, nil, url.Path(shadowUser), url.Param("realm", reqRealmName), url.Param("id", userID), url.Param("provider", provider), body.JSON(fedIDKC)) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
// SendEmail sends an email to a user
|
|
|
|
func (c *Client) SendEmail(accessToken string, reqRealmName string, realmName string, emailRep keycloak.EmailRepresentation) error { |
|
|
|
_, err := c.post(accessToken, nil, url.Path(sendEmailAdminExtensionAPIPath), url.Param("realmReq", reqRealmName), url.Param("realm", realmName), body.JSON(emailRep)) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
// SendSMS sends an SMS to a user
|
|
|
|
func (c *Client) SendSMS(accessToken string, realmName string, smsRep keycloak.SMSRepresentation) error { |
|
|
|
_, err := c.post(accessToken, nil, url.Path(sendSMSPath), url.Param("realm", realmName), body.JSON(smsRep)) |
|
|
|
return err |
|
|
|
} |
|
|
|
|