domain

package
v0.0.0-...-6fd37f8 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ACCESS_TOKEN_DURATION = time.Hour
View Source
const HMAC_SAMPLE_SECRET = "hmacSampleSecret"
View Source
const REFRESH_TOKEN_DURATION = time.Hour * 24 * 30

Variables

This section is empty.

Functions

func NewAccessTokenFromRefreshToken

func NewAccessTokenFromRefreshToken(refreshToken string) (string, *errs.AppError)

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	CustomerId string   `json:"customer_id"`
	Accounts   []string `json:"accounts"`
	Username   string   `json:"username"`
	Role       string   `json:"role"`
	jwt.StandardClaims
}

func (AccessTokenClaims) IsRequestVerifiedWithTokenClaims

func (c AccessTokenClaims) IsRequestVerifiedWithTokenClaims(urlParams map[string]string) bool

func (AccessTokenClaims) IsUserRole

func (c AccessTokenClaims) IsUserRole() bool

func (AccessTokenClaims) IsValidAccountId

func (c AccessTokenClaims) IsValidAccountId(accountId string) bool

func (AccessTokenClaims) IsValidCustomerId

func (c AccessTokenClaims) IsValidCustomerId(customerId string) bool

func (AccessTokenClaims) RefreshTokenClaims

func (c AccessTokenClaims) RefreshTokenClaims() RefreshTokenClaims

type AuthRepository

type AuthRepository interface {
	FindBy(username string, password string) (*Login, *errs.AppError)
	GenerateAndSaveRefreshTokenToStore(authToken AuthToken) (string, *errs.AppError)
	RefreshTokenExists(refreshToken string) *errs.AppError
}

type AuthRepositoryDb

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

func NewAuthRepository

func NewAuthRepository(client *sqlx.DB) AuthRepositoryDb

func (AuthRepositoryDb) FindBy

func (d AuthRepositoryDb) FindBy(username, password string) (*Login, *errs.AppError)

func (AuthRepositoryDb) GenerateAndSaveRefreshTokenToStore

func (d AuthRepositoryDb) GenerateAndSaveRefreshTokenToStore(authToken AuthToken) (string, *errs.AppError)

func (AuthRepositoryDb) RefreshTokenExists

func (d AuthRepositoryDb) RefreshTokenExists(refreshToken string) *errs.AppError

type AuthToken

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

func NewAuthToken

func NewAuthToken(claims AccessTokenClaims) AuthToken

func (AuthToken) NewAccessToken

func (t AuthToken) NewAccessToken() (string, *errs.AppError)

type Login

type Login struct {
	Username   string         `db:"username"`
	CustomerId sql.NullString `db:"customer_id"`
	Accounts   sql.NullString `db:"account_numbers"`
	Role       string         `db:"role"`
}

func (Login) ClaimsForAccessToken

func (l Login) ClaimsForAccessToken() AccessTokenClaims

type RefreshTokenClaims

type RefreshTokenClaims struct {
	TokenType  string   `json:"token_type"`
	CustomerId string   `json:"cid"`
	Accounts   []string `json:"accounts"`
	Username   string   `json:"un"`
	Role       string   `json:"role"`
	jwt.StandardClaims
}

func (RefreshTokenClaims) AccessTokenClaims

func (c RefreshTokenClaims) AccessTokenClaims() AccessTokenClaims

type RolePermissions

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

func GetRolePermissions

func GetRolePermissions() RolePermissions

func (RolePermissions) IsAuthorizedFor

func (p RolePermissions) IsAuthorizedFor(role string, routeName string) bool

Jump to

Keyboard shortcuts

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