Documentation
¶
Index ¶
- Constants
- func CreateLoginToken(name string, activeOrganization string, validFor time.Duration) (string, error)
- func CreatePasswordToken(name string, validFor time.Duration) (string, error)
- func CreateVerificationToken(name string, validFor time.Duration) (string, error)
- func GetActiveOrganization(ctx context.Context) string
- func GetUser(ctx context.Context) string
- func Interceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (i interface{}, err error)
- func StreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- type AccountClaims
Constants ¶
View Source
const ( TokenKey = "amp.token" UserKey = "amp.user" ActiveOrganizationKey = "amp.organization" CredentialsRequired = "credentials required" )
Keys used in context metadata
View Source
const ( TokenTypeVerification = "verification" TokenTypeLogin = "login" TokenTypePassword = "password" )
Token types
Variables ¶
This section is empty.
Functions ¶
func CreateLoginToken ¶
func CreateLoginToken(name string, activeOrganization string, validFor time.Duration) (string, error)
CreateLoginToken creates a login token for a given user name
func CreatePasswordToken ¶
CreatePasswordToken creates a password token for a given user name
func CreateVerificationToken ¶
CreateVerificationToken creates a verification token for a given user name
func GetActiveOrganization ¶
GetActiveOrganization gets the active organization from context metadata
func Interceptor ¶
func Interceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (i interface{}, err error)
Interceptor is an interceptor checking for authentication tokens
func StreamInterceptor ¶
func StreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
StreamInterceptor is an interceptor checking for authentication tokens
Types ¶
type AccountClaims ¶
type AccountClaims struct {
AccountName string `json:"AccountName"`
ActiveOrganization string `json:"ActiveOrganization"`
Type string `json:"Type"`
jwt.StandardClaims
}
AccountClaims represents account claims
func ValidateToken ¶
func ValidateToken(signedString string, tokenType string) (*AccountClaims, error)
ValidateToken validates a token and return its claims
Click to show internal directories.
Click to hide internal directories.