Documentation ¶
Index ¶
- Variables
- type Authenticator
- func (authn *Authenticator) IsAuthenticated() (bool, error)
- func (authn *Authenticator) OAuthHandler(w http.ResponseWriter, r *http.Request)
- func (authn *Authenticator) RetrieveToken(authCode string) error
- func (authn *Authenticator) StartOAuthFlow(ports []int, ...) (string, error)
- func (authn *Authenticator) WaitForOAuthFlowCompletion(timeout time.Duration) (bool, error)
- type Role
- type RoleMask
Constants ¶
This section is empty.
Variables ¶
var RoleAny = NewRoleMask(Admin, Manager, Guest)
Role Mask constants
var RoleSpaceAdmin = NewRoleMask(Admin, Manager)
var RoleSpaceSuperUser = NewRoleMask(Admin)
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator( context config.AuthContext, config *oauth2.Config, authCallbackHandler func(w http.ResponseWriter, r *http.Request), ) *Authenticator
func (*Authenticator) IsAuthenticated ¶
func (authn *Authenticator) IsAuthenticated() (bool, error)
Checks if the current auth context has been authenticated. This will refresh the oauth token if the access token has expired and the refresh token has not expired
func (*Authenticator) OAuthHandler ¶
func (authn *Authenticator) OAuthHandler(w http.ResponseWriter, r *http.Request)
Handles the OAuth callback which exchanges the auth code in the request for a token and saves the token.
func (*Authenticator) RetrieveToken ¶
func (authn *Authenticator) RetrieveToken(authCode string) error
Exchange given auth code for a token
func (*Authenticator) StartOAuthFlow ¶
func (authn *Authenticator) StartOAuthFlow( ports []int, reqHandlers ...func() (string, func(http.ResponseWriter, *http.Request)), ) (string, error)
Starts an http listener locally to listen for the oauth redirect with authcode once the user has been authenticated by the auth service.
func (*Authenticator) WaitForOAuthFlowCompletion ¶
func (authn *Authenticator) WaitForOAuthFlowCompletion(timeout time.Duration) (bool, error)
Wait until OAuth flow has completed. Returns false if oath flow completes with callback to local server
type Role ¶
type Role uint
User Role
func RoleFromContext ¶
func RoleFromContext( deviceContext config.DeviceContext, spaceNode userspace.SpaceNode, ) Role
func RoleFromString ¶
type RoleMask ¶
type RoleMask uint
Space user role mask
func NewRoleMask ¶
func (RoleMask) HasOnlyRole ¶
func (RoleMask) LoggedInUserHasRole ¶
func (m RoleMask) LoggedInUserHasRole( deviceContext config.DeviceContext, spaceNode userspace.SpaceNode, ) bool
check if user logged into device is authorized using the give mask