Documentation ¶
Overview ¶
package keycloakadm contains a client and relevant data structs for interacting with the Keycloak Admin REST API
For mapping, see https://www.keycloakadmorg/docs-api/4.0/rest-api/index.html
Index ¶
- Constants
- type AttributeMap
- type AuthenticationExecutionExportRepresentation
- type AuthenticationFlowRepresentation
- type AuthenticatorConfigRepresentation
- type Client
- type ClientRepresentation
- type ClientScopeRepresentation
- type ClientService
- func (s *ClientService) AddProtocolMappers(ctx context.Context, client *ClientRepresentation, ...) error
- func (s *ClientService) Create(ctx context.Context, client *ClientRepresentation) (string, error)
- func (s *ClientService) CreateRole(ctx context.Context, client *ClientRepresentation, role *RoleRepresentation) error
- func (s *ClientService) Delete(ctx context.Context, client *ClientRepresentation) error
- func (s *ClientService) DeleteProtocolMapper(ctx context.Context, client *ClientRepresentation, ...) error
- func (s *ClientService) DeleteRole(ctx context.Context, client *ClientRepresentation, role *RoleRepresentation) error
- func (s *ClientService) Find(ctx context.Context, params map[string]string) ([]ClientRepresentation, error)
- func (s *ClientService) Get(ctx context.Context, ID string) (*ClientRepresentation, error)
- func (s *ClientService) GetProtocolMappers(ctx context.Context, client *ClientRepresentation) ([]ProtocolMapperRepresentation, error)
- func (s *ClientService) GetRole(ctx context.Context, client *ClientRepresentation, roleName string) (*RoleRepresentation, error)
- func (s *ClientService) GetServiceAccountUser(ctx context.Context, ID string) (*UserRepresentation, error)
- func (s *ClientService) ListRoles(ctx context.Context, client *ClientRepresentation) ([]RoleRepresentation, error)
- func (s *ClientService) Realm() string
- func (s *ClientService) Update(ctx context.Context, client *ClientRepresentation) error
- func (s *ClientService) UpdateProtocolMapper(ctx context.Context, client *ClientRepresentation, ...) error
- type CredentialRepresentation
- type Error
- type FederatedIdentityRepresentation
- type GroupRepresentation
- type GroupService
- func (s *GroupService) AddRole(ctx context.Context, groupID string, role RoleRepresentation) error
- func (s *GroupService) Create(ctx context.Context, groupName string) error
- func (s *GroupService) Delete(ctx context.Context, groupID string) error
- func (s *GroupService) DeleteRole(ctx context.Context, groupID string, role RoleRepresentation) error
- func (s *GroupService) Get(ctx context.Context, groupID string) (*GroupRepresentation, error)
- func (s *GroupService) List(ctx context.Context) ([]GroupRepresentation, error)
- func (s *GroupService) ListMapping(ctx context.Context, groupID string) (*MappingRepresentation, error)
- func (s *GroupService) Realm() string
- type IdentityProviderMapperRepresentation
- type IdentityProviderRepresentation
- type MappingRepresentation
- type MultivaluedHashMap
- type PolicyRepresentation
- type ProtocolMapperRepresentation
- type RealmRepresentation
- type RealmService
- func (s *RealmService) Create(ctx context.Context, realm *RealmRepresentation) error
- func (s *RealmService) Delete(ctx context.Context, realm string) error
- func (s *RealmService) Get(ctx context.Context, realm string) (*RealmRepresentation, error)
- func (s *RealmService) List(ctx context.Context) ([]RealmRepresentation, error)
- type RequiredActionProviderRepresentation
- type ResourceRepresentation
- type ResourceServerRepresentation
- type RoleComposites
- type RoleRepresentation
- type RoleService
- func (s *RoleService) AddComposite(ctx context.Context, role *RoleRepresentation, composites []RoleRepresentation) error
- func (s *RoleService) Create(ctx context.Context, role *RoleRepresentation) (string, error)
- func (s *RoleService) Delete(ctx context.Context, role *RoleRepresentation) error
- func (s *RoleService) Get(ctx context.Context, name string) (*RoleRepresentation, error)
- func (s *RoleService) GetComposites(ctx context.Context, role *RoleRepresentation) ([]RoleRepresentation, error)
- func (s *RoleService) List(ctx context.Context) ([]RoleRepresentation, error)
- func (s *RoleService) Realm() string
- func (s *RoleService) RemoveComposite(ctx context.Context, role *RoleRepresentation, composites []RoleRepresentation) error
- type RolesRepresentation
- type ScopeMappingRepresentation
- type ScopeRepresentation
- type UnixTime
- type UserConsentRepresentation
- type UserFederationMapperRepresentation
- type UserFederationProviderRepresentation
- type UserRepresentation
- type UserService
- func (s *UserService) AddGroup(ctx context.Context, user *UserRepresentation, groupID string) error
- func (s *UserService) AddRole(ctx context.Context, user *UserRepresentation, role RoleRepresentation) error
- func (s *UserService) Count(ctx context.Context, realm string) (uint32, error)
- func (s *UserService) Create(ctx context.Context, user *UserRepresentation) (string, error)
- func (s *UserService) Delete(ctx context.Context, user *UserRepresentation) error
- func (s *UserService) DeleteRole(ctx context.Context, user *UserRepresentation, role RoleRepresentation) error
- func (s *UserService) DisableCredentials(ctx context.Context, user *UserRepresentation, credentialTypes []string) error
- func (s *UserService) Find(ctx context.Context, params map[string]string) ([]UserRepresentation, error)
- func (s *UserService) Get(ctx context.Context, userID string) (*UserRepresentation, error)
- func (s *UserService) GetConsents(ctx context.Context, user *UserRepresentation) (AttributeMap, error)
- func (s *UserService) GetGroups(ctx context.Context, user *UserRepresentation) ([]GroupRepresentation, error)
- func (s *UserService) GetOfflineSessions(ctx context.Context, user *UserRepresentation, clientID string) ([]UserSessionRepresentation, error)
- func (s *UserService) GetSessions(ctx context.Context, user *UserRepresentation) ([]UserSessionRepresentation, error)
- func (s *UserService) Impersonate(ctx context.Context, user *UserRepresentation) (AttributeMap, error)
- func (s *UserService) List(ctx context.Context, realm string) ([]UserRepresentation, error)
- func (s *UserService) ListClientRoles(ctx context.Context, user *UserRepresentation, client *ClientRepresentation) ([]RoleRepresentation, error)
- func (s *UserService) ListRealmRoles(ctx context.Context, user *UserRepresentation) ([]RoleRepresentation, error)
- func (s *UserService) Logout(ctx context.Context, user *UserRepresentation) error
- func (s *UserService) Realm() string
- func (s *UserService) RemoveGroup(ctx context.Context, user *UserRepresentation, groupID string) error
- func (s *UserService) ResetPassword(ctx context.Context, user *UserRepresentation, ...) error
- func (s *UserService) RevokeClientConsents(ctx context.Context, user *UserRepresentation, clientID string) error
- func (s *UserService) Update(ctx context.Context, user *UserRepresentation) error
- type UserSessionRepresentation
Examples ¶
Constants ¶
const ( // PolicyEnforcementModeEnforcing marks policy enforcement as enforcing PolicyEnforcementModeEnforcing = "ENFORCING" // PolicyEnforcementModePermissive marks policy enforcement as permissive PolicyEnforcementModePermissive = "PERMISSIVE" // PolicyEnforcementModeDisabled marks policy enforcement as disabled PolicyEnforcementModeDisabled = "DISABLED" // DecisionstrategyAffirmative sets decision strategy to affirmative DecisionstrategyAffirmative = "AFFIRMATIVE" // DecisionstrategyUnanimous sets decision strategy to unanimous DecisionstrategyUnanimous = "UNANIMOUS" // DecisionstrategyConsensus sets decision strategy to consensus DecisionstrategyConsensus = "CONSENSUS" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributeMap ¶
type AttributeMap map[string]interface{}
AttributeMap represents a map of attributes
type AuthenticationExecutionExportRepresentation ¶
type AuthenticationExecutionExportRepresentation struct { Authenticator string `json:"authenticator,omitempty"` AuthenticatorConfig string `json:"authenticatorConfig,omitempty"` AuthenticatorFlow *bool `json:"authenticatorFlow,omitempty"` AutheticatorFlow *bool `json:"autheticatorFlow,omitempty"` FlowAlias string `json:"flowAlias,omitempty"` Priority int `json:"priority,omitempty"` Requirement string `json:"requirement,omitempty"` UserSetupAllowed *bool `json:"userSetupAllowed,omitempty"` }
AuthenticationExecutionExportRepresentation for Authenticator Execution
type AuthenticationFlowRepresentation ¶
type AuthenticationFlowRepresentation struct { Alias string `json:"alias,omitempty"` AuthenticationExecutions []AuthenticationExecutionExportRepresentation `json:"authenticationExecutions,omitempty"` BuiltIn *bool `json:"builtIn,omitempty"` Description string `json:"description,omitempty"` ID string `json:"id,omitempty"` ProviderID string `json:"providerId,omitempty"` TopLevel *bool `json:"topLevel,omitempty"` }
AuthenticationFlowRepresentation for representing Flows
type AuthenticatorConfigRepresentation ¶
type AuthenticatorConfigRepresentation struct { Alias string `json:"alias,omitempty"` Config AttributeMap `json:"config,omitempty"` ID string `json:"id,omitempty"` }
AuthenticatorConfigRepresentation Authenticator Config
type Client ¶
Client is the API client for talking to keycloak admin
func NewClient ¶
NewClient creates a new client instance set to talk to the keycloak service as well as the various services for working with specific resources
Example ¶
u, _ := url.Parse("http://localhost/auth/admin") c := NewClient(*u, http.DefaultClient, testRelam) userID, _ := c.Users().Create(context.Background(), &UserRepresentation{ Username: "hello-world", }) fmt.Println("UserID: ", userID)
Output:
func (*Client) Clients ¶
func (c *Client) Clients() *ClientService
Clients returns a new client service for working with client resources in a realm.
func (*Client) Groups ¶
func (c *Client) Groups() *GroupService
Groups returns a new group service for working with group resources in a realm.
func (*Client) Realms ¶
func (c *Client) Realms() *RealmService
NewRealmService returns a new realm service for working with realm resources
func (*Client) Roles ¶
func (c *Client) Roles() *RoleService
Roles returns a new role service for working with role resources in a realm.
func (*Client) Users ¶
func (c *Client) Users() *UserService
Users returns a new user service for working with user resources in a realm.
type ClientRepresentation ¶
type ClientRepresentation struct { Access AttributeMap `json:"access,omitempty"` AdminURL string `json:"adminUrl,omitempty"` Attributes AttributeMap `json:"attributes,omitempty"` AuthenticationFlowBindingOverrides AttributeMap `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 string `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 string `json:"id,omitempty"` ImplicitFlowEnabled *bool `json:"implicitFlowEnabled,omitempty"` Name string `json:"name,omitempty"` NodeRegistrationTimeout *UnixTime `json:"nodeRegistrationTimeout,omitempty"` NotBefore *UnixTime `json:"notBefore,omitempty"` OptionalClientScopes []string `json:"optionalClientScopes,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 AttributeMap `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"` }
ClientRepresentation represents a client's configuration in a realm
type ClientScopeRepresentation ¶
type ClientScopeRepresentation struct { Attributes AttributeMap `json:"attributes,omitempty"` Description string `json:"description,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Protocol string `json:"protocol,omitempty"` ProtocolMappers []ProtocolMapperRepresentation `json:"protocolMappers,omitempty"` }
ClientScopeRepresentation Client Scope
type ClientService ¶
type ClientService service
ClientService interacts with all user resources
func (*ClientService) AddProtocolMappers ¶
func (s *ClientService) AddProtocolMappers(ctx context.Context, client *ClientRepresentation, mappers []ProtocolMapperRepresentation) error
AddProtocolMappers adds protocol mappers
func (*ClientService) Create ¶
func (s *ClientService) Create(ctx context.Context, client *ClientRepresentation) (string, error)
Create creates a new client and returns the ID Response is a 201 with a location redirect
func (*ClientService) CreateRole ¶
func (s *ClientService) CreateRole(ctx context.Context, client *ClientRepresentation, role *RoleRepresentation) error
CreateRole creates a role
func (*ClientService) Delete ¶
func (s *ClientService) Delete(ctx context.Context, client *ClientRepresentation) error
Delete deletes a client
func (*ClientService) DeleteProtocolMapper ¶
func (s *ClientService) DeleteProtocolMapper(ctx context.Context, client *ClientRepresentation, mapper *ProtocolMapperRepresentation) error
DeleteProtocolMapper deletes a protocol mapper
func (*ClientService) DeleteRole ¶
func (s *ClientService) DeleteRole(ctx context.Context, client *ClientRepresentation, role *RoleRepresentation) error
DeleteRole deletes a role
func (*ClientService) Find ¶
func (s *ClientService) Find(ctx context.Context, params map[string]string) ([]ClientRepresentation, error)
Find returns clients based on query params Params: - clientId
func (*ClientService) Get ¶
func (s *ClientService) Get(ctx context.Context, ID string) (*ClientRepresentation, error)
Get returns a client in a realm
func (*ClientService) GetProtocolMappers ¶
func (s *ClientService) GetProtocolMappers(ctx context.Context, client *ClientRepresentation) ([]ProtocolMapperRepresentation, error)
GetProtocolMappers gets protocol mappers
func (*ClientService) GetRole ¶
func (s *ClientService) GetRole(ctx context.Context, client *ClientRepresentation, roleName string) (*RoleRepresentation, error)
GetRole gets a client role by name
func (*ClientService) GetServiceAccountUser ¶
func (s *ClientService) GetServiceAccountUser(ctx context.Context, ID string) (*UserRepresentation, error)
GetServiceAccountUser returns the service account user associated with the client
func (*ClientService) ListRoles ¶
func (s *ClientService) ListRoles(ctx context.Context, client *ClientRepresentation) ([]RoleRepresentation, error)
ListRoles returns all the client roles
func (*ClientService) Realm ¶
func (s *ClientService) Realm() string
Realm returns the reaml the service is operating in
func (*ClientService) Update ¶
func (s *ClientService) Update(ctx context.Context, client *ClientRepresentation) error
Update updates the given client
func (*ClientService) UpdateProtocolMapper ¶
func (s *ClientService) UpdateProtocolMapper(ctx context.Context, client *ClientRepresentation, mapper *ProtocolMapperRepresentation) error
UpdateProtocolMapper updates a protocol mapper
type CredentialRepresentation ¶
type CredentialRepresentation struct { Algorithm string `json:"algorithm,omitempty"` Counter int32 `json:"counter,omitempty"` CreatedDate *UnixTime `json:"createdDate,omitempty"` Device string `json:"device,omitempty"` Digits int32 `json:"digits,omitempty"` HashIterations int32 `json:"hashIterations,omitempty"` HashedSaltedValue string `json:"hashedSaltedValue,omitempty"` Period int32 `json:"period,omitempty"` Salt string `json:"salt,omitempty"` Temporary *bool `json:"temporary,omitempty"` Type string `json:"type,omitempty"` Value string `json:"value,omitempty"` }
CredentialRepresentation represents credentials for a user or client
type FederatedIdentityRepresentation ¶
type FederatedIdentityRepresentation struct { IdentityProvider string `json:"identityProvider,omitempty"` UserID string `json:"userId,omitempty"` UserName string `json:"userName,omitempty"` }
FederatedIdentityRepresentation represents a federated identity
type GroupRepresentation ¶
type GroupRepresentation struct { Access AttributeMap `json:"access,omitempty"` Attributes AttributeMap `json:"attributes,omitempty"` ClientRoles AttributeMap `json:"clientRoles,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Path string `json:"path,omitempty"` RealmRoles []string `json:"realmRoles,omitempty"` SubGroups []GroupRepresentation `json:"subGroups,omitempty"` }
GroupRepresentation represents a single user group in a realm
type GroupService ¶
type GroupService service
GroupService interacts with all user resources
func (*GroupService) AddRole ¶
func (s *GroupService) AddRole(ctx context.Context, groupID string, role RoleRepresentation) error
AddRole adds a role to a group in a realm
func (*GroupService) Create ¶
func (s *GroupService) Create(ctx context.Context, groupName string) error
Create creates a group in a realm
func (*GroupService) Delete ¶
func (s *GroupService) Delete(ctx context.Context, groupID string) error
Delete deletes a group from a realm
func (*GroupService) DeleteRole ¶
func (s *GroupService) DeleteRole(ctx context.Context, groupID string, role RoleRepresentation) error
DeleteRole deletes a role from a group in a realm
func (*GroupService) Get ¶
func (s *GroupService) Get(ctx context.Context, groupID string) (*GroupRepresentation, error)
Get returns a group in a realm
func (*GroupService) List ¶
func (s *GroupService) List(ctx context.Context) ([]GroupRepresentation, error)
List returns all groups in a realm
func (*GroupService) ListMapping ¶
func (s *GroupService) ListMapping(ctx context.Context, groupID string) (*MappingRepresentation, error)
ListMapping returns a all role mappings for group (TODO: maybe put this as a GroupRepresentation Method)
func (*GroupService) Realm ¶
func (s *GroupService) Realm() string
Realm returns the reaml the service is operating in
type IdentityProviderMapperRepresentation ¶
type IdentityProviderMapperRepresentation struct { Config AttributeMap `json:"config,omitempty"` ID string `json:"id,omitempty"` IdentityProviderAlias string `json:"identityProviderAlias,omitempty"` IdentityProviderMapper string `json:"identityProviderMapper,omitempty"` Name string `json:"name,omitempty"` }
IdentityProviderMapperRepresentation Identity Provider Mapper
type IdentityProviderRepresentation ¶
type IdentityProviderRepresentation struct { AddReadTokenRoleOnCreate *bool `json:"addReadTokenRoleOnCreate,omitempty"` Alias string `json:"alias,omitempty"` Config AttributeMap `json:"config,omitempty"` DisplayName string `json:"displayName,omitempty"` Enabled *bool `json:"enabled,omitempty"` FirstBrokerLoginFlowAlias string `json:"firstBrokerLoginFlowAlias,omitempty"` InternalID string `json:"internalId,omitempty"` LinkOnly *bool `json:"linkOnly,omitempty"` PostBrokerLoginFlowAlias string `json:"postBrokerLoginFlowAlias,omitempty"` ProviderID string `json:"providerId,omitempty"` StoreToken *bool `json:"storeToken,omitempty"` TrustEmail *bool `json:"trustEmail,omitempty"` }
IdentityProviderRepresentation Identity Provider
type MappingRepresentation ¶
type MappingRepresentation struct { RealmMappings []RoleRepresentation `json:"realmMappings,omitempty"` ClientMappings bool `json:"clientMappings,omitempty"` }
type MultivaluedHashMap ¶
type MultivaluedHashMap struct { Empty bool `json:"empty,omitempty"` LoadFactor float64 `json:"loadFactor,omitempty"` Threshold int32 `json:"threshold,omitempty"` }
MultivaluedHashMap multivalued map easyjson:json
type PolicyRepresentation ¶
type PolicyRepresentation struct { Config AttributeMap `json:"config,omitempty"` DecisionStrategy string `json:"decisionStrategy,omitempty"` Description string `json:"description,omitempty"` ID string `json:"id,omitempty"` Logic string `json:"logic,omitempty"` //enum (POSITIVE, NEGATIVE) 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"` }
PolicyRepresentation represents the policies attached to the resource server for a realm client
type ProtocolMapperRepresentation ¶
type ProtocolMapperRepresentation struct { Config AttributeMap `json:"config,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Protocol string `json:"protocol,omitempty"` ProtocolMapper string `json:"protocolMapper,omitempty"` }
ProtocolMapperRepresentation represents an individual protocol mapper on a realm client
type RealmRepresentation ¶
type RealmRepresentation struct { AccessCodeLifespan int `json:"accessCodeLifespan,omitempty"` AccessCodeLifespanLogin int `json:"accessCodeLifespanLogin,omitempty"` AccessCodeLifespanUserAction int `json:"accessCodeLifespanUserAction,omitempty"` AccessTokenLifespan int `json:"accessTokenLifespan,omitempty"` AccessTokenLifespanForImplicitFlow int `json:"accessTokenLifespanForImplicitFlow,omitempty"` AccountTheme string `json:"accountTheme,omitempty"` ActionTokenGeneratedByAdminLifespan int `json:"actionTokenGeneratedByAdminLifespan,omitempty"` ActionTokenGeneratedByUserLifespan int `json:"actionTokenGeneratedByUserLifespan,omitempty"` AdminEventsDetailsEnabled *bool `json:"adminEventsDetailsEnabled,omitempty"` AdminEventsEnabled *bool `json:"adminEventsEnabled,omitempty"` AdminTheme string `json:"adminTheme,omitempty"` Attributes AttributeMap `json:"attributes,omitempty"` AuthenticationFlows []AuthenticationFlowRepresentation `json:"authenticationFlows,omitempty"` AuthenticatorConfig []AuthenticatorConfigRepresentation `json:"authenticatorConfig,omitempty"` BrowserFlow string `json:"browserFlow,omitempty"` BrowserSecurityHeaders AttributeMap `json:"browserSecurityHeaders,omitempty"` BruteForceProtected *bool `json:"bruteForceProtected,omitempty"` ClientAuthenticationFlow string `json:"clientAuthenticationFlow,omitempty"` ClientScopeMappings AttributeMap `json:"clientScopeMappings,omitempty"` ClientScopes []ClientScopeRepresentation `json:"clientScopes,omitempty"` Clients []ClientRepresentation `json:"clients,omitempty"` Components MultivaluedHashMap `json:"components,omitempty"` DefaultDefaultClientScopes []string `json:"defaultDefaultClientScopes,omitempty"` DefaultGroups []string `json:"defaultGroups,omitempty"` DefaultLocale string `json:"defaultLocale,omitempty"` DefaultOptionalClientScopes []string `json:"defaultOptionalClientScopes,omitempty"` DefaultRoles []string `json:"defaultRoles,omitempty"` DirectGrantFlow string `json:"directGrantFlow,omitempty"` DisplayName string `json:"displayName,omitempty"` DisplayNameHTML string `json:"displayNameHtml,omitempty"` DockerAuthenticationFlow string `json:"dockerAuthenticationFlow,omitempty"` DuplicateEmailsAllowed *bool `json:"duplicateEmailsAllowed,omitempty"` EditUsernameAllowed *bool `json:"editUsernameAllowed,omitempty"` EmailTheme string `json:"emailTheme,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledEventTypes []string `json:"enabledEventTypes,omitempty"` EventsEnabled *bool `json:"eventsEnabled,omitempty"` EventsExpiration int `json:"eventsExpiration,omitempty"` EventsListeners []string `json:"eventsListeners,omitempty"` FailureFactor int `json:"failureFactor,omitempty"` FederatedUsers []UserRepresentation `json:"federatedUsers,omitempty"` Groups []GroupRepresentation `json:"groups,omitempty"` ID string `json:"id,omitempty"` IdentityProviderMappers []IdentityProviderMapperRepresentation `json:"identityProviderMappers,omitempty"` IdentityProviders []IdentityProviderRepresentation `json:"identityProviders,omitempty"` InternationalizationEnabled *bool `json:"internationalizationEnabled,omitempty"` KeycloakVersion string `json:"keycloakVersion,omitempty"` LoginTheme string `json:"loginTheme,omitempty"` LoginWithEmailAllowed *bool `json:"loginWithEmailAllowed,omitempty"` MaxDeltaTimeSeconds int `json:"maxDeltaTimeSeconds,omitempty"` MaxFailureWaitSeconds int `json:"maxFailureWaitSeconds,omitempty"` MinimumQuickLoginWaitSeconds int `json:"minimumQuickLoginWaitSeconds,omitempty"` NotBefore int `json:"notBefore,omitempty"` OfflineSessionIdleTimeout int `json:"offlineSessionIdleTimeout,omitempty"` OtpPolicyAlgorithm string `json:"otpPolicyAlgorithm,omitempty"` OtpPolicyDigits int `json:"otpPolicyDigits,omitempty"` OtpPolicyLookAheadWindow int `json:"otpPolicyLookAheadWindow,omitempty"` OtpPolicyPeriod int `json:"otpPolicyPeriod,omitempty"` OtpPolicyType string `json:"otpPolicyType,omitempty"` OtpSupportedApplications []string `json:"otpSupportedApplications,omitempty"` PasswordPolicy string `json:"passwordPolicy,omitempty"` PermanentLockout *bool `json:"permanentLockout,omitempty"` ProtocolMappers []ProtocolMapperRepresentation `json:"protocolMappers,omitempty"` QuickLoginCheckMilliSeconds int `json:"quickLoginCheckMilliSeconds,omitempty"` Realm string `json:"realm,omitempty"` RefreshTokenMaxReuse int `json:"refreshTokenMaxReuse,omitempty"` RegistrationAllowed *bool `json:"registrationAllowed,omitempty"` RegistrationEmailAsUsername *bool `json:"registrationEmailAsUsername,omitempty"` RegistrationFlow string `json:"registrationFlow,omitempty"` RememberMe *bool `json:"rememberMe,omitempty"` RequiredActions []RequiredActionProviderRepresentation `json:"requiredActions,omitempty"` ResetCredentialsFlow string `json:"resetCredentialsFlow,omitempty"` ResetPasswordAllowed *bool `json:"resetPasswordAllowed,omitempty"` RevokeRefreshToken *bool `json:"revokeRefreshToken,omitempty"` Roles RolesRepresentation `json:"roles,omitempty"` ScopeMappings []ScopeMappingRepresentation `json:"scopeMappings,omitempty"` SMTPServer AttributeMap `json:"smtpServer,omitempty"` SslRequired string `json:"sslRequired,omitempty"` SsoSessionIdleTimeout int `json:"ssoSessionIdleTimeout,omitempty"` SsoSessionMaxLifespan int `json:"ssoSessionMaxLifespan,omitempty"` SupportedLocales []string `json:"supportedLocales,omitempty"` UserFederationMappers []UserFederationMapperRepresentation `json:"userFederationMappers,omitempty"` UserFederationProviders []UserFederationProviderRepresentation `json:"userFederationProviders,omitempty"` UserManagedAccessAllowed *bool `json:"userManagedAccessAllowed,omitempty"` Users []UserRepresentation `json:"users,omitempty"` VerifyEmail *bool `json:"verifyEmail,omitempty"` WaitIncrementSeconds int `json:"waitIncrementSeconds,omitempty"` }
RealmRepresentation represents a realm
type RealmService ¶
type RealmService service
NewRealmService interacts with all realm resources
func (*RealmService) Create ¶
func (s *RealmService) Create(ctx context.Context, realm *RealmRepresentation) error
Create realm with realm, known in Keycloak as import
func (*RealmService) Delete ¶
func (s *RealmService) Delete(ctx context.Context, realm string) error
Delete realm with realm name (not id!)
func (*RealmService) Get ¶
func (s *RealmService) Get(ctx context.Context, realm string) (*RealmRepresentation, error)
Get realm with realm name (not id!)
func (*RealmService) List ¶
func (s *RealmService) List(ctx context.Context) ([]RealmRepresentation, error)
Get returns a user in a realm
type RequiredActionProviderRepresentation ¶
type RequiredActionProviderRepresentation struct { Alias string `json:"alias,omitempty"` Config AttributeMap `json:"config,omitempty"` DefaultAction *bool `json:"defaultAction,omitempty"` Enabled *bool `json:"enabled,omitempty"` Name string `json:"name,omitempty"` ProviderID string `json:"providerId,omitempty"` }
RequiredActionProviderRepresentation Required Action Provider
type ResourceRepresentation ¶
type ResourceRepresentation struct { ID string `json:"id,omitempty"` Attributes AttributeMap `json:"attributes,omitempty"` DisplayName string `json:"displayName,omitempty"` IconURI string `json:"iconURI,omitempty"` Name string `json:"name,omitempty"` OwnerManagedAccess *bool `json:"ownerManagedAccess,omitempty"` Scopes []ScopeRepresentation `json:"scopes,omitempty"` Type string `json:"type,omitempty"` URI string `json:"uri,omitempty"` }
ResourceRepresentation represents resources attached to a scope
type ResourceServerRepresentation ¶
type ResourceServerRepresentation struct { AllowRemoteResourceManagement *bool `json:"allowRemoteResourceManagement,omitempty"` ClientID string `json:"clientId,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Policies []PolicyRepresentation `json:"policies,omitempty"` PolicyEnforcementMode string `json:"policyEnforcementMode,omitempty"` Resources []ResourceRepresentation `json:"resources,omitempty"` Scopes []ScopeRepresentation `json:"scopes,omitempty"` }
ResourceServerRepresentation represents the authorization settings for a realm client
type RoleComposites ¶
type RoleComposites struct { Client AttributeMap `json:"client,omitempty"` Realm []string `json:"realm,omitempty"` }
RoleComposites known in keycloak as a "RoleRepresentations-Composites" in in the source it is just an inner-class.
type RoleRepresentation ¶
type RoleRepresentation struct { ClientRole *bool `json:"clientRole,omitempty"` Composite *bool `json:"composite,omitempty"` Composites RoleComposites `json:"composites,omitempty"` ContainerID string `json:"containerId,omitempty"` Description string `json:"description,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` }
RoleRepresentation Role
type RoleService ¶
type RoleService service
RoleService interacts with all role resources
func (*RoleService) AddComposite ¶
func (s *RoleService) AddComposite(ctx context.Context, role *RoleRepresentation, composites []RoleRepresentation) error
AddComposite adds composite roles to role
func (*RoleService) Create ¶
func (s *RoleService) Create(ctx context.Context, role *RoleRepresentation) (string, error)
Create creates a new role in realm
func (*RoleService) Delete ¶
func (s *RoleService) Delete(ctx context.Context, role *RoleRepresentation) error
Delete deletes the role in realm
func (*RoleService) Get ¶
func (s *RoleService) Get(ctx context.Context, name string) (*RoleRepresentation, error)
Get gets a role by name
func (*RoleService) GetComposites ¶
func (s *RoleService) GetComposites(ctx context.Context, role *RoleRepresentation) ([]RoleRepresentation, error)
GetComposites gets the composite roles from the given role
func (*RoleService) List ¶
func (s *RoleService) List(ctx context.Context) ([]RoleRepresentation, error)
List returns all roles
func (*RoleService) Realm ¶
func (s *RoleService) Realm() string
Realm returns the reaml the service is operating in
func (*RoleService) RemoveComposite ¶
func (s *RoleService) RemoveComposite(ctx context.Context, role *RoleRepresentation, composites []RoleRepresentation) error
RemoveComposite removes composite roles from role
type RolesRepresentation ¶
type RolesRepresentation struct { Client AttributeMap `json:"client,omitempty"` Realm []RoleRepresentation `json:"realm,omitempty"` }
RolesRepresentation Roles Representation
type ScopeMappingRepresentation ¶
type ScopeMappingRepresentation struct { Client string `json:"client,omitempty"` ClientScope string `json:"clientScope,omitempty"` Roles []string `json:"roles,omitempty"` Self string `json:"self,omitempty"` }
ScopeMappingRepresentation Scope Mapping
type ScopeRepresentation ¶
type ScopeRepresentation struct { DisplayName string `json:"displayName,omitempty"` IconURI string `json:"iconURI,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Policies []PolicyRepresentation `json:"policies,omitempty"` Resources []ResourceRepresentation `json:"resources,omitempty"` }
ScopeRepresentation represents scopes defined for a resource server, user, or resource
type UnixTime ¶
UnixTime is an alias for a date time from Keycloak which comes in as an int32
func (UnixTime) MarshalJSON ¶
MarshalJSON lets UnixTime implement the json.Marshaler interface
func (*UnixTime) UnmarshalJSON ¶
UnmarshalJSON lets UnixTime implement the json.Unmarshaler interface
type UserConsentRepresentation ¶
type UserConsentRepresentation struct { ClientID string `json:"clientId,omitempty"` CreatedDate *UnixTime `json:"createdDate,omitempty"` GrantedClientScopes []string `json:"grantedClientScopes,omitempty"` LastUpdatedDate *UnixTime `json:"lastUpdatedDate,omitempty"` }
UserConsentRepresentation represents client consents
type UserFederationMapperRepresentation ¶
type UserFederationMapperRepresentation struct { Config AttributeMap `json:"config,omitempty"` FederationMapperType string `json:"federationMapperType,omitempty"` FederationProviderDisplayName string `json:"federationProviderDisplayName,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` }
UserFederationMapperRepresentation User Federation
type UserFederationProviderRepresentation ¶
type UserFederationProviderRepresentation struct { ChangedSyncPeriod int32 `json:"changedSyncPeriod,omitempty"` Config AttributeMap `json:"config,omitempty"` DisplayName string `json:"displayName,omitempty"` FullSyncPeriod int32 `json:"fullSyncPeriod,omitempty"` ID string `json:"id,omitempty"` LastSync int `json:"lastSync,omitempty"` Priority int32 `json:"priority,omitempty"` ProviderName string `json:"providerName,omitempty"` }
UserFederationProviderRepresentation User federation provider
type UserRepresentation ¶
type UserRepresentation struct { Access AttributeMap `json:"access,omitempty"` Attributes AttributeMap `json:"attributes,omitempty"` ClientRoles AttributeMap `json:"clientRoles,omitempty"` ClientConsents []UserConsentRepresentation `json:"clientConsents,omitempty"` CreatedTimestamp *UnixTime `json:"createdTimestamp,omitempty"` Credentials []CredentialRepresentation `json:"credentials,omitempty"` DisableCredentialTypes []string `json:"disableCredentialTypes,omitempty"` Email string `json:"email,omitempty"` EmailVerified *bool `json:"emailVerified,omitempty"` Enabled *bool `json:"enabled,omitempty"` FederatedIdentities []FederatedIdentityRepresentation `json:"federatedIdentities,omitempty"` FederationLink *url.URL `json:"federationLink,omitempty"` FirstName string `json:"firstName,omitempty"` Groups []string `json:"groups,omitempty"` ID string `json:"id,omitempty"` LastName string `json:"lastName,omitempty"` NotBefore *UnixTime `json:"notBefore,omitempty"` Origin string `json:"origin,omitempty"` RealmRoles []string `json:"realmRoles,omitempty"` RequiredActions []string `json:"requiredActions,omitempty"` Self string `json:"self,omitempty"` ServiceAccountClientID string `json:"serviceAccountClientId,omitempty"` Username string `json:"username,omitempty"` }
UserRepresentation represents a realm user in Keycloak
type UserService ¶
type UserService service
UserService interacts with all user resources
func (*UserService) AddGroup ¶
func (s *UserService) AddGroup(ctx context.Context, user *UserRepresentation, groupID string) error
AddGroup adds a user to a group
func (*UserService) AddRole ¶
func (s *UserService) AddRole(ctx context.Context, user *UserRepresentation, role RoleRepresentation) error
AddRole adds a role to a user in a realm
func (*UserService) Create ¶
func (s *UserService) Create(ctx context.Context, user *UserRepresentation) (string, error)
Create creates a new user and returns the ID Response is a 201 with a location redirect
func (*UserService) Delete ¶
func (s *UserService) Delete(ctx context.Context, user *UserRepresentation) error
Delete user information Response is a 204: No Content
func (*UserService) DeleteRole ¶
func (s *UserService) DeleteRole(ctx context.Context, user *UserRepresentation, role RoleRepresentation) error
DeleteRole deletes a role from a user in a realm
func (*UserService) DisableCredentials ¶
func (s *UserService) DisableCredentials(ctx context.Context, user *UserRepresentation, credentialTypes []string) error
DisableCredentials disables credentials of certain types for a user
func (*UserService) Find ¶
func (s *UserService) Find(ctx context.Context, params map[string]string) ([]UserRepresentation, error)
Find returns users based on query params Params: - email - first - firstName - lastName - max - search - userName
func (*UserService) Get ¶
func (s *UserService) Get(ctx context.Context, userID string) (*UserRepresentation, error)
Get returns a user in a realm
func (*UserService) GetConsents ¶
func (s *UserService) GetConsents(ctx context.Context, user *UserRepresentation) (AttributeMap, error)
GetConsents gets consents granted by the user
func (*UserService) GetGroups ¶
func (s *UserService) GetGroups(ctx context.Context, user *UserRepresentation) ([]GroupRepresentation, error)
GetGroups gets the groups a realm user belongs to
func (*UserService) GetOfflineSessions ¶
func (s *UserService) GetOfflineSessions(ctx context.Context, user *UserRepresentation, clientID string) ([]UserSessionRepresentation, error)
GetOfflineSessions for particular client and user
func (*UserService) GetSessions ¶
func (s *UserService) GetSessions(ctx context.Context, user *UserRepresentation) ([]UserSessionRepresentation, error)
GetSessions for user
func (*UserService) Impersonate ¶
func (s *UserService) Impersonate(ctx context.Context, user *UserRepresentation) (AttributeMap, error)
Impersonate user
func (*UserService) List ¶
func (s *UserService) List(ctx context.Context, realm string) ([]UserRepresentation, error)
List returns a user in a realm
func (*UserService) ListClientRoles ¶ added in v0.8.0
func (s *UserService) ListClientRoles(ctx context.Context, user *UserRepresentation, client *ClientRepresentation) ([]RoleRepresentation, error)
ListClientRoles lists the client roles associated with the user
func (*UserService) ListRealmRoles ¶ added in v0.8.0
func (s *UserService) ListRealmRoles(ctx context.Context, user *UserRepresentation) ([]RoleRepresentation, error)
ListRealmRoles lists the realm roles associated with the user
func (*UserService) Logout ¶
func (s *UserService) Logout(ctx context.Context, user *UserRepresentation) error
Logout revokes all user sessions
func (*UserService) Realm ¶
func (s *UserService) Realm() string
Realm returns the reaml the service is operating in
func (*UserService) RemoveGroup ¶
func (s *UserService) RemoveGroup(ctx context.Context, user *UserRepresentation, groupID string) error
RemoveGroup removes a user from a group
func (*UserService) ResetPassword ¶
func (s *UserService) ResetPassword(ctx context.Context, user *UserRepresentation, tempPassword *CredentialRepresentation) error
ResetPassword for user
func (*UserService) RevokeClientConsents ¶
func (s *UserService) RevokeClientConsents(ctx context.Context, user *UserRepresentation, clientID string) error
RevokeClientConsents revokes consent and offline tokens for particular client from user
func (*UserService) Update ¶
func (s *UserService) Update(ctx context.Context, user *UserRepresentation) error
Update user information Response is a 204: No Content
type UserSessionRepresentation ¶
type UserSessionRepresentation struct { Clients AttributeMap `json:"clients,omitempty"` ID string `json:"id,omitempty"` IPAddress string `json:"ipAddress,omitempty"` LastAccess *UnixTime `json:"lastAccess,omitempty"` Start *UnixTime `json:"start,omitempty"` UserID string `json:"userId,omitempty"` UserName string `json:"userName,omitempty"` }
UserSessionRepresentation is a single session for a user