feat: update end session request to pass all params according to specification (#754)
* feat: update end session request to pass all params according to specification * register encoder
This commit is contained in:
parent
7d57aaa999
commit
f94bd541d7
4 changed files with 23 additions and 5 deletions
|
@ -4,7 +4,9 @@ package oidc
|
|||
// https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout
|
||||
type EndSessionRequest struct {
|
||||
IdTokenHint string `schema:"id_token_hint"`
|
||||
LogoutHint string `schema:"logout_hint"`
|
||||
ClientID string `schema:"client_id"`
|
||||
PostLogoutRedirectURI string `schema:"post_logout_redirect_uri"`
|
||||
State string `schema:"state"`
|
||||
UILocales Locales `schema:"ui_locales"`
|
||||
}
|
||||
|
|
|
@ -115,6 +115,14 @@ func ParseLocales(locales []string) Locales {
|
|||
return out
|
||||
}
|
||||
|
||||
func (l Locales) String() string {
|
||||
tags := make([]string, len(l))
|
||||
for i, tag := range l {
|
||||
tags[i] = tag.String()
|
||||
}
|
||||
return strings.Join(tags, " ")
|
||||
}
|
||||
|
||||
// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
|
||||
// It decodes an unquoted space seperated string into Locales.
|
||||
// Undefined language tags in the input are ignored and ommited from
|
||||
|
@ -231,6 +239,9 @@ func NewEncoder() *schema.Encoder {
|
|||
e.RegisterEncoder(SpaceDelimitedArray{}, func(value reflect.Value) string {
|
||||
return value.Interface().(SpaceDelimitedArray).String()
|
||||
})
|
||||
e.RegisterEncoder(Locales{}, func(value reflect.Value) string {
|
||||
return value.Interface().(Locales).String()
|
||||
})
|
||||
return e
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ func ValidateEndSessionRequest(ctx context.Context, req *oidc.EndSessionRequest,
|
|||
|
||||
session := &EndSessionRequest{
|
||||
RedirectURI: ender.DefaultLogoutRedirectURI(),
|
||||
LogoutHint: req.LogoutHint,
|
||||
UILocales: req.UILocales,
|
||||
}
|
||||
if req.IdTokenHint != "" {
|
||||
claims, err := VerifyIDTokenHint[*oidc.IDTokenClaims](ctx, req.IdTokenHint, ender.IDTokenHintVerifier(ctx))
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
jose "github.com/go-jose/go-jose/v4"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/oidc/v3/pkg/oidc"
|
||||
)
|
||||
|
@ -170,6 +171,8 @@ type EndSessionRequest struct {
|
|||
ClientID string
|
||||
IDTokenHintClaims *oidc.IDTokenClaims
|
||||
RedirectURI string
|
||||
LogoutHint string
|
||||
UILocales []language.Tag
|
||||
}
|
||||
|
||||
var ErrDuplicateUserCode = errors.New("user code already exists")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue