Documentation ¶
Overview ¶
Package keycloak contains a client and relevant data structs for interacting with the Keycloak Admin REST API
For mapping, see https://www.keycloak.org/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 CredentialRepresentation
- type Error
- type FederatedIdentityRepresentation
- type GroupRepresentation
- type IdentityProviderMapperRepresentation
- type IdentityProviderRepresentation
- type MultivaluedHashMap
- type PolicyRepresentation
- type ProtocolMapperRepresentation
- type RealmRepresentation
- type RealmService
- func (rs *RealmService) ClearCache(ctx context.Context, realm string) error
- func (rs *RealmService) ClearUserCache(ctx context.Context, realm string) error
- func (rs *RealmService) Create(ctx context.Context, realm *RealmRepresentation) error
- func (rs *RealmService) Delete(ctx context.Context, realm string) error
- func (rs *RealmService) Get(ctx context.Context, realm string) (*RealmRepresentation, error)
- type RequiredActionProviderRepresentation
- type ResourceRepresentation
- type ResourceServerRepresentation
- type RoleComposites
- type RoleRepresentation
- type RolesRepresentation
- type ScopeMappingRepresentation
- type ScopeRepresentation
- type UnixTime
- type UserConsentRepresentation
- type UserFederationMapperRepresentation
- type UserFederationProviderRepresentation
- type UserRepresentation
- type UserService
- func (us *UserService) AddGroup(ctx context.Context, realm string, userID string, groupID string) error
- func (us *UserService) Count(ctx context.Context, realm string) (uint32, error)
- func (us *UserService) Create(ctx context.Context, realm string, user *UserRepresentation) (string, error)
- func (us *UserService) Delete(ctx context.Context, realm string, userID string) error
- func (us *UserService) DisableCredentials(ctx context.Context, realm string, userID string, credentialTypes []string) error
- func (us *UserService) Find(ctx context.Context, realm string, params map[string]string) ([]UserRepresentation, error)
- func (us *UserService) Get(ctx context.Context, realm string, userID string) (*UserRepresentation, error)
- func (us *UserService) GetConsents(ctx context.Context, realm string, userID string) (AttributeMap, error)
- func (us *UserService) GetGroups(ctx context.Context, realm string, userID string) ([]GroupRepresentation, error)
- func (us *UserService) GetOfflineSessions(ctx context.Context, realm string, userID string, clientID string) ([]UserSessionRepresentation, error)
- func (us *UserService) GetSessions(ctx context.Context, realm string, userID string) ([]UserSessionRepresentation, error)
- func (us *UserService) Impersonate(ctx context.Context, realm string, userID string) (AttributeMap, error)
- func (us *UserService) Logout(ctx context.Context, realm string, userID string) error
- func (us *UserService) RemoveGroup(ctx context.Context, realm string, userID string, groupID string) error
- func (us *UserService) ResetPassword(ctx context.Context, realm string, userID string, ...) error
- func (us *UserService) RevokeClientConsents(ctx context.Context, realm string, userID string, clientID string) error
- func (us *UserService) Update(ctx context.Context, realm string, 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 ¶
type Client struct { BaseURL url.URL // Services for working with various keycloak resources Users *UserService Realm *RealmService // contains filtered or unexported fields }
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) userID, _ := c.Users.Create(context.Background(), "myRealm", &UserRepresentation{ Username: "hello-world", }) fmt.Println("UserID: ", userID)
Output:
type ClientRepresentation ¶
type ClientRepresentation struct { Access string `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 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 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 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
RealmService interacts with all realm resources
func NewRealmService ¶
func NewRealmService(c *Client) *RealmService
NewRealmService returns a new user service for working with user resources in a realm.
func (*RealmService) ClearCache ¶
func (rs *RealmService) ClearCache(ctx context.Context, realm string) error
Clear a realm's cache
func (*RealmService) ClearUserCache ¶
func (rs *RealmService) ClearUserCache(ctx context.Context, realm string) error
Clear a realm's user cache
func (*RealmService) Create ¶
func (rs *RealmService) Create(ctx context.Context, realm *RealmRepresentation) error
Create realm with realm, known in Keycloak as import
func (*RealmService) Delete ¶
func (rs *RealmService) Delete(ctx context.Context, realm string) error
Delete realm with realm name (not id!)
func (*RealmService) Get ¶
func (rs *RealmService) Get(ctx context.Context, realm string) (*RealmRepresentation, error)
Get realm with realm name (not id!)
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 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 string `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 NewUserService ¶
func NewUserService(c *Client) *UserService
NewUserService returns a new user service for working with user resources in a realm.
Example ¶
userService := NewUserService(&Client{}) _, _ = userService.Create(context.TODO(), "my-realm", &UserRepresentation{})
Output:
func (*UserService) AddGroup ¶
func (us *UserService) AddGroup(ctx context.Context, realm string, userID string, groupID string) error
AddGroup adds a user to a group
func (*UserService) Create ¶
func (us *UserService) Create(ctx context.Context, realm string, user *UserRepresentation) (string, error)
Create creates a new user and returns the ID Response is a 201 with a location redirect
func (*UserService) DisableCredentials ¶
func (us *UserService) DisableCredentials(ctx context.Context, realm string, userID string, credentialTypes []string) error
DisableCredentials disables credentials of certain types for a user
func (*UserService) Find ¶
func (us *UserService) Find(ctx context.Context, realm string, 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 (us *UserService) Get(ctx context.Context, realm string, userID string) (*UserRepresentation, error)
Get returns a user in a realm
func (*UserService) GetConsents ¶
func (us *UserService) GetConsents(ctx context.Context, realm string, userID string) (AttributeMap, error)
GetConsents gets consents granted by the user
func (*UserService) GetGroups ¶
func (us *UserService) GetGroups(ctx context.Context, realm string, userID string) ([]GroupRepresentation, error)
GetGroups gets the groups a realm user belongs to
func (*UserService) GetOfflineSessions ¶
func (us *UserService) GetOfflineSessions(ctx context.Context, realm string, userID string, clientID string) ([]UserSessionRepresentation, error)
GetOfflineSessions for particular client and user
func (*UserService) GetSessions ¶
func (us *UserService) GetSessions(ctx context.Context, realm string, userID string) ([]UserSessionRepresentation, error)
GetSessions for user
func (*UserService) Impersonate ¶
func (us *UserService) Impersonate(ctx context.Context, realm string, userID string) (AttributeMap, error)
Impersonate user
func (*UserService) RemoveGroup ¶
func (us *UserService) RemoveGroup(ctx context.Context, realm string, userID string, groupID string) error
RemoveGroup removes a user from a group
func (*UserService) ResetPassword ¶
func (us *UserService) ResetPassword(ctx context.Context, realm string, userID string, tempPassword *CredentialRepresentation) error
ResetPassword for user
func (*UserService) RevokeClientConsents ¶
func (us *UserService) RevokeClientConsents(ctx context.Context, realm string, userID string, clientID string) error
RevokeClientConsents revokes consent and offline tokens for particular client from user
func (*UserService) Update ¶
func (us *UserService) Update(ctx context.Context, realm string, 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
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package auth is copied almost verbatim from golang.org/x/oauth2/clientcredentials This is because the package above doesn't allow overwriting the grant_type key TODO: Clean up and implement/reuse a true keycloak auth
|
Package auth is copied almost verbatim from golang.org/x/oauth2/clientcredentials This is because the package above doesn't allow overwriting the grant_type key TODO: Clean up and implement/reuse a true keycloak auth |