manage

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInviteOnly = errors.New(
		"behaivoural setting is set to only accept invited members",
	)
	ErrTokenGenTimeout         = errors.New("could not generate a token within given cycles")
	ErrEntityAlreadyExists     = errors.New("entity already exists in system")
	ErrTokenExpired            = errors.New("supplied token has expired")
	ErrEntityInvalidTransition = errors.New("entity does not support transition")
	ErrPasswordGuidelines      = errors.New("password doesnt match password guidlines")
	ErrNotFound                = errors.New("entity not found")
)
View Source
var ErrAppIsRetired = errors.New("application is retired")
View Source
var ErrApplicationClientIDExists = errors.New("application with client_id already exists")
View Source
var ErrInvalidSecret = errors.New("invalid secret")
View Source
var ErrUserNotInRole = errors.New("user is not in role")

Functions

This section is empty.

Types

type ApplicationDTO

type ApplicationDTO struct {
	ID              int      `json:"id"`
	ClientID        string   `json:"client_id"`
	Type            string   `json:"type"`
	Name            string   `json:"name"`
	Status          string   `json:"status"`
	Confidentiality string   `json:"confidentiality"`
	HasSecret       bool     `json:"has_secret"`
	PKCE            bool     `json:"pkce"`
	Flows           []string `json:"flows"`
	Scope           string   `json:"scope"`
	RedirectURIs    []string `json:"redirect_uris"`
	LogoutURIs      []string `json:"logout_uris"`
}

func (*ApplicationDTO) Render

type ApplicationService

type ApplicationService struct {
	// contains filtered or unexported fields
}

func NewApplicationSevice

func NewApplicationSevice(store *db.DataStore,
	log *zap.Logger,
	cfg *config.Configuration,
	dispatcher *events.Dispatcher) *ApplicationService

func (*ApplicationService) AddFlow

func (a *ApplicationService) AddFlow(
	ctx context.Context,
	clientID string,
	flow application.FlowType,
) error

func (*ApplicationService) AddLogoutURI

func (a *ApplicationService) AddLogoutURI(
	ctx context.Context,
	clientID string,
	logoutURI string,
) error

func (*ApplicationService) AddRedirectURI

func (a *ApplicationService) AddRedirectURI(
	ctx context.Context,
	clientID string,
	redirectURI string,
) error

func (*ApplicationService) ByClientID

func (a *ApplicationService) ByClientID(
	ctx context.Context,
	clientID string,
) (*ApplicationDTO, error)

func (*ApplicationService) CreateApplication

func (a *ApplicationService) CreateApplication(
	ctx context.Context,
	clientID string,
	clientSecret string,
	name string,
	flows []string,
	redirectUris []string,
	logoutURIs []string,
	confidentiality string,
	scope string,
	appType int,
	pkce bool) (int, error)

func (*ApplicationService) List

func (a *ApplicationService) List(
	ctx context.Context,
	page int,
	pageSize int,
	q string,
	sort string,
) (*PaginationResponse, error)

func (*ApplicationService) PurgeRetiredApplications

func (a *ApplicationService) PurgeRetiredApplications(ctx context.Context) error

func (*ApplicationService) RemoveFlow

func (a *ApplicationService) RemoveFlow(
	ctx context.Context,
	clientID string,
	flow application.FlowType,
) error

func (*ApplicationService) RemoveLogoutURI

func (a *ApplicationService) RemoveLogoutURI(
	ctx context.Context,
	clientID string,
	logoutURI string,
) error

func (*ApplicationService) RemoveRedirectURI

func (a *ApplicationService) RemoveRedirectURI(
	ctx context.Context,
	clientID string,
	redirectURI string,
) error

func (*ApplicationService) RetireApplication

func (a *ApplicationService) RetireApplication(ctx context.Context, clientID string) error

func (*ApplicationService) SetSecret

func (a *ApplicationService) SetSecret(ctx context.Context, clientID string, secret string) error

