feat: add all optional claims of the introspection response
This commit is contained in:
parent
aea3f43268
commit
653209a23c
1 changed files with 70 additions and 16 deletions
|
@ -19,10 +19,17 @@ type ClientAssertionParams struct {
|
||||||
|
|
||||||
type IntrospectionResponse interface {
|
type IntrospectionResponse interface {
|
||||||
UserInfoSetter
|
UserInfoSetter
|
||||||
SetActive(bool)
|
|
||||||
IsActive() bool
|
IsActive() bool
|
||||||
|
SetActive(bool)
|
||||||
SetScopes(scopes []string)
|
SetScopes(scopes []string)
|
||||||
SetClientID(id string)
|
SetClientID(id string)
|
||||||
|
SetTokenType(tokenType string)
|
||||||
|
SetExpiration(exp time.Time)
|
||||||
|
SetIssuedAt(iat time.Time)
|
||||||
|
SetNotBefore(nbf time.Time)
|
||||||
|
SetAudience(audience []string)
|
||||||
|
SetIssuer(issuer string)
|
||||||
|
SetJWTID(id string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIntrospectionResponse() IntrospectionResponse {
|
func NewIntrospectionResponse() IntrospectionResponse {
|
||||||
|
@ -30,10 +37,17 @@ func NewIntrospectionResponse() IntrospectionResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
type introspectionResponse struct {
|
type introspectionResponse struct {
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
Scope SpaceDelimitedArray `json:"scope,omitempty"`
|
Scope SpaceDelimitedArray `json:"scope,omitempty"`
|
||||||
ClientID string `json:"client_id,omitempty"`
|
ClientID string `json:"client_id,omitempty"`
|
||||||
Subject string `json:"sub,omitempty"`
|
TokenType string `json:"token_type,omitempty"`
|
||||||
|
Expiration Time `json:"exp,omitempty"`
|
||||||
|
IssuedAt Time `json:"iat,omitempty"`
|
||||||
|
NotBefore Time `json:"nbf,omitempty"`
|
||||||
|
Subject string `json:"sub,omitempty"`
|
||||||
|
Audience Audience `json:"aud,omitempty"`
|
||||||
|
Issuer string `json:"iss,omitempty"`
|
||||||
|
JWTID string `json:"jti,omitempty"`
|
||||||
userInfoProfile
|
userInfoProfile
|
||||||
userInfoEmail
|
userInfoEmail
|
||||||
userInfoPhone
|
userInfoPhone
|
||||||
|
@ -46,14 +60,6 @@ func (i *introspectionResponse) IsActive() bool {
|
||||||
return i.Active
|
return i.Active
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *introspectionResponse) SetScopes(scope []string) {
|
|
||||||
i.Scope = scope
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *introspectionResponse) SetClientID(id string) {
|
|
||||||
i.ClientID = id
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *introspectionResponse) GetSubject() string {
|
func (i *introspectionResponse) GetSubject() string {
|
||||||
return i.Subject
|
return i.Subject
|
||||||
}
|
}
|
||||||
|
@ -138,6 +144,42 @@ func (i *introspectionResponse) SetActive(active bool) {
|
||||||
i.Active = active
|
i.Active = active
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetScopes(scope []string) {
|
||||||
|
i.Scope = scope
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetClientID(id string) {
|
||||||
|
i.ClientID = id
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetTokenType(tokenType string) {
|
||||||
|
i.TokenType = tokenType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetExpiration(exp time.Time) {
|
||||||
|
i.Expiration = Time(exp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetIssuedAt(iat time.Time) {
|
||||||
|
i.IssuedAt = Time(iat)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetNotBefore(nbf time.Time) {
|
||||||
|
i.NotBefore = Time(nbf)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetAudience(audience []string) {
|
||||||
|
i.Audience = audience
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetIssuer(issuer string) {
|
||||||
|
i.Issuer = issuer
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *introspectionResponse) SetJWTID(id string) {
|
||||||
|
i.JWTID = id
|
||||||
|
}
|
||||||
|
|
||||||
func (i *introspectionResponse) SetSubject(sub string) {
|
func (i *introspectionResponse) SetSubject(sub string) {
|
||||||
i.Subject = sub
|
i.Subject = sub
|
||||||
}
|
}
|
||||||
|
@ -223,9 +265,12 @@ func (i *introspectionResponse) MarshalJSON() ([]byte, error) {
|
||||||
type Alias introspectionResponse
|
type Alias introspectionResponse
|
||||||
a := &struct {
|
a := &struct {
|
||||||
*Alias
|
*Alias
|
||||||
Locale interface{} `json:"locale,omitempty"`
|
Expiration int64 `json:"exp,omitempty"`
|
||||||
UpdatedAt int64 `json:"updated_at,omitempty"`
|
IssuedAt int64 `json:"iat,omitempty"`
|
||||||
Username string `json:"username,omitempty"`
|
NotBefore int64 `json:"nbf,omitempty"`
|
||||||
|
Locale interface{} `json:"locale,omitempty"`
|
||||||
|
UpdatedAt int64 `json:"updated_at,omitempty"`
|
||||||
|
Username string `json:"username,omitempty"`
|
||||||
}{
|
}{
|
||||||
Alias: (*Alias)(i),
|
Alias: (*Alias)(i),
|
||||||
}
|
}
|
||||||
|
@ -235,6 +280,15 @@ func (i *introspectionResponse) MarshalJSON() ([]byte, error) {
|
||||||
if !time.Time(i.UpdatedAt).IsZero() {
|
if !time.Time(i.UpdatedAt).IsZero() {
|
||||||
a.UpdatedAt = time.Time(i.UpdatedAt).Unix()
|
a.UpdatedAt = time.Time(i.UpdatedAt).Unix()
|
||||||
}
|
}
|
||||||
|
if !time.Time(i.Expiration).IsZero() {
|
||||||
|
a.Expiration = time.Time(i.Expiration).Unix()
|
||||||
|
}
|
||||||
|
if !time.Time(i.IssuedAt).IsZero() {
|
||||||
|
a.IssuedAt = time.Time(i.IssuedAt).Unix()
|
||||||
|
}
|
||||||
|
if !time.Time(i.NotBefore).IsZero() {
|
||||||
|
a.NotBefore = time.Time(i.NotBefore).Unix()
|
||||||
|
}
|
||||||
a.Username = i.PreferredUsername
|
a.Username = i.PreferredUsername
|
||||||
|
|
||||||
b, err := json.Marshal(a)
|
b, err := json.Marshal(a)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue