user

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClaimIssuer        = "iss"
	ClaimSubject       = "sub"
	ClaimEmail         = "email"
	ClaimEmailVerified = "email_verified"
	ClaimName          = "name"
	ClaimGivenName     = "given_name"
	ClaimFamilyName    = "family_name"
	ClaimGroups        = "groups"
	ClaimPicture       = "picture"
)

default claim names

Variables

View Source
var Anonymous = &UserInfo{
	Subject: "anonymous",
	Name:    "anonymous",
	Issuer:  "system/anonymous",
}
View Source
var SystemAdmin = &UserInfo{
	Subject: "admin",
	Issuer:  "system/admin",
	Name:    "system-admin",
}

Functions

This section is empty.

Types

type Claims

type Claims map[string]json.RawMessage

func (Claims) HasClaim

func (c Claims) HasClaim(id string) bool

func (Claims) UnmarshalClaim

func (c Claims) UnmarshalClaim(id string, v interface{}) error

type User

type User interface {
	// GetIssuer returns the issuer of the subject id
	GetIssuer() string

	// GetSubject returns a unique user id, it is expected to stay stable
	GetSubject() string

	// GetName returns a human-readable name of the user
	GetName() string

	// GetEmail returns the users email, only if available and verified
	GetEmail() string

	// GetGroups returns the names of the groups the user is a member of
	GetGroups() []string

	// GetSignInProvider returns the sign-in provider that authenticated the user
	GetSignInProvider() string

	// GetLabels returns customer information for the user
	GetLabels() map[string]string

	// GetMrn returns the mrn set in the claims, or an empty string if non is found
	GetMrn() string
}

User describes the authenticated user

func ParseClaims

func ParseClaims(c *Claims) (User, error)

ParseClaims extracts basic information from the claims standard claims are defined in https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims we follow the required fields from google https://developers.google.com/identity/protocols/OpenIDConnect#server-flow required claims: iss, sub optional claims: name, email, email_verified

type UserInfo

type UserInfo struct {
	Mrn            string
	Issuer         string
	Subject        string
	Name           string
	Email          string
	Groups         []string
	SignInProvider string
	Labels         map[string]string
}

DefaultInfo provides a simple user information exchange object

func (*UserInfo) GetEmail

func (i *UserInfo) GetEmail() string

func (*UserInfo) GetGroups

func (i *UserInfo) GetGroups() []string

func (*UserInfo) GetIssuer

func (i *UserInfo) GetIssuer() string

func (*UserInfo) GetLabels

func (i *UserInfo) GetLabels() map[string]string

func (*UserInfo) GetMrn

func (i *UserInfo) GetMrn() string

func (*UserInfo) GetName

func (i *UserInfo) GetName() string

func (*UserInfo) GetSignInProvider

func (i *UserInfo) GetSignInProvider() string

func (*UserInfo) GetSubject

func (i *UserInfo) GetSubject() string

Jump to

Keyboard shortcuts

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