Documentation ¶
Overview ¶
Package keycloak implements a Keycloak REST API client. See https://www.keycloak.org/docs-api/4.8/rest-api/index.html.
Index ¶
- Constants
- func FormatTime(t time.Time) int64
- func ParseTime(msec int64) time.Time
- type Client
- type ClientID
- type ClientRepresentation
- type ClientsQuery
- type ContainerID
- type CredentialRepresentation
- type DecisionStrategy
- type FederatedIdentityRepresentation
- type GroupID
- type GroupRepresentation
- type GroupsQuery
- type Logic
- type MultivaluedHashMap
- type PartialClientRepresentation
- type PartialGroupRepresentation
- type PartialUserRepresentation
- type PolicyEnforcementMode
- type PolicyRepresentation
- type PolicyRepresentationID
- type ProtocolMapperRepresentation
- type ProtocolMapperRepresentationID
- type RESTClient
- func (c *RESTClient) Client(ctx context.Context, realm Realm, clientID ClientID) (*ClientRepresentation, error)
- func (c *RESTClient) ClientRoles(ctx context.Context, realm Realm, clientID ClientID) ([]*RoleRepresentation, error)
- func (c *RESTClient) ClientSecret(ctx context.Context, realm Realm, clientID ClientID) (*CredentialRepresentation, error)
- func (c *RESTClient) Clients(ctx context.Context, realm Realm, clientsQuery *ClientsQuery) ([]*PartialClientRepresentation, error)
- func (c *RESTClient) CreateClient(ctx context.Context, realm Realm, client *ClientRepresentation) (ClientID, error)
- func (c *RESTClient) CreateGroup(ctx context.Context, realm Realm, group *GroupRepresentation) (GroupID, error)
- func (c *RESTClient) CreateUser(ctx context.Context, realm Realm, user *UserRepresentation) (UserID, error)
- func (c *RESTClient) DeleteClient(ctx context.Context, realm Realm, clientID ClientID) error
- func (c *RESTClient) GenerateNewClientSecret(ctx context.Context, realm Realm, clientID ClientID) (*CredentialRepresentation, error)
- func (c *RESTClient) Group(ctx context.Context, realm Realm, groupID GroupID) (*GroupRepresentation, error)
- func (c *RESTClient) Groups(ctx context.Context, realm Realm, groupsQuery *GroupsQuery) ([]*PartialGroupRepresentation, error)
- func (c *RESTClient) UpdateClient(ctx context.Context, realm Realm, client *ClientRepresentation) error
- func (c *RESTClient) User(ctx context.Context, realm Realm, userID UserID) (*UserRepresentation, error)
- func (c *RESTClient) UserAddGroup(ctx context.Context, realm Realm, userID UserID, groupID GroupID) error
- func (c *RESTClient) UserGroups(ctx context.Context, realm Realm, userID UserID) ([]GroupRepresentation, error)
- func (c *RESTClient) UserRemoveGroup(ctx context.Context, realm Realm, userID UserID, groupID GroupID) error
- func (c *RESTClient) Users(ctx context.Context, realm Realm, usersQuery *UsersQuery) ([]*PartialUserRepresentation, error)
- type RESTClientOption
- func AdminClientID(adminClientID ClientID) RESTClientOption
- func AdminRealm(adminRealm Realm) RESTClientOption
- func BaseURL(baseURL string) RESTClientOption
- func ClientCredentialsAuth(clientSecret string) RESTClientOption
- func PasswordAuth(username, password string) RESTClientOption
- func UserAgent(userAgent string) RESTClientOption
- type RESTError
- type Realm
- type RealmClient
- func (r *RealmClient) Client(ctx context.Context, clientID ClientID) (*ClientRepresentation, error)
- func (r *RealmClient) ClientRoles(ctx context.Context, clientID ClientID) ([]*RoleRepresentation, error)
- func (r *RealmClient) ClientSecret(ctx context.Context, clientID ClientID) (*CredentialRepresentation, error)
- func (r *RealmClient) Clients(ctx context.Context, clientsQuery *ClientsQuery) ([]*PartialClientRepresentation, error)
- func (r *RealmClient) CreateClient(ctx context.Context, client *ClientRepresentation) (ClientID, error)
- func (r *RealmClient) CreateGroup(ctx context.Context, group *GroupRepresentation) (GroupID, error)
- func (r *RealmClient) CreateUser(ctx context.Context, user *UserRepresentation) (UserID, error)
- func (r *RealmClient) DeleteClient(ctx context.Context, clientID ClientID) error
- func (r *RealmClient) GenerateNewClientSecret(ctx context.Context, clientID ClientID) (*CredentialRepresentation, error)
- func (r *RealmClient) Group(ctx context.Context, groupID GroupID) (*GroupRepresentation, error)
- func (r *RealmClient) Groups(ctx context.Context, groupsQuery *GroupsQuery) ([]*PartialGroupRepresentation, error)
- func (r *RealmClient) UpdateClient(ctx context.Context, client *ClientRepresentation) error
- func (r *RealmClient) User(ctx context.Context, userID UserID) (*UserRepresentation, error)
- func (r *RealmClient) UserAddGroup(ctx context.Context, userID UserID, groupID GroupID) error
- func (r *RealmClient) UserGroups(ctx context.Context, userID UserID) ([]GroupRepresentation, error)
- func (r *RealmClient) UserRemoveGroup(ctx context.Context, userID UserID, groupID GroupID) error
- func (r *RealmClient) Users(ctx context.Context, usersQuery *UsersQuery) ([]*PartialUserRepresentation, error)
- type ResourceRepresentation
- type ResourceRepresentationID
- type ResourceServerRepresentation
- type ResourceServerRepresentationID
- type RoleID
- type RoleRepresentation
- type RoleRepresentationComposites
- type ScopeRepresentation
- type ScopeRepresentationID
- type UserConsentRepresentation
- type UserID
- type UserRepresentation
- type UsersQuery
Examples ¶
Constants ¶
const ( // DecisionStrategyAffirmative is the affirmative decision strategy. DecisionStrategyAffirmative DecisionStrategy = "AFFIRMATIVE" // DecisionStrategyUnanimous is the unanimous decision strategy. DecisionStrategyUnanimous DecisionStrategy = "UNANIMOUS" // DecisionStrategyConsensus is the consensus decision strategy. DecisionStrategyConsensus DecisionStrategy = "CONSENSUS" // PolicyEnforcementModeEnforcing is the enforcing policy enforcement mode.` PolicyEnforcementModeEnforcing PolicyEnforcementMode = "ENFORCING" // PolicyEnforcementModePermissive is the permissive policy enforcement mode. PolicyEnforcementModePermissive PolicyEnforcementMode = "PERMISSIVE" // PolicyEnforcementModeDisabled is the disabled policy enforcement mode. PolicyEnforcementModeDisabled PolicyEnforcementMode = "DISABLED" // LogicPositive is positive logic. LogicPositive Logic = "POSITIVE" // LogicNegative is negative logic. LogicNegative Logic = "NEGATIVE" )
const ( // DefaultBaseURL is the default base URL. DefaultBaseURL = "http://localhost:8080/auth" // DefaultAdminClientID is the default admin client ID. DefaultAdminClientID ClientID = "admin-cli" // DefaultAdminRealm is the default admin realm. DefaultAdminRealm Realm = "master" // DefaultUserAgent is the default user agent. DefaultUserAgent = "github.com/airmap/go-keycloak" )
Variables ¶
This section is empty.
Functions ¶
func FormatTime ¶
FormatTime converts a time.Time into a Keycloak time.
Types ¶
type Client ¶
type Client interface { Client(ctx context.Context, realm Realm, clientID ClientID) (*ClientRepresentation, error) ClientRoles(ctx context.Context, realm Realm, clientID ClientID) ([]*RoleRepresentation, error) ClientSecret(ctx context.Context, realm Realm, clientID ClientID) (*CredentialRepresentation, error) Clients(ctx context.Context, realm Realm, clientsQuery *ClientsQuery) ([]*PartialClientRepresentation, error) CreateClient(ctx context.Context, realm Realm, client *ClientRepresentation) (ClientID, error) CreateGroup(ctx context.Context, realm Realm, group *GroupRepresentation) (GroupID, error) CreateUser(ctx context.Context, realm Realm, user *UserRepresentation) (UserID, error) DeleteClient(ctx context.Context, realm Realm, clientID ClientID) error GenerateNewClientSecret(ctx context.Context, realm Realm, clientID ClientID) (*CredentialRepresentation, error) Group(ctx context.Context, realm Realm, groupID GroupID) (*GroupRepresentation, error) Groups(ctx context.Context, realm Realm, groupsQuery *GroupsQuery) ([]*PartialGroupRepresentation, error) UpdateClient(ctx context.Context, realm Realm, client *ClientRepresentation) error User(ctx context.Context, realm Realm, userID UserID) (*UserRepresentation, error) UserAddGroup(ctx context.Context, realm Realm, userID UserID, groupID GroupID) error UserGroups(ctx context.Context, realm Realm, userID UserID) ([]GroupRepresentation, error) UserRemoveGroup(ctx context.Context, realm Realm, userID UserID, groupID GroupID) error Users(ctx context.Context, realm Realm, usersQuery *UsersQuery) ([]*PartialUserRepresentation, error) }
Client is the interface implemented by all Keycloak clients.
type ClientRepresentation ¶
type ClientRepresentation struct { Access map[string]interface{} `json:"access,omitempty"` AdminURL string `json:"adminUrl,omitempty"` Attributes map[string][]string `json:"attributes,omitempty"` AuthenticationFlowBindingOverrides map[string]interface{} `json:"authenticationFlowBindingOverrides,omitempty"` AuthorizationServicesEnabled bool `json:"authorizationServicesEnabled,omitempty"` AuthorizationSettings *ResourceServerRepresentation `json:"authorizationSettings,omitempty"` BaseURL string `json:"baseUrl,omitempty"` BearerOnly bool `json:"bearerOnly,omitempty"` ClientAuthenticatorType string `json:"clientAuthenticatorType,omitempty"` ClientID ClientID `json:"clientId,omitempty"` ConsentRequired bool `json:"consentRequired,omitempty"` DefaultClientScopes []string `json:"defaultClientScopes,omitempty"` DefaultRoles []string `json:"defaultRoles,omitempty"` Description string `json:"description,omitempty"` DirectAccessGrantsEnabled bool `json:"directAccessGrantsEnabled,omitempty"` Enabled bool `json:"enabled,omitempty"` FrontchannelLogout bool `json:"frontchannelLogout,omitempty"` FullScopeAllowed bool `json:"fullScopeAllowed,omitempty"` ID ClientID `json:"id,omitempty"` ImplicitFlowEnabled bool `json:"implicitFlowEnabled,omitempty"` Name string `json:"name,omitempty"` NodeReRegistrationTimeout int64 `json:"nodeReRegistrationTimeout,omitempty"` NotBefore int64 `json:"notBefore,omitempty"` ClientScopes []string `json:"clientScopes,omitempty"` Origin string `json:"origin,omitempty"` Protocol string `json:"protocol,omitempty"` ProtocolMappers []*ProtocolMapperRepresentation `json:"protocolMappers,omitempty"` PublicClient bool `json:"publicClient,omitempty"` RedirectURIs []string `json:"redirectUris,omitempty"` RegisteredNodes map[string]interface{} `json:"registeredNodes,omitempty"` RegistrationAccessToken string `json:"registrationAccessToken,omitempty"` RootURL string `json:"rootUrl,omitempty"` Secret string `json:"secret,omitempty"` ServiceAccountsEnabled bool `json:"serviceAccountsEnabled,omitempty"` StandardFlowEnabled bool `json:"standardFlowEnabled,omitempty"` SurrogateAuthRequired bool `json:"surrogateAuthRequired,omitempty"` WebOrigins []string `json:"webOrigins,omitempty"` }
A ClientRepresentation is Keycloak's representation of a Client.
type ClientsQuery ¶
A ClientsQuery contains options for querying clients.
type CredentialRepresentation ¶
type CredentialRepresentation struct { Algorithm string `json:"algorithm,omitempty"` Config MultivaluedHashMap `json:"config,omitempty"` Counter int `json:"counter,omitempty"` CreatedDate int64 `json:"createdDate,omitempty"` Device string `json:"device,omitempty"` Digits int `json:"digits,omitempty"` HashIterations int `json:"hashIterations,omitempty"` HashedSaltedValue string `json:"hashedSaltedValue,omitempty"` Period int `json:"period,omitempty"` Salt string `json:"salt,omitempty"` Temporary bool `json:"temporary,omitempty"` Type string `json:"type,omitempty"` Value string `json:"value,omitempty"` }
A CredentialRepresentation is Keycloak's representation of a Credential.
type FederatedIdentityRepresentation ¶
type FederatedIdentityRepresentation struct { IdentityProvider string `json:"identityProvider,omitempty"` UserID string `json:"userId,omitempty"` // Federated, not a Keycloak UserID. UserName string `json:"userName,omitempty"` // userName, not username. }
A FederatedIdentityRepresentation is Keycloak's representation of a FederatedIdentity.
type GroupRepresentation ¶
type GroupRepresentation struct { Access map[string]interface{} `json:"access,omitempty"` Attributes map[string][]string `json:"attributes,omitempty"` ClientRoles map[string]interface{} `json:"clientRoles,omitempty"` ID GroupID `json:"id,omitempty"` Name string `json:"name,omitempty"` Path string `json:"path,omitempty"` RealmRoles []string `json:"realmRoles,omitempty"` SubGroups []*GroupRepresentation `json:"subGroups,omitempty"` }
A GroupRepresentation is Keycloak's representation of a Group.
type GroupsQuery ¶
A GroupsQuery contains options for querying groups.
type MultivaluedHashMap ¶
type MultivaluedHashMap map[string][]interface{}
A MultivaluedHashMap is map with multiple values for each key. FIXME compare with https://github.com/Azuka/keycloak-admin-go/blob/master/keycloak/types.go#L39-L45
type PartialClientRepresentation ¶
type PartialClientRepresentation ClientRepresentation
A PartialClientRepresentation is a ClientRepresentation that is only partially complete.
type PartialGroupRepresentation ¶
type PartialGroupRepresentation GroupRepresentation
A PartialGroupRepresentation is a GroupRepresentation that is only partially complete.
type PartialUserRepresentation ¶
type PartialUserRepresentation UserRepresentation
A PartialUserRepresentation is a UserRepresentation that is only partially complete.
type PolicyEnforcementMode ¶
type PolicyEnforcementMode string
A PolicyEnforcementMode is a policy enforcement mode.
type PolicyRepresentation ¶
type PolicyRepresentation struct { Config map[string]interface{} `json:"config,omitempty"` DecisionStrategy DecisionStrategy `json:"decisionStrategy,omitempty"` Description string `json:"description,omitempty"` ID PolicyRepresentationID `json:"id,omitempty"` Logic Logic `json:"logic,omitempty"` Name string `json:"name,omitempty"` Owner string `json:"owner,omitempty"` Policies []string `json:"policies,omitempty"` Resources []string `json:"resources,omitempty"` Scopes []string `json:"scopes,omitempty"` Type string `json:"type,omitempty"` }
A PolicyRepresentation is Keycloak's representation of a Policy.
type PolicyRepresentationID ¶
type PolicyRepresentationID string
A PolicyRepresentationID is a policy representation ID.
type ProtocolMapperRepresentation ¶
type ProtocolMapperRepresentation struct { Config map[string]interface{} `json:"config,omitempty"` ID ProtocolMapperRepresentationID `json:"id,omitempty"` Name string `json:"name,omitempty"` Protocol string `json:"protocol,omitempty"` ProtocolMapper string `json:"protocolMapper,omitempty"` }
A ProtocolMapperRepresentation is Keycloak's representation of a ProtocolMapper.
type ProtocolMapperRepresentationID ¶
type ProtocolMapperRepresentationID string
A ProtocolMapperRepresentationID is a protocol mapper representation ID.
type RESTClient ¶
type RESTClient struct {
// contains filtered or unexported fields
}
A RESTClient is a Keycloak REST client.
func NewRESTClient ¶
func NewRESTClient(options ...RESTClientOption) *RESTClient
NewRESTClient returns a new RESTClient with the given options.
Example (ClientCredentialsAuth) ¶
var ( adminClientID = keycloak.DefaultAdminClientID adminClientSecret = "admin-client-secret" adminRealm = keycloak.DefaultAdminRealm baseURL = keycloak.DefaultBaseURL ) restClient := keycloak.NewRESTClient( keycloak.AdminClientID(adminClientID), keycloak.ClientCredentialsAuth(adminClientSecret), keycloak.BaseURL(baseURL), keycloak.AdminRealm(adminRealm), ) _ = restClient
Output:
Example (PasswordAuth) ¶
var ( adminClientID = keycloak.DefaultAdminClientID adminRealm = keycloak.DefaultAdminRealm baseURL = keycloak.DefaultBaseURL username = "username" password = "password" ) restClient := keycloak.NewRESTClient( keycloak.AdminClientID(adminClientID), keycloak.BaseURL(baseURL), keycloak.AdminRealm(adminRealm), keycloak.PasswordAuth(username, password), ) _ = restClient
Output:
func (*RESTClient) Client ¶
func (c *RESTClient) Client(ctx context.Context, realm Realm, clientID ClientID) (*ClientRepresentation, error)
Client returns the client with clientID in realm.
func (*RESTClient) ClientRoles ¶
func (c *RESTClient) ClientRoles(ctx context.Context, realm Realm, clientID ClientID) ([]*RoleRepresentation, error)
ClientRoles returns the client's roles.
func (*RESTClient) ClientSecret ¶
func (c *RESTClient) ClientSecret(ctx context.Context, realm Realm, clientID ClientID) (*CredentialRepresentation, error)
ClientSecret returns the client's secret.
func (*RESTClient) Clients ¶
func (c *RESTClient) Clients(ctx context.Context, realm Realm, clientsQuery *ClientsQuery) ([]*PartialClientRepresentation, error)
Clients returns a slice of clients, filtered according to the query options in clientsQuery.
func (*RESTClient) CreateClient ¶
func (c *RESTClient) CreateClient(ctx context.Context, realm Realm, client *ClientRepresentation) (ClientID, error)
CreateClient creates a new client.
func (*RESTClient) CreateGroup ¶
func (c *RESTClient) CreateGroup(ctx context.Context, realm Realm, group *GroupRepresentation) (GroupID, error)
CreateGroup creates a new group.
func (*RESTClient) CreateUser ¶
func (c *RESTClient) CreateUser(ctx context.Context, realm Realm, user *UserRepresentation) (UserID, error)
CreateUser creates a new user.
func (*RESTClient) DeleteClient ¶
DeleteClient deletes client clientID in realm.
func (*RESTClient) GenerateNewClientSecret ¶
func (c *RESTClient) GenerateNewClientSecret(ctx context.Context, realm Realm, clientID ClientID) (*CredentialRepresentation, error)
GenerateNewClientSecret generates a new client secret for client ClientID.
func (*RESTClient) Group ¶
func (c *RESTClient) Group(ctx context.Context, realm Realm, groupID GroupID) (*GroupRepresentation, error)
Group returns the group groupID in realm.
func (*RESTClient) Groups ¶
func (c *RESTClient) Groups(ctx context.Context, realm Realm, groupsQuery *GroupsQuery) ([]*PartialGroupRepresentation, error)
Groups returns a slice of groups, filtered according to the query options in groupsQuery.
func (*RESTClient) UpdateClient ¶
func (c *RESTClient) UpdateClient(ctx context.Context, realm Realm, client *ClientRepresentation) error
UpdateClient creates a new client in realm.
func (*RESTClient) User ¶
func (c *RESTClient) User(ctx context.Context, realm Realm, userID UserID) (*UserRepresentation, error)
User returns the user userID in realm.
func (*RESTClient) UserAddGroup ¶
func (c *RESTClient) UserAddGroup(ctx context.Context, realm Realm, userID UserID, groupID GroupID) error
UserAddGroup adds userID to groupID in realm.
func (*RESTClient) UserGroups ¶
func (c *RESTClient) UserGroups(ctx context.Context, realm Realm, userID UserID) ([]GroupRepresentation, error)
UserGroups returns the user userID in realm.
func (*RESTClient) UserRemoveGroup ¶
func (c *RESTClient) UserRemoveGroup(ctx context.Context, realm Realm, userID UserID, groupID GroupID) error
UserRemoveGroup removes userID from groupID in realm.
func (*RESTClient) Users ¶
func (c *RESTClient) Users(ctx context.Context, realm Realm, usersQuery *UsersQuery) ([]*PartialUserRepresentation, error)
Users returns a slice of users, filtered according to the query options in userQuery.
type RESTClientOption ¶
type RESTClientOption func(*RESTClient)
A RESTClientOption sets an option on a RESTClient.
func AdminClientID ¶
func AdminClientID(adminClientID ClientID) RESTClientOption
AdminClientID sets the admin client id.
func AdminRealm ¶
func AdminRealm(adminRealm Realm) RESTClientOption
AdminRealm sets the realm for requesting the OpenID Connect token.
func ClientCredentialsAuth ¶
func ClientCredentialsAuth(clientSecret string) RESTClientOption
ClientCredentialsAuth authenticates with a client ID and secret.
func PasswordAuth ¶
func PasswordAuth(username, password string) RESTClientOption
PasswordAuth authenticates with a username and password. This is only available if you build this library with a patched golang.org/x/oauth2 including https://github.com/golang/oauth2/pull/363.
type RESTError ¶
An RESTError is an REST error returned by Keycloak. Keycloak does not report errors in a consistent format. The body can be empty, an arbitrary string, or a JSON object, and may contain useful information for debugging.
type RealmClient ¶
type RealmClient struct {
// contains filtered or unexported fields
}
A RealmClient wraps a Client for a specific realm.
func NewRealmClient ¶
func NewRealmClient(client Client, realm Realm) *RealmClient
NewRealmClient returns a new RealmClient.
func (*RealmClient) Client ¶
func (r *RealmClient) Client(ctx context.Context, clientID ClientID) (*ClientRepresentation, error)
Client wraps Client.
func (*RealmClient) ClientRoles ¶
func (r *RealmClient) ClientRoles(ctx context.Context, clientID ClientID) ([]*RoleRepresentation, error)
ClientRoles wraps ClientRoles.
func (*RealmClient) ClientSecret ¶
func (r *RealmClient) ClientSecret(ctx context.Context, clientID ClientID) (*CredentialRepresentation, error)
ClientSecret wraps ClientSecret.
func (*RealmClient) Clients ¶
func (r *RealmClient) Clients(ctx context.Context, clientsQuery *ClientsQuery) ([]*PartialClientRepresentation, error)
Clients wraps Clients.
func (*RealmClient) CreateClient ¶
func (r *RealmClient) CreateClient(ctx context.Context, client *ClientRepresentation) (ClientID, error)
CreateClient wraps CreateClient.
func (*RealmClient) CreateGroup ¶
func (r *RealmClient) CreateGroup(ctx context.Context, group *GroupRepresentation) (GroupID, error)
CreateGroup wraps CreateGroup.
func (*RealmClient) CreateUser ¶
func (r *RealmClient) CreateUser(ctx context.Context, user *UserRepresentation) (UserID, error)
CreateUser wraps CreateUser.
func (*RealmClient) DeleteClient ¶
func (r *RealmClient) DeleteClient(ctx context.Context, clientID ClientID) error
DeleteClient wraps DeleteClient.
func (*RealmClient) GenerateNewClientSecret ¶
func (r *RealmClient) GenerateNewClientSecret(ctx context.Context, clientID ClientID) (*CredentialRepresentation, error)
GenerateNewClientSecret wraps GenerateNewClientSecret.
func (*RealmClient) Group ¶
func (r *RealmClient) Group(ctx context.Context, groupID GroupID) (*GroupRepresentation, error)
Group wraps Group.
func (*RealmClient) Groups ¶
func (r *RealmClient) Groups(ctx context.Context, groupsQuery *GroupsQuery) ([]*PartialGroupRepresentation, error)
Groups wraps Groups.
func (*RealmClient) UpdateClient ¶
func (r *RealmClient) UpdateClient(ctx context.Context, client *ClientRepresentation) error
UpdateClient wraps UpdateClient.
func (*RealmClient) User ¶
func (r *RealmClient) User(ctx context.Context, userID UserID) (*UserRepresentation, error)
User wraps User.
func (*RealmClient) UserAddGroup ¶
UserAddGroup wraps UserAddGroup.
func (*RealmClient) UserGroups ¶
func (r *RealmClient) UserGroups(ctx context.Context, userID UserID) ([]GroupRepresentation, error)
UserGroups wraps UserGroups.
func (*RealmClient) UserRemoveGroup ¶
UserRemoveGroup wraps UserRemoveGroup.
func (*RealmClient) Users ¶
func (r *RealmClient) Users(ctx context.Context, usersQuery *UsersQuery) ([]*PartialUserRepresentation, error)
Users wraps Users.
Example ¶
var ( restClient = keycloak.NewRESTClient( /* options... */ ) realm = keycloak.Realm("example") realmClient = keycloak.NewRealmClient(restClient, realm) ) ctx := context.Background() var users []*keycloak.PartialUserRepresentation for { // Break when ctx is canceled. select { case <-ctx.Done(): break default: } // Load the next page of users. usersPage, err := realmClient.Users(ctx, &keycloak.UsersQuery{ First: len(users), }) if err != nil { panic(err) } // Break when there are no more users. if len(usersPage) == 0 { break } users = append(users, usersPage...) } _ = users
Output:
type ResourceRepresentation ¶
type ResourceRepresentation struct { ID ResourceRepresentationID `json:"id,omitempty"` Attributes map[string][]string `json:"attributes,omitempty"` DisplayName string `json:"displayName,omitempty"` IconURI string `json:"icon_uri,omitempty"` // JSON icon_uri, not iconUri Name string `json:"name,omitempty"` OwnerManagedAccess bool `json:"ownerManagedAccess,omitempty"` Scopes []*ScopeRepresentation `json:"scopes,omitempty"` Type string `json:"type,omitempty"` URIs []string `json:"uris,omitempty"` }
A ResourceRepresentation is Keycloak's representation of a Resource.
type ResourceRepresentationID ¶
type ResourceRepresentationID string
A ResourceRepresentationID is a resource representation ID.
type ResourceServerRepresentation ¶
type ResourceServerRepresentation struct { AllowRemoteResourceManagement bool `json:"allowRemoteResourceManagement,omitempty"` ClientID ClientID `json:"clientId,omitempty"` ID ResourceServerRepresentationID `json:"id,omitempty"` Name string `json:"name,omitempty"` Policies []*PolicyRepresentation `json:"policies,omitempty"` PolicyEnforcementMode PolicyEnforcementMode `json:"policyEnforcementMode,omitempty"` Resources []*ResourceRepresentation `json:"resources,omitempty"` Scopes []*ScopeRepresentation `json:"scopes,omitempty"` }
A ResourceServerRepresentation is Keycloak's representation of a ResourceServer.
type ResourceServerRepresentationID ¶
type ResourceServerRepresentationID string
A ResourceServerRepresentationID is a resource server representation ID.
type RoleRepresentation ¶
type RoleRepresentation struct { Attributes map[string][]string `json:"attributes,omitempty"` ClientRole bool `json:"clientRole,omitempty"` Composite bool `json:"composite,omitempty"` Composites RoleRepresentationComposites `json:"composites,omitempty"` ContainerID ContainerID `json:"containerId,omitempty"` Description string `json:"description,omitempty"` ID RoleID `json:"id,omitempty"` Name string `json:"name,omitempty"` }
A RoleRepresentation is Keycloak's representation of a Role.
type RoleRepresentationComposites ¶
type RoleRepresentationComposites struct { Client map[string][]string `json:"client,omitempty"` Realm []Realm `json:"realm,omitempty"` }
A RoleRepresentationComposites is Keycloak's representation of a RoleRepresentation Composites.
type ScopeRepresentation ¶
type ScopeRepresentation struct { DisplayName string `json:"displayName,omitempty"` IconURI string `json:"iconUri,omitempty"` ID ScopeRepresentationID `json:"id,omitempty"` Name string `json:"name,omitempty"` Policies []*PolicyRepresentation `json:"policies,omitempty"` Resources []*ResourceRepresentation `json:"resources,omitempty"` }
A ScopeRepresentation is Keycloak's representation of a Scope.
type ScopeRepresentationID ¶
type ScopeRepresentationID string
A ScopeRepresentationID is a scope representation ID.
type UserConsentRepresentation ¶
type UserConsentRepresentation struct { ClientID ClientID `json:"clientId,omitempty"` CreatedDate int64 `json:"createdDate,omitempty"` GrantedClientScopes []string `json:"grantedClientScopes,omitempty"` LastUpdatedDate int64 `json:"lastUpdatedDate,omitempty"` }
A UserConsentRepresentation is Keycloak's representation of a UserConsent.
type UserRepresentation ¶
type UserRepresentation struct { Access map[string]interface{} `json:"access,omitempty"` Attributes map[string][]string `json:"attributes,omitempty"` ClientConsents []*UserConsentRepresentation `json:"clientConsents,omitempty"` ClientRoles map[string]interface{} `json:"clientRoles,omitempty"` CreatedTimestamp int64 `json:"createdTimestamp,omitempty"` Credentials []*CredentialRepresentation `json:"credentials,omitempty"` DisableableCredentialTypes []string `json:"disableableCredentialTypes,omitempty"` Email string `json:"email,omitempty"` EmailVerified bool `json:"emailVerified,omitempty"` Enabled bool `json:"enabled,omitempty"` FederatedIdentities []*FederatedIdentityRepresentation `json:"federatedIdentities,omitempty"` FederationLink string `json:"federationLink,omitempty"` FirstName string `json:"firstName,omitempty"` Groups []string `json:"groups,omitempty"` ID UserID `json:"id,omitempty"` LastName string `json:"lastName,omitempty"` NotBefore int64 `json:"notBefore,omitempty"` Origin string `json:"origin,omitempty"` RealmRoles []string `json:"realmRoles,omitempty"` RequiredActions []string `json:"requiredActions,omitempty"` Self string `json:"self,omitempty"` ServiceAccountClientID ClientID `json:"serviceAccountClientId,omitempty"` Username string `json:"username,omitempty"` }
A UserRepresentation is Keycloak's representation of a User.