authenticator

package
v0.0.0-...-47cfc89 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth0AccessTokenResponse

type Auth0AccessTokenResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
}

Auth0AccessTokenResponse represents the response from Auth0 access token authorization

type Auth0Role

type Auth0Role struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Auth0Role represents the Auth0Role type

type Auth0RoleRequest

type Auth0RoleRequest struct {
	Name string `json:"name"`
}

Auth0RoleRequest represents the Auth0Role request

type Auth0UserRoleRequest

type Auth0UserRoleRequest struct {
	Roles []string `json:"roles"`
}

Auth0UserRoleRequest represents the Auth0UserRole request

type Authenticator

type Authenticator struct {
	*oidc.Provider
	oauth2.Config
	// contains filtered or unexported fields
}

Authenticator is used to authenticate our users.

func New

func New(di *DI) (*Authenticator, error)

New instantiates the *Authenticator.

func (*Authenticator) AssignRoleToUser

func (a *Authenticator) AssignRoleToUser(ctx context.Context, accessToken, userID, roleName string) error

AssignRoleToUser assigns the given user to the given role

func (*Authenticator) CreateRole

func (a *Authenticator) CreateRole(ctx context.Context, accessToken, roleName string) (string, error)

CreateRole creates a new role to the list

func (*Authenticator) GetAuth0AccessToken

func (a *Authenticator) GetAuth0AccessToken(ctx context.Context) (string, error)

GetAuth0AccessToken fetches auth0 access token from the server

func (*Authenticator) GetAuth0Roles

func (a *Authenticator) GetAuth0Roles(ctx context.Context, accessToken string) ([]Auth0Role, error)

GetAuth0Roles fetches all the auth0 roles

func (*Authenticator) GetUserRoles

func (a *Authenticator) GetUserRoles(ctx context.Context, accessToken, userID string) ([]string, error)

GetUserRoles fetches user roles from oauth0

func (*Authenticator) Init

func (a *Authenticator) Init(ctx context.Context) error

Init checks the roles available in the auth0 namespace

func (*Authenticator) VerifyIDToken

func (a *Authenticator) VerifyIDToken(ctx context.Context, token *oauth2.Token) (*oidc.IDToken, error)

VerifyIDToken verifies that an *oauth2.Token is a valid *oidc.IDToken.

type DI

type DI struct {
	Auth0ClientID     string
	Auth0ClientSecret string
	Auth0CallbackURL  string
	Auth0Domain       string
	Auth0SharedSecret string

	Logger *logger.Logger
}

DI is the dependency injection entity for Authenticator

Jump to

Keyboard shortcuts

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