helpers

package
v0.0.0-...-9c9e09e Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdminRoleString = "admin"
	UserRoleString  = "user"
)
View Source
const AuthClaimsDurationInMinutes = 60

Variables

View Source
var ErrInvalidClaimsToken = errors.New("invalid claims token")

Functions

func IsEmailInDomain

func IsEmailInDomain(email string, domain string) bool

func IsEmailValid

func IsEmailValid(email string) bool

Types

type AuthClaims

type AuthClaims struct {
	Email       string `json:"email"`
	Name        string `json:"name"`
	Picture     string `json:"picture"`
	Permissions string `json:"permissions"`
	jwt.StandardClaims
}

func AuthClaimsFromContext

func AuthClaimsFromContext(ctx context.Context) (*AuthClaims, bool)

func NewAuthClaims

func NewAuthClaims(email string, name string, picture string, permissions string) *AuthClaims

func (*AuthClaims) ContextWithClaims

func (c *AuthClaims) ContextWithClaims(ctx context.Context) context.Context

func (*AuthClaims) IsAdmin

func (c *AuthClaims) IsAdmin() bool

func (*AuthClaims) Refresh

func (c *AuthClaims) Refresh() *AuthClaims

type AuthHelper

type AuthHelper struct {
	AllowedDomain string
	// contains filtered or unexported fields
}

func NewAuthHelper

func NewAuthHelper(allowedDomain string, secret string, adminsEmail []string) *AuthHelper

func (*AuthHelper) AuthClaimsFromSignedToken

func (h *AuthHelper) AuthClaimsFromSignedToken(tokenString string) (*AuthClaims, error)

func (*AuthHelper) InAllowedDomain

func (h *AuthHelper) InAllowedDomain(email string) bool

func (*AuthHelper) NewJWTSignedString

func (h *AuthHelper) NewJWTSignedString(claims *AuthClaims) string

func (*AuthHelper) RoleForEmail

func (h *AuthHelper) RoleForEmail(email string) string

Jump to

Keyboard shortcuts

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