Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultKeycloakURL = "http://platform-keycloak.orch-platform:8080" DefaultKeycloakRealm = "master" DefaultOnboardingCredentialsSecretKey = "client_secret" DefaultENCredentialsPrefix = "edgenode-" EnvNameKeycloakURL = "KEYCLOAK_URL" EnvNameKeycloakRealm = "KEYCLOAK_REALM" EnvNameOnboardingManagerClientName = "ONBOARDING_MANAGER_CLIENT_NAME" EnvNameOnboardingCredentialsSecretName = "ONBOARDING_CREDENTIALS_SECRET_NAME" EnvNameOnboardingCredentialsSecretKey = "ONBOARDING_CREDENTIALS_SECRET_KEY" EnvNameENCredentialsPrefix = "EN_CREDENTIALS_PREFIX" EnvNameEnableGroupCache = "ENABLE_GROUP_CACHE" )
Variables ¶
View Source
var ( AuthServiceFactory = newKeycloakSecretService LoginMethod = loginKeycloakClient )
Functions ¶
func AuthServiceMockFactory ¶
Types ¶
type AuthService ¶
type AuthService interface { // CreateCredentialsWithUUID creates EN credentials based on UUID. // The credentials can be further used by edge node agents. CreateCredentialsWithUUID(ctx context.Context, tenantID, uuid string) (string, string, error) // GetCredentialsByUUID obtains EN credentials based on UUID. GetCredentialsByUUID(ctx context.Context, tenantID, uuid string) (string, string, error) // RevokeCredentialsByUUID revokes EN credentials based on UUID. RevokeCredentialsByUUID(ctx context.Context, tenantID, uuid string) error // Logout closes the session with authorization service. // Should always be invoked after all operations in a session are done. Logout(ctx context.Context) }
AuthService implements the authorization service to create or revoke EN credentials. Remember to call auth.Init() at the very beginning.
type KeycloakAPI ¶
type KeycloakAPI interface { CreateClient(ctx context.Context, accessToken, realm string, newClient gocloak.Client) (string, error) GetClientSecret(ctx context.Context, token, realm, idOfClient string) (*gocloak.CredentialRepresentation, error) GetClients(ctx context.Context, token, realm string, params gocloak.GetClientsParams) ([]*gocloak.Client, error) GetUsers(ctx context.Context, token, realm string, params gocloak.GetUsersParams) ([]*gocloak.User, error) GetRoleMappingByUserID(ctx context.Context, token, realm, userID string) (*gocloak.MappingsRepresentation, error) AddUserToGroup(ctx context.Context, token, realm, userID, groupID string) error DeleteClient(ctx context.Context, token, realm, idOfClient string) error Logout(ctx context.Context, clientID, clientSecret, realm, refreshToken string) error GetGroups(ctx context.Context, token, realm string, params gocloak.GetGroupsParams) ([]*gocloak.Group, error) }
KeycloakAPI wraps Keycloak under interface to enable mocking for unit testing.
Click to show internal directories.
Click to hide internal directories.