func (*ApplicationService) TogglePKCE

func (a *ApplicationService) TogglePKCE(ctx context.Context, clientID string, enable bool) error

func (*ApplicationService) WithActiveUserAuthorizations

func (a *ApplicationService) WithActiveUserAuthorizations(
	ctx context.Context,
	userID uuid.UUID,
) ([]*ApplicationDTO, error)

type AuthorizationApplicationDTO

type AuthorizationApplicationDTO struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	ClientID string `json:"client_id"`
}

type AuthorizationDTO

type AuthorizationDTO struct {
	ID          uuid.UUID                   `json:"id"`
	User        AuthorizationUserDTO        `json:"user"`
	Application AuthorizationApplicationDTO `json:"application"`
	Properties  map[string]interface{}      `json:"properties"`
	RevokedAt   *time.Time                  `json:"revoked_at"`
	CreatedAt   time.Time                   `json:"created_at"`
	UpdatedAt   *time.Time                  `json:"updated_at"`
}

type AuthorizationService

type AuthorizationService struct {
	// contains filtered or unexported fields
}

func NewAuthorizationService

func NewAuthorizationService(store *db.DataStore,
	log *zap.Logger,
	cfg *config.Configuration,
	dispatcher *events.Dispatcher) *AuthorizationService

func (*AuthorizationService) ActiveByUser

func (a *AuthorizationService) ActiveByUser(
	ctx context.Context,
	userID uuid.UUID,
) ([]*AuthorizationDTO, error)

func (*AuthorizationService) GrantAuthorization

func (a *AuthorizationService) GrantAuthorization(
	ctx context.Context,
	userID uuid.UUID,
	clientID string,
	scope string,
) error

func (*AuthorizationService) List

func (a *AuthorizationService) List(
	ctx context.Context,
	page int,
	pageSize int,
	q string,
	sort string,
) (*PaginationResponse, error)

func (*AuthorizationService) RevokeAuthorizationByClientIDAndUserID

func (a *AuthorizationService) RevokeAuthorizationByClientIDAndUserID(
	ctx context.Context,
	clientID string,
	userID uuid.UUID,
) error

func (*AuthorizationService) RevokeAuthorizationClientIDAndEmail

func (a *AuthorizationService) RevokeAuthorizationClientIDAndEmail(
	ctx context.Context,
	clientID string,
	email string,
) error

type AuthorizationUserDTO

type AuthorizationUserDTO struct {
	ID uuid.UUID `json:"id"`
}

type InviteApplicationDTO

type InviteApplicationDTO struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	ClientID string `json:"client_id"`
	Scope    string `json:"scope"`
}

type InviteDTO

type InviteDTO struct {
	ID           int                    `json:"id"`
	Email        *string                `json:"email"`
	Code         string                 `json:"code"`
	SentAt       *time.Time             `json:"sent_at"`
	ConsumedAt   *time.Time             `json:"consumed_at"`
	ExpiresAt    time.Time              `json:"expires_at"`
	CreatedAt    time.Time              `json:"created_at"`
	Roles        []string               `json:"roles"`
	Applications []InviteApplicationDTO `json:"applications"`
}

type InviteService

type InviteService struct {
	// contains filtered or unexported fields
}

InviteService is used to managed invitations

func NewInviteService

func NewInviteService(store *db.DataStore,
	log *zap.Logger,
	dispatcher *events.Dispatcher) *InviteService

NewInviteService returns a new invite service

func (*InviteService) List

func (i *InviteService) List(
	ctx context.Context,
	page int,
	pageSize int,
	q string,
	sort string,
) (*PaginationResponse, error)

List lists all invitations in a paginated response

type PaginationResponse

type PaginationResponse struct {
	Total   int         `json:"total"`
	Entries interface{} `json:"entries"`
}

func (*PaginationResponse) Render

func (*PaginationResponse) Render()

type RoleDTO

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

type RoleService

type RoleService struct {
	// contains filtered or unexported fields
}

func NewRoleService

func NewRoleService(store *db.DataStore,
	log *zap.Logger,
	dispatcher *events.Dispatcher) *RoleService

func (*RoleService) CreateRole

func (r *RoleService) CreateRole(ctx context.Context, name string) (int, error)

func (*RoleService) DeleteRole

func (r *RoleService) DeleteRole(ctx context.Context, name string) error

func (*RoleService) List

func (r *RoleService) List(
	ctx context.Context,
	page int,
	pageSize int,
	q string,
	sort string,
) (*PaginationResponse, error)

type UserDTO

type UserDTO struct {
	ID                   uuid.UUID  `json:"id,omitempty"`
	Email                string     `json:"email"`
	EmailConfirmed       *time.Time `json:"email_confirmed"`
	Phone                *string    `json:"phone"`
	PhoneConfirmed       *time.Time `json:"phone_confirmed"`
	Mfa                  bool       `json:"mfa"`
	LockoutTill          *time.Time `json:"lockout_till"`
	BannedOn             *time.Time `json:"banned_on"`
	CurrentFailureCount  int        `json:"current_failure_count"`
	RecoveryTokenCreated *time.Time `json:"recovery_token_created,omitempty"`
	ConfirmToken         *string    `json:"confirm_token"`
	ConfirmTokenCreated  *time.Time `json:"confirm_token_created,omitempty"`
	CreatedAt            time.Time  `json:"created_at"`
	UpdatedAt            *time.Time `json:"updated_at,omitempty"`
	Roles                []string   `json:"roles"`
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(store *db.DataStore,
	log *zap.Logger,
	cfg *config.Configuration,
	mailer *mailing.Mailer,
	dispatcher *events.Dispatcher) *UserService

func (*UserService) AddUserToRole

func (g *UserService) AddUserToRole(ctx context.Context, id uuid.UUID, role string) error

func (*UserService) BanUser

func (g *UserService) BanUser(ctx context.Context, id uuid.UUID) error

func (*UserService) ByID

func (g *UserService) ByID(ctx context.Context, userID uuid.UUID) (*UserDTO, error)

func (*UserService) ConfirmUser

func (g *UserService) ConfirmUser(ctx context.Context, id uuid.UUID) error

func (*UserService) EmailToID

func (g *UserService) EmailToID(ctx context.Context, email string) (uuid.UUID, error)

func (*UserService) InitialUserInvite

func (g *UserService) InitialUserInvite(
	ctx context.Context,
	inviteCode string,
	roles []string,
	appIds []int,
) error

InitialUserInvite used for docker container setup, it seeds a predefined a user invite for the admin user so the admin user can signup with his wanted credentials

func (*UserService) InsertUser

func (g *UserService) InsertUser(ctx context.Context,
	email string,
	password string,
	phone *string,
	confirmToken *string) (uuid.UUID, error)

func (*UserService) InviteUser

func (g *UserService) InviteUser(
	ctx context.Context,
	email *string,
	roles []string,
	appIds []int,
) (generator.RandomTokenType, error)

func (*UserService) List

func (g *UserService) List(
	ctx context.Context,
	page int,
	pageSize int,
	q string,
	sort string,
) (*PaginationResponse, error)

func (*UserService) LockUser

func (g *UserService) LockUser(ctx context.Context, id uuid.UUID, until time.Time) error

func (*UserService) RemoveUserFromRole

func (g *UserService) RemoveUserFromRole(ctx context.Context, id uuid.UUID, role string) error

func (*UserService) UnbanUser

func (g *UserService) UnbanUser(ctx context.Context, id uuid.UUID) error

func (*UserService) UnlockUser

func (g *UserService) UnlockUser(ctx context.Context, id uuid.UUID) error

func (*UserService) VerifyUserInRole

func (g *UserService) VerifyUserInRole(ctx context.Context, userID uuid.UUID, role string) error

Jump to

Keyboard shortcuts

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