security

package
v0.0.0-...-cf82cec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2020 License: EPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CodewindCliID string = "codewind-cli"

CodewindCliID : master realm name

View Source
const CodewindClientID string = "codewind-backend"

CodewindClientID : master realm name

View Source
const KeycloakAdminClientID string = "admin-cli"

KeycloakAdminClientID : master realm name

View Source
const KeycloakMasterRealm string = "master"

KeycloakMasterRealm : master realm name

View Source
const KeyringServiceName string = "org.eclipse.codewind"

KeyringServiceName : name

Variables

This section is empty.

Functions

func AddCodewindRealmToKeycloak

func AddCodewindRealmToKeycloak(authURL string, realmName string, keycloakAdminUser string, keycloakAdminPass string) error

AddCodewindRealmToKeycloak : Installs a keycloak realm

func AddCodewindToKeycloak

func AddCodewindToKeycloak(workspaceID string, authURL string, realmName string, keycloakAdminUser string, keycloakAdminPass string, gatekeeperPublicURL string, devUsername string, clientName string) (string, error)

AddCodewindToKeycloak : sets up Keycloak with a realm, client and user Returns a clientKey or an error

func GetServerInfo

func GetServerInfo(keycloakHostname string, accesstoken string) (*ServerInfo, *SecError)

GetServerInfo - fetch Keycloak server info

func SecAuthenticate

func SecAuthenticate(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration) (*AuthToken, *SecError)

SecAuthenticate - sends credentials to the auth server for a specific realm and returns an AuthToken connectionRealm can be used to override the supplied context arguments

func SecClientGet

func SecClientGet(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string) (*RegisteredClient, *SecError)

SecClientGet : Retrieve Client information

func SecClientGetSecret

func SecClientGetSecret(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string) (*RegisteredClientSecret, *SecError)

SecClientGetSecret : Retrieve the client secret for the supplied clientID

func SecRealmGet

func SecRealmGet(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string) (*KeycloakRealm, *SecError)

SecRealmGet : Reads a realm in Keycloak

func SecUserGet

func SecUserGet(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string) (*RegisteredUser, *SecError)

SecUserGet : Get user from Keycloak

Types

type AuthToken

type AuthToken struct {
	AccessToken     string `json:"access_token"`
	ExpiresIn       int    `json:"expires_in"`
	RefreshToken    string `json:"refresh_token"`
	TokenType       string `json:"token_type"`
	NotBeforePolicy int    `json:"not-before-policy"`
	SessionState    string `json:"session_state"`
	Scope           string `json:"scope"`
}

AuthToken from the keycloak server after successfully authenticating

type KeycloakAPIError

type KeycloakAPIError struct {
	HTTPStatus       int
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
	ErrorMessage     string `json:"errorMessage"`
}

KeycloakAPIError : Error responses from Keycloak

type KeycloakConfiguration

type KeycloakConfiguration struct {
	RealmName             string
	AuthURL               string
	WorkspaceID           string
	KeycloakAdminPassword string
	KeycloakAdminUsername string
	DevUsername           string
	GatekeeperPublicURL   string
	ClientName            string
}

KeycloakConfiguration : Keycloak configuration for an instance of codewind

type KeycloakRealm

type KeycloakRealm struct {
	ID          string `json:"id"`
	Realm       string `json:"realm"`
	DisplayName string `json:"displayName"`
	Enabled     bool   `json:"enabled"`
	LoginTheme  string `json:"loginTheme"`
}

KeycloakRealm : A Keycloak Realm

type RegisteredClient

type RegisteredClient struct {
	ID           string   `json:"id"`
	ClientID     string   `json:"clientId"`
	Name         string   `json:"name"`
	RedirectUris []string `json:"redirectUris"`
	WebOrigins   []string `json:"webOrigins"`
}

RegisteredClient : Registered client

type RegisteredClientSecret

type RegisteredClientSecret struct {
	Type   string `json:"type"`
	Secret string `json:"value"`
}

RegisteredClientSecret : Client secret

type RegisteredClients

type RegisteredClients struct {
	Collection []RegisteredClient
}

RegisteredClients : A collection of registered clients

type RegisteredTheme

type RegisteredTheme struct {
	Name    string   `json:"name"`
	Locales []string `json:"locales"`
}

RegisteredTheme : A Keycloak theme

type RegisteredThemes

type RegisteredThemes struct {
	Common  []RegisteredTheme `json:"common"`
	Admin   []RegisteredTheme `json:"admin"`
	Login   []RegisteredTheme `json:"login"`
	Welcome []RegisteredTheme `json:"welcome"`
	Account []RegisteredTheme `json:"account"`
	Email   []RegisteredTheme `json:"email"`
}

RegisteredThemes : A collection of themes

type RegisteredUser

type RegisteredUser struct {
	ID       string `json:"id"`
	Username string `json:"username"`
}

RegisteredUser : details of a registered user

type RegisteredUsers

type RegisteredUsers struct {
	Collection []RegisteredUser
}

RegisteredUsers : A collection of registered users

type Result

type Result struct {
	Status string `json:"status"`
}

Result : status messaqe

type Role

type Role struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Composite   bool   `json:"composite"`
	ClientRole  bool   `json:"clientRole"`
	ContainerID string `json:"containerId"`
}

Role : Access role

type SecError

type SecError struct {
	Op   string
	Err  error
	Desc string
}

SecError : Security package errors

func GetSuggestedThemes

func GetSuggestedThemes(keycloakHostname string, accesstoken string) (string, string, *SecError)

GetSuggestedThemes - Recommends the Codewind theme, else Che, else keycloak default Returns the loginTheme, accountTheme, optionalError

func SecClientAppendURL

func SecClientAppendURL(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string) *SecError

SecClientAppendURL : Append an additional url to the whitelist

func SecClientCreate

func SecClientCreate(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string, redirectURL string) *SecError

SecClientCreate : Create a new client in Keycloak

func SecRealmCreate

func SecRealmCreate(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string) *SecError

SecRealmCreate : Create a new realm in Keycloak

func SecRoleCreate

func SecRoleCreate(httpClient utils.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string, roleName string) (*SecError, int)

SecRoleCreate : Create a new role in Keycloak Can return an error and an HTTP code

func SecUserAddRole

func SecUserAddRole(httpClient util.HTTPClient, keycloakConfig *KeycloakConfiguration, accessToken string, roleName string) *SecError

SecUserAddRole : Adds a role to a specified user

func (*SecError) Error

func (se *SecError) Error() string

SecError : Error formatted in JSON containing an errorOp and a description from either a fault condition in the CLI, or an error payload from a REST request

type ServerInfo

type ServerInfo struct {
	Themes RegisteredThemes `json:"themes"`
}

ServerInfo : A collection of themes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL