Documentation ¶
Index ¶
- Constants
- func Exists(name string) bool
- func GenerateAndStoreNewRsaKey(ctx context.Context, basePath, name string) error
- func JtiPartsToString(parts JtiParts) string
- type Claims
- type DiProvider
- type JtiParts
- type Jwk
- type JwkGenerateParams
- type JwkRepository
- type JwkRepositoryImpl
- func (repo *JwkRepositoryImpl) Add(ctx context.Context, jwk Jwk) error
- func (repo *JwkRepositoryImpl) Generate(ctx context.Context, params JwkGenerateParams) error
- func (repo *JwkRepositoryImpl) Get(ctx context.Context, id string) (Jwk, error)
- func (repo *JwkRepositoryImpl) GetLatest(ctx context.Context) (Jwk, error)
- func (repo *JwkRepositoryImpl) List(ctx context.Context) (result []Jwk, err error)
- func (repo *JwkRepositoryImpl) Store(ctx context.Context, jwk Jwk) error
- type JwkRsa
- type JwkService
- type Jwt
- type JwtService
- type JwtSigningService
- type KeysFacade
- type Repositories
- type Services
- type SignedJwt
- func (j *SignedJwt) AppId() string
- func (j *SignedJwt) Audience() string
- func (j *SignedJwt) Claims() map[string]interface{}
- func (j *SignedJwt) ClientId() string
- func (j *SignedJwt) ExpiresAt() time.Time
- func (j *SignedJwt) ID() string
- func (j *SignedJwt) IssuedAt() time.Time
- func (j *SignedJwt) Issuer() string
- func (j *SignedJwt) Jti() JtiParts
- func (j *SignedJwt) JwkID() string
- func (j *SignedJwt) Raw() string
- func (j *SignedJwt) RawHeader() map[string]interface{}
- func (j *SignedJwt) Scopes() shared.Scopes
- func (j *SignedJwt) Subject() string
- func (j *SignedJwt) UserId() string
- type TokenCreateParams
Constants ¶
View Source
const ( TokenTypeAccess = "a" TokenTypeRefresh = "r" TokenTypeId = "i" TokenTypeSession = "s" TokenTypeUndefined = "U" )
View Source
const AccessTokenExpiration = HOUR
View Source
const DAY = HOUR * 24
View Source
const HOUR int64 = 3600
View Source
const IdTokenExpiration = 8 * HOUR
View Source
const LatestPrivateKey = "latest" + PrivateKeyExt
View Source
const PasswordLogin = "pwd-login"
View Source
const PrivateKeyExt = ".pem"
View Source
const PublicKeyExt = ".pub"
View Source
const RefreshTokenExpiration = 7 * DAY // WEEK
View Source
const SessionTokenExpiration = 12 * HOUR
Variables ¶
This section is empty.
Functions ¶
func JtiPartsToString ¶
Types ¶
type Claims ¶
type Claims struct { Audience string `json:"aud,omitempty"` ExpiresAt int64 `json:"exp,omitempty"` Id string `json:"jti,omitempty"` IssuedAt int64 `json:"iat,omitempty"` Issuer string `json:"iss,omitempty"` Subject string `json:"sub,omitempty"` Additional map[string]interface{} Scopes shared.Scopes `json:"scope,omitempty"` }
type DiProvider ¶
type DiProvider struct { Repos Repositories Services Services Facade KeysFacade }
func NewDiProvider ¶
func NewDiProvider(keyPath string) DiProvider
type JtiParts ¶
func ParseJtiParts ¶
type Jwk ¶
type JwkGenerateParams ¶
type JwkGenerateParams struct { }
type JwkRepository ¶
type JwkRepository interface { Get(ctx context.Context, id string) (Jwk, error) List(ctx context.Context) ([]Jwk, error) Generate(ctx context.Context, params JwkGenerateParams) error Store(ctx context.Context, jwk Jwk) error Add(ctx context.Context, jwk Jwk) error GetLatest(ctx context.Context) (Jwk, error) }
func NewJwkRepository ¶
func NewJwkRepository(keysPath string) JwkRepository
type JwkRepositoryImpl ¶
type JwkRepositoryImpl struct { BasePath string // contains filtered or unexported fields }
func (*JwkRepositoryImpl) Add ¶
func (repo *JwkRepositoryImpl) Add(ctx context.Context, jwk Jwk) error
func (*JwkRepositoryImpl) Generate ¶
func (repo *JwkRepositoryImpl) Generate(ctx context.Context, params JwkGenerateParams) error
func (*JwkRepositoryImpl) GetLatest ¶
func (repo *JwkRepositoryImpl) GetLatest(ctx context.Context) (Jwk, error)
type JwkRsa ¶
type JwkRsa struct {
// contains filtered or unexported fields
}
func (*JwkRsa) PrivateKey ¶
func (jwk *JwkRsa) PrivateKey() crypto.PrivateKey
type JwkService ¶
type JwkService interface { GenerateNew(ctx context.Context) error List(ctx context.Context) ([]Jwk, error) Get(ctx context.Context, id string) (Jwk, error) GetLatest(ctx context.Context) (Jwk, error) }
func NewJwkService ¶
func NewJwkService(jwkRepo JwkRepository) JwkService
type Jwt ¶
type Jwt interface { JwkID() string ClientId() string Audience() string Subject() string ID() string Issuer() string IssuedAt() time.Time ExpiresAt() time.Time UserId() string AppId() string Scopes() shared.Scopes Jti() JtiParts Raw() string // Kind of internal Claims() map[string]interface{} RawHeader() map[string]interface{} }
type JwtService ¶
type JwtService interface { CreateAccessToken(ctx context.Context, params TokenCreateParams) (Jwt, error) CreateRefreshToken(ctx context.Context, params TokenCreateParams) (Jwt, error) CreateIdToken(ctx context.Context, params TokenCreateParams) (Jwt, error) CreateSessionToken(ctx context.Context, params TokenCreateParams) (Jwt, error) CreateSignedAccessToken(ctx context.Context, params TokenCreateParams) (*SignedJwt, error) CreateSignedRefreshToken(ctx context.Context, params TokenCreateParams) (*SignedJwt, error) CreateSignedIdToken(ctx context.Context, params TokenCreateParams) (*SignedJwt, error) CreateSignedSessionToken(ctx context.Context, params TokenCreateParams) (*SignedJwt, error) }
func NewJwtService ¶
func NewJwtService(keys JwkRepository) JwtService
type JwtSigningService ¶
type JwtSigningService interface { Sign(ctx context.Context, token Jwt) (*SignedJwt, error) Create(ctx context.Context, claims Claims) (Jwt, error) }
func NewJwtSigningService ¶
func NewJwtSigningService(repo JwkRepository) JwtSigningService
type KeysFacade ¶
type KeysFacade interface { ListJwks(ctx context.Context) ([]Jwk, error) GenerateNewJwk(ctx context.Context) error GetLatest(ctx context.Context) (Jwk, error) }
func NewKeysFacade ¶
func NewKeysFacade(jwkService JwkService) KeysFacade
type Repositories ¶
type Repositories struct {
Jwk JwkRepository
}
type Services ¶
type Services struct { Jwk JwkService Jwt JwtService }
type SignedJwt ¶
type SignedJwt struct { Signature string // contains filtered or unexported fields }
type TokenCreateParams ¶
Click to show internal directories.
Click to hide internal directories.