mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 18:33:28 +00:00
fix(providers): set prompt select_account again (#5329)
This commit is contained in:
@@ -34,7 +34,7 @@ func TestProvider_BeginAuth(t *testing.T) {
|
||||
redirectURI: "redirectURI",
|
||||
},
|
||||
want: &oidc.Session{
|
||||
AuthURL: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=clientID&redirect_uri=redirectURI&response_type=code&scope=openid+profile+email&state=testState",
|
||||
AuthURL: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=clientID&prompt=select_account&redirect_uri=redirectURI&response_type=code&scope=openid+profile+email&state=testState",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -48,7 +48,7 @@ func TestProvider_BeginAuth(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &oidc.Session{
|
||||
AuthURL: "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize?client_id=clientID&redirect_uri=redirectURI&response_type=code&scope=openid+profile+email&state=testState",
|
||||
AuthURL: "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize?client_id=clientID&prompt=select_account&redirect_uri=redirectURI&response_type=code&scope=openid+profile+email&state=testState",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ func TestProvider_BeginAuth(t *testing.T) {
|
||||
redirectURI: "redirectURI",
|
||||
},
|
||||
want: &oauth.Session{
|
||||
AuthURL: "https://github.com/login/oauth/authorize?client_id=clientID&redirect_uri=redirectURI&response_type=code&state=testState",
|
||||
AuthURL: "https://github.com/login/oauth/authorize?client_id=clientID&prompt=select_account&redirect_uri=redirectURI&response_type=code&state=testState",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ func TestProvider_BeginAuth(t *testing.T) {
|
||||
scopes: []string{"openid"},
|
||||
},
|
||||
want: &oidc.Session{
|
||||
AuthURL: "https://gitlab.com/oauth/authorize?client_id=clientID&redirect_uri=redirectURI&response_type=code&scope=openid&state=testState",
|
||||
AuthURL: "https://gitlab.com/oauth/authorize?client_id=clientID&prompt=select_account&redirect_uri=redirectURI&response_type=code&scope=openid&state=testState",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ func TestProvider_BeginAuth(t *testing.T) {
|
||||
scopes: []string{"openid"},
|
||||
},
|
||||
want: &oidc.Session{
|
||||
AuthURL: "https://accounts.google.com/o/oauth2/v2/auth?client_id=clientID&redirect_uri=redirectURI&response_type=code&scope=openid&state=testState",
|
||||
AuthURL: "https://accounts.google.com/o/oauth2/v2/auth?client_id=clientID&prompt=select_account&redirect_uri=redirectURI&response_type=code&scope=openid&state=testState",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/oidc/v2/pkg/client/rp"
|
||||
"github.com/zitadel/oidc/v2/pkg/oidc"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/idp"
|
||||
@@ -87,7 +88,7 @@ func (p *Provider) Name() string {
|
||||
// BeginAuth implements the [idp.Provider] interface.
|
||||
// It will create a [Session] with an OAuth2.0 authorization request as AuthURL.
|
||||
func (p *Provider) BeginAuth(ctx context.Context, state string, _ ...any) (idp.Session, error) {
|
||||
url := rp.AuthURL(state, p.RelyingParty)
|
||||
url := rp.AuthURL(state, p.RelyingParty, rp.WithPrompt(oidc.PromptSelectAccount))
|
||||
return &Session{AuthURL: url, Provider: p}, nil
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ func TestProvider_BeginAuth(t *testing.T) {
|
||||
Scopes: []string{"user"},
|
||||
},
|
||||
},
|
||||
want: &Session{AuthURL: "https://oauth2.com/authorize?client_id=clientID&redirect_uri=redirectURI&response_type=code&scope=user&state=testState"},
|
||||
want: &Session{AuthURL: "https://oauth2.com/authorize?client_id=clientID&prompt=select_account&redirect_uri=redirectURI&response_type=code&scope=user&state=testState"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@@ -105,7 +105,7 @@ func (p *Provider) Name() string {
|
||||
// BeginAuth implements the [idp.Provider] interface.
|
||||
// It will create a [Session] with an OIDC authorization request as AuthURL.
|
||||
func (p *Provider) BeginAuth(ctx context.Context, state string, _ ...any) (idp.Session, error) {
|
||||
url := rp.AuthURL(state, p.RelyingParty)
|
||||
url := rp.AuthURL(state, p.RelyingParty, rp.WithPrompt(oidc.PromptSelectAccount))
|
||||
return &Session{AuthURL: url, Provider: p}, nil
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@ func TestProvider_BeginAuth(t *testing.T) {
|
||||
})
|
||||
},
|
||||
},
|
||||
want: &Session{AuthURL: "https://issuer.com/authorize?client_id=clientID&redirect_uri=redirectURI&response_type=code&scope=openid&state=testState"},
|
||||
want: &Session{AuthURL: "https://issuer.com/authorize?client_id=clientID&prompt=select_account&redirect_uri=redirectURI&response_type=code&scope=openid&state=testState"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
Reference in New Issue
Block a user