account

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EMAIL key
	EMAIL = "name"
	// ID key
	ID = "id"
)

Variables

This section is empty.

Functions

func AddAuthAPIsToHandler

func AddAuthAPIsToHandler(handler core.Handler, db core.DB)

AddAuthAPIsToHandler constructs an API for recipes

func DeleteTokenCookie

func DeleteTokenCookie(c *core.APICallContext)

DeleteTokenCookie by setting the cookie maxAge to -1

func ValidateToken

func ValidateToken(provider *oidc.Provider, config *oauth2.Config, token *Token) (*oidc.IDToken, error)

ValidateToken ensures the validity of the token

func WriteTokenToCookie

func WriteTokenToCookie(c *core.APICallContext, config *oauth2.Config, provider *oidc.Provider, token *Token)

WriteTokenToCookie stores the token in a cookie

Types

type AccID

type AccID uuid.UUID

AccID identifies the account uniquely

type Account

type Account struct {
	Name string `json:"name"`
	ID   AccID  `json:"id"`
	Type Type   `json:"type"`
}

Account document that can be stored in the database

func NewAccount

func NewAccount(name string, accountType Type) *Account

NewAccount is created with a specific name (eMail ID) and type (e.g., KEYCLOAK)

type AuthKeyCloakAPI

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

AuthKeyCloakAPI for authorization

type IDTokenClaim

type IDTokenClaim struct {
	Email string `json:"email"`
}

IDTokenClaim represents the relevant claims

func GetClaims

func GetClaims(provider *oidc.Provider, config *oauth2.Config, token *Token) (*IDTokenClaim, error)

type MongoAccountService

type MongoAccountService struct {
	DbClient *core.MongoClient
}

MongoAccountService stores and manipulates stored accounts in a DB

func NewMongoAccountService

func NewMongoAccountService(db core.DB) *MongoAccountService

NewMongoAccountService is created and configured

func (*MongoAccountService) DeleteAccountByID

func (db *MongoAccountService) DeleteAccountByID(id AccID) error

DeleteAccountByID deletes an account indefinitely

func (*MongoAccountService) DeleteAccountByName

func (db *MongoAccountService) DeleteAccountByName(name string) error

DeleteAccountByName deletes an account indefinitely

func (*MongoAccountService) FindAccount

func (db *MongoAccountService) FindAccount(name string) (*Account, error)

FindAccount by Name

func (*MongoAccountService) NewAccount

func (db *MongoAccountService) NewAccount(name string, t Type) (*Account, error)

NewAccount stores the account information in a db

type State

type State struct {
	URL         string
	Signup      bool
	StateString string
}

State stored when getting Token

type StateMap

type StateMap map[string]*State

StateMap type to cache all states

var States StateMap

States cached for reuse

func (StateMap) CreateState

func (sm StateMap) CreateState(url string, signup bool) *State

CreateState to reuse later

func (StateMap) FindAndDelete

func (sm StateMap) FindAndDelete(key string) *State

FindAndDelete returns the state for a given key and deletes the entry of the StateMap

func (StateMap) Get

func (sm StateMap) Get(key string) (*State, bool)

Get the state by key

type Token

type Token struct {
	Token string `json:"token"`
}

Token document

func GetTokenFromCookie

func GetTokenFromCookie(c *core.APICallContext, provider *oidc.Provider, config *oauth2.Config) (*Token, error)

GetTokenFromCookie returns the token or an error

func NewToken

func NewToken(token string) *Token

NewToken document is created

type Type

type Type int64
const (
	// KEYCLOAK type
	KEYCLOAK Type = 0
)

Jump to

Keyboard shortcuts

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