mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-07 00:46:56 +00:00
fix(openid/client): handle missing redirect uri for callbacks
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
urlpkg "github.com/nais/wonderwall/pkg/handler/url"
|
||||
"github.com/nais/wonderwall/pkg/openid"
|
||||
)
|
||||
|
||||
@@ -23,6 +24,16 @@ func NewLoginCallback(c *Client, r *http.Request, cookie *openid.LoginCookie) (*
|
||||
return nil, fmt.Errorf("cookie is nil")
|
||||
}
|
||||
|
||||
// redirect_uri not set in cookie (e.g. login initiated at instance running older version, callback handled at newer version)
|
||||
if len(cookie.RedirectURI) == 0 {
|
||||
callbackURL, err := urlpkg.LoginCallbackURL(r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("generating callback url: %w", err)
|
||||
}
|
||||
|
||||
cookie.RedirectURI = callbackURL
|
||||
}
|
||||
|
||||
return &LoginCallback{
|
||||
Client: c,
|
||||
cookie: cookie,
|
||||
|
||||
Reference in New Issue
Block a user