Documentation ¶
Index ¶
- func AccountIDCookie() string
- func AddMD(ctx context.Context, actorID, group string) context.Context
- func AddTokenMD(ctx context.Context, token string) context.Context
- func AdminGroup() string
- func Admins() []string
- func AuthenticateRequest(ctx context.Context) error
- func GenToken(ctx context.Context, payload *Payload, expirationTime time.Time) (string, error)
- func Groups() []string
- func Header() string
- func JWTCookie() string
- func RefreshCookie() string
- func Scheme() string
- func SessionIDCookie() string
- func SuperAdminGroup() string
- func User() string
- type Claims
- type Interface
- type Payload
- func AuthenticateActor(ctx context.Context, actorID string) (*Payload, error)
- func AuthorizeActorOrGroup(ctx context.Context, actorID string, allowedGroups ...string) (*Payload, error)
- func AuthorizeGroup(ctx context.Context, allowedGroups ...string) (*Payload, error)
- func AuthorizeStrict(ctx context.Context, actorID string, allowedGroups ...string) (*Payload, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountIDCookie ¶
func AccountIDCookie() string
AccountIDCookie is name of cookie holding account ID of signed in user
func AddTokenMD ¶
AddTokenMD adds token as authorization metadata to context and returns the updated context object
func AuthenticateRequest ¶
AuthenticateRequest authenticates a request whether it contains valid jwt in metadata
func RefreshCookie ¶
func RefreshCookie() string
RefreshCookie is name of cookie holding jwt refresh token
func SessionIDCookie ¶
func SessionIDCookie() string
SessionIDCookie is name of cookie holding session ID of signed in user
Types ¶
type Claims ¶
type Claims struct { *Payload jwt.StandardClaims }
Claims contains JWT claims information
func ParseFromCtx ¶
ParseFromCtx jwt token from context
func ParseToken ¶
ParseToken parses a jwt token and return claims
type Interface ¶
type Interface interface { AuthenticateRequest(context.Context) error AuthenticateRequestV2(context.Context) (*Payload, error) AuthorizeActor(ctx context.Context, actorID string) (*Payload, error) AuthorizeGroups(ctx context.Context, allowedGroups ...string) (*Payload, error) AuthorizeStrict(ctx context.Context, actorID string, allowedGroups ...string) (*Payload, error) AuthorizeActorOrGroups(ctx context.Context, actorID string, allowedGroups ...string) (*Payload, error) GenToken(context.Context, *Payload, time.Time) (string, error) }
Interface is a generic authentication and authorization API
type Payload ¶
type Payload struct { ID string ProjectID string Names string PhoneNumber string EmailAddress string Group string }
Payload contains jwt payload
func AuthenticateActor ¶
AuthenticateActor authenticates actor
func AuthorizeActorOrGroup ¶
func AuthorizeActorOrGroup(ctx context.Context, actorID string, allowedGroups ...string) (*Payload, error)
AuthorizeActorOrGroup authorizes the actor or whether they belong to list of allowed groups
func AuthorizeGroup ¶
AuthorizeGroup authorizes an actor group against allowed groups