Browse Source

Add endpoints from new module keycloak-rest-api-extensions

master
sispeo 7 years ago
committed by harture
parent
commit
26fc713de3
  1. 13
      integration/integration.go
  2. 24
      users.go

13
integration/integration.go

@ -15,7 +15,7 @@ const (
user = "version" user = "version"
) )
// This should be oncverted into // This should be converted into
// GetClient(accessToken string, realmName, idClient string) (kc.ClientRepresentation, error) // GetClient(accessToken string, realmName, idClient string) (kc.ClientRepresentation, error)
// GetClientRoleMappings(accessToken string, realmName, userID, clientID string) ([]kc.RoleRepresentation, error) // GetClientRoleMappings(accessToken string, realmName, userID, clientID string) ([]kc.RoleRepresentation, error)
// AddClientRolesToUserRoleMapping(accessToken string, realmName, userID, clientID string, roles []kc.RoleRepresentation) error // AddClientRolesToUserRoleMapping(accessToken string, realmName, userID, clientID string, roles []kc.RoleRepresentation) error
@ -287,6 +287,17 @@ func main() {
} }
} }
fmt.Println("User updated.") fmt.Println("User updated.")
// Check credentials
{
tstRealmReq := "master"
var creds, err = client.GetCredentialsForUser(accessToken, tstRealmReq, tstRealm, userID)
if err != nil {
log.Fatalf("could not get credentials: %v", err)
}
if len(creds) != 0 {
log.Fatalf("Maria should not have credentials")
}
}
} }
// Delete user. // Delete user.

24
users.go

@ -8,11 +8,13 @@ import (
) )
const ( const (
userPath = "/auth/admin/realms/:realm/users" userPath = "/auth/admin/realms/:realm/users"
userCountPath = userPath + "/count" userCountPath = userPath + "/count"
userIDPath = userPath + "/:id" userIDPath = userPath + "/:id"
resetPasswordPath = userIDPath + "/reset-password" resetPasswordPath = userIDPath + "/reset-password"
sendVerifyEmailPath = userIDPath + "/send-verify-email" sendVerifyEmailPath = userIDPath + "/send-verify-email"
getCredentialsForUserPath = "/auth/realms/:realmReq/api/realms/:realm/users/:id/credentials"
deleteCredentialsForUserPath = getCredentialsForUserPath + "/:credid"
) )
// GetUsers returns a list of users, filtered according to the query parameters. // GetUsers returns a list of users, filtered according to the query parameters.
@ -74,3 +76,15 @@ func (c *Client) SendVerifyEmail(accessToken string, realmName string, userID st
return c.put(accessToken, plugins...) return c.put(accessToken, plugins...)
} }
// GetCredentialsForUser gets the credential list for a user
func (c *Client) GetCredentialsForUser(accessToken string, realmReq, realmName string, userID string) ([]CredentialRepresentation, error) {
var resp = []CredentialRepresentation{}
var err = c.get(accessToken, &resp, url.Path(getCredentialsForUserPath), url.Param("realmReq", realmReq), url.Param("realm", realmName), url.Param("id", userID))
return resp, err
}
// DeleteCredentialsForUser remove credentials for a user
func (c *Client) DeleteCredentialsForUser(accessToken string, realmReq, realmName string, userID string, credentialID string) error {
return c.delete(accessToken, url.Path(deleteCredentialsForUserPath), url.Param("realmReq", realmReq), url.Param("realm", realmName), url.Param("id", userID), url.Param("credid", userID))
}

Loading…
Cancel
Save