Documentation ¶
Index ¶
- Constants
- Variables
- func CreateInternalToken(params *model.Params) string
- func CreateToken(params *model.Params, userDetails *model.SysApiUserDetail) (string, time.Time, error)
- func Init(cfg *utils.Config)
- type JWTHS256Maker
- type JWTRS256Maker
- type JwksList
- type Maker
- type OpenIdConfiguration
- type Payload
Constants ¶
View Source
const ( HS256 = "HS256" RS256 = "RS256" )
View Source
const ( RoleSystem = "SYSTEM" RoleAdministrator = "ADMINISTRATOR" RoleUser = "USER" )
define roles in system
Variables ¶
View Source
var ( ErrInvalidToken = errors.New("token is invalid") ErrExpiredToken = errors.New("token has expired") )
Functions ¶
func CreateInternalToken ¶
func CreateToken ¶
Types ¶
type JWTHS256Maker ¶
type JWTHS256Maker struct {
// contains filtered or unexported fields
}
func (*JWTHS256Maker) CreateToken ¶
func (*JWTHS256Maker) VerifyToken ¶
func (maker *JWTHS256Maker) VerifyToken(token string) (*Payload, error)
type JWTRS256Maker ¶
type JWTRS256Maker struct {
// contains filtered or unexported fields
}
func (*JWTRS256Maker) CreateToken ¶
func (*JWTRS256Maker) VerifyToken ¶
func (maker *JWTRS256Maker) VerifyToken(token string) (*Payload, error)
type JwksList ¶
func GenerateJwks ¶
func GenerateJwks() *JwksList
type Maker ¶
type Maker interface { CreateToken(params *model.Params, duration time.Duration, userDetails *model.SysApiUserDetail) (string, time.Time, error) VerifyToken(token string) (*Payload, error) }
func NewJWTHS256Maker ¶
type OpenIdConfiguration ¶
type OpenIdConfiguration struct { Issuer string `json:"issuer"` AuthorizationEndpoint string `json:"authorization_endpoint"` JwksUri string `json:"jwks_uri"` }
func GenerateOpenIdConfiguration ¶
func GenerateOpenIdConfiguration() *OpenIdConfiguration
type Payload ¶
type Payload struct { Issuer string `json:"iss"` Id uuid.UUID `json:"jti"` Upn string `json:"upn"` Aud string `json:"aud"` Name string `json:"name,omitempty"` Provider string `json:"provider,omitempty"` Tenant string `json:"tenant,omitempty"` IssueAt *jwt.NumericDate `json:"iat,omitempty"` ExpiryAt *jwt.NumericDate `json:"exp,omitempty"` Roles []string `json:"roles,omitempty"` }
func NewPayload ¶
func VerifyToken ¶
Click to show internal directories.
Click to hide internal directories.