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 IsEmailValid ¶
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
Click to show internal directories.
Click to hide internal directories.