comments
This commit is contained in:
parent
507a437c56
commit
f845ce2010
2 changed files with 22 additions and 15 deletions
|
@ -43,51 +43,58 @@ type JWTTokenRequest struct {
|
||||||
ExpiresAt Time `json:"exp"`
|
ExpiresAt Time `json:"exp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JWTTokenRequest) GetClientID() string {
|
//GetSubject implements the Claims interface
|
||||||
return j.Subject
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j *JWTTokenRequest) GetSubject() string {
|
|
||||||
return j.Subject
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j *JWTTokenRequest) GetScopes() []string {
|
|
||||||
return j.Scopes
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j *JWTTokenRequest) GetIssuer() string {
|
func (j *JWTTokenRequest) GetIssuer() string {
|
||||||
return j.Issuer
|
return j.Issuer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetAudience implements the Claims and TokenRequest interfaces
|
||||||
func (j *JWTTokenRequest) GetAudience() []string {
|
func (j *JWTTokenRequest) GetAudience() []string {
|
||||||
return j.Audience
|
return j.Audience
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetExpiration implements the Claims interface
|
||||||
func (j *JWTTokenRequest) GetExpiration() time.Time {
|
func (j *JWTTokenRequest) GetExpiration() time.Time {
|
||||||
return time.Time(j.ExpiresAt)
|
return time.Time(j.ExpiresAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetIssuedAt implements the Claims interface
|
||||||
func (j *JWTTokenRequest) GetIssuedAt() time.Time {
|
func (j *JWTTokenRequest) GetIssuedAt() time.Time {
|
||||||
return time.Time(j.IssuedAt)
|
return time.Time(j.IssuedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetNonce implements the Claims interface
|
||||||
func (j *JWTTokenRequest) GetNonce() string {
|
func (j *JWTTokenRequest) GetNonce() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetAuthenticationContextClassReference implements the Claims interface
|
||||||
func (j *JWTTokenRequest) GetAuthenticationContextClassReference() string {
|
func (j *JWTTokenRequest) GetAuthenticationContextClassReference() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetAuthTime implements the Claims interface
|
||||||
func (j *JWTTokenRequest) GetAuthTime() time.Time {
|
func (j *JWTTokenRequest) GetAuthTime() time.Time {
|
||||||
return time.Time{}
|
return time.Time{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetAuthorizedParty implements the Claims interface
|
||||||
func (j *JWTTokenRequest) GetAuthorizedParty() string {
|
func (j *JWTTokenRequest) GetAuthorizedParty() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JWTTokenRequest) SetSignatureAlgorithm(algorithm jose.SignatureAlgorithm) {}
|
//SetSignatureAlgorithm implements the Claims interface
|
||||||
|
func (j *JWTTokenRequest) SetSignatureAlgorithm(_ jose.SignatureAlgorithm) {}
|
||||||
|
|
||||||
|
//GetSubject implements the TokenRequest interface
|
||||||
|
func (j *JWTTokenRequest) GetSubject() string {
|
||||||
|
return j.Subject
|
||||||
|
}
|
||||||
|
|
||||||
|
//GetSubject implements the TokenRequest interface
|
||||||
|
func (j *JWTTokenRequest) GetScopes() []string {
|
||||||
|
return j.Scopes
|
||||||
|
}
|
||||||
|
|
||||||
type TokenExchangeRequest struct {
|
type TokenExchangeRequest struct {
|
||||||
subjectToken string `schema:"subject_token"`
|
subjectToken string `schema:"subject_token"`
|
||||||
|
|
|
@ -82,8 +82,8 @@ func CreateBearerToken(id string, crypto Crypto) (string, error) {
|
||||||
return crypto.Encrypt(id)
|
return crypto.Encrypt(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateJWT(issuer string, authReq TokenRequest, exp time.Time, id string, signer Signer) (string, error) {
|
func CreateJWT(issuer string, tokenRequest TokenRequest, exp time.Time, id string, signer Signer) (string, error) {
|
||||||
claims := oidc.NewAccessTokenClaims(issuer, authReq.GetSubject(), authReq.GetAudience(), exp, id)
|
claims := oidc.NewAccessTokenClaims(issuer, tokenRequest.GetSubject(), tokenRequest.GetAudience(), exp, id)
|
||||||
return utils.Sign(claims, signer.Signer())
|
return utils.Sign(claims, signer.Signer())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue