Skip to content

Commit

Permalink
Merge pull request #1505 from MarcDufresne/show-login-page
Browse files Browse the repository at this point in the history
Add option to always display connector selection even if there's only one
  • Loading branch information
srenatus authored Aug 7, 2019
2 parents 89e43c1 + 0dbb642 commit e1afe77
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/dex/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ type OAuth2 struct {
// If specified, do not prompt the user to approve client authorization. The
// act of logging in implies authorization.
SkipApprovalScreen bool `json:"skipApprovalScreen"`
// If specified, show the connector selection screen even if there's only one
AlwaysShowLoginScreen bool `json:"alwaysShowLoginScreen"`
}

// Web is the config format for the HTTP server.
Expand Down
6 changes: 6 additions & 0 deletions cmd/dex/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ staticClients:
name: 'Example App'
secret: ZXhhbXBsZS1hcHAtc2VjcmV0
oauth2:
alwaysShowLoginScreen: true
connectors:
- type: mockCallback
id: mock
Expand Down Expand Up @@ -153,6 +156,9 @@ logger:
},
},
},
OAuth2: OAuth2{
AlwaysShowLoginScreen: true,
},
StaticConnectors: []Connector{
{
Type: "mockCallback",
Expand Down
1 change: 1 addition & 0 deletions cmd/dex/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ func serve(cmd *cobra.Command, args []string) error {
serverConfig := server.Config{
SupportedResponseTypes: c.OAuth2.ResponseTypes,
SkipApprovalScreen: c.OAuth2.SkipApprovalScreen,
AlwaysShowLoginScreen: c.OAuth2.AlwaysShowLoginScreen,
AllowedOrigins: c.Web.AllowedOrigins,
Issuer: c.Issuer,
Storage: s,
Expand Down
2 changes: 1 addition & 1 deletion server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (s *Server) handleAuthorization(w http.ResponseWriter, r *http.Request) {
return
}

if len(connectors) == 1 {
if len(connectors) == 1 && !s.alwaysShowLogin {
for _, c := range connectors {
// TODO(ericchiang): Make this pass on r.URL.RawQuery and let something latter
// on create the auth request.
Expand Down
7 changes: 7 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type Config struct {
// Logging in implies approval.
SkipApprovalScreen bool

// If enabled, the connectors selection page will always be shown even if there's only one
AlwaysShowLoginScreen bool

RotateKeysAfter time.Duration // Defaults to 6 hours.
IDTokensValidFor time.Duration // Defaults to 24 hours
AuthRequestsValidFor time.Duration // Defaults to 24 hours
Expand Down Expand Up @@ -137,6 +140,9 @@ type Server struct {
// If enabled, don't prompt user for approval after logging in through connector.
skipApproval bool

// If enabled, show the connector selection screen even if there's only one
alwaysShowLogin bool

supportedResponseTypes map[string]bool

now func() time.Time
Expand Down Expand Up @@ -205,6 +211,7 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
idTokensValidFor: value(c.IDTokensValidFor, 24*time.Hour),
authRequestsValidFor: value(c.AuthRequestsValidFor, 24*time.Hour),
skipApproval: c.SkipApprovalScreen,
alwaysShowLogin: c.AlwaysShowLoginScreen,
now: now,
templates: tmpls,
logger: c.Logger,
Expand Down

0 comments on commit e1afe77

Please sign in to comment.