Add option to always display connector selection even if there's only one
This commit is contained in:
parent
6ae11a1cfe
commit
0dbb642f2c
5 changed files with 17 additions and 1 deletions
|
@ -127,6 +127,8 @@ type OAuth2 struct {
|
||||||
// If specified, do not prompt the user to approve client authorization. The
|
// If specified, do not prompt the user to approve client authorization. The
|
||||||
// act of logging in implies authorization.
|
// act of logging in implies authorization.
|
||||||
SkipApprovalScreen bool `json:"skipApprovalScreen"`
|
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.
|
// Web is the config format for the HTTP server.
|
||||||
|
|
|
@ -76,6 +76,9 @@ staticClients:
|
||||||
name: 'Example App'
|
name: 'Example App'
|
||||||
secret: ZXhhbXBsZS1hcHAtc2VjcmV0
|
secret: ZXhhbXBsZS1hcHAtc2VjcmV0
|
||||||
|
|
||||||
|
oauth2:
|
||||||
|
alwaysShowLoginScreen: true
|
||||||
|
|
||||||
connectors:
|
connectors:
|
||||||
- type: mockCallback
|
- type: mockCallback
|
||||||
id: mock
|
id: mock
|
||||||
|
@ -140,6 +143,9 @@ logger:
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
OAuth2: OAuth2{
|
||||||
|
AlwaysShowLoginScreen: true,
|
||||||
|
},
|
||||||
StaticConnectors: []Connector{
|
StaticConnectors: []Connector{
|
||||||
{
|
{
|
||||||
Type: "mockCallback",
|
Type: "mockCallback",
|
||||||
|
|
|
@ -199,6 +199,7 @@ func serve(cmd *cobra.Command, args []string) error {
|
||||||
serverConfig := server.Config{
|
serverConfig := server.Config{
|
||||||
SupportedResponseTypes: c.OAuth2.ResponseTypes,
|
SupportedResponseTypes: c.OAuth2.ResponseTypes,
|
||||||
SkipApprovalScreen: c.OAuth2.SkipApprovalScreen,
|
SkipApprovalScreen: c.OAuth2.SkipApprovalScreen,
|
||||||
|
AlwaysShowLoginScreen: c.OAuth2.AlwaysShowLoginScreen,
|
||||||
AllowedOrigins: c.Web.AllowedOrigins,
|
AllowedOrigins: c.Web.AllowedOrigins,
|
||||||
Issuer: c.Issuer,
|
Issuer: c.Issuer,
|
||||||
Storage: s,
|
Storage: s,
|
||||||
|
|
|
@ -249,7 +249,7 @@ func (s *Server) handleAuthorization(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(connectors) == 1 {
|
if len(connectors) == 1 && !s.alwaysShowLogin {
|
||||||
for _, c := range connectors {
|
for _, c := range connectors {
|
||||||
// TODO(ericchiang): Make this pass on r.URL.RawQuery and let something latter
|
// TODO(ericchiang): Make this pass on r.URL.RawQuery and let something latter
|
||||||
// on create the auth request.
|
// on create the auth request.
|
||||||
|
|
|
@ -68,6 +68,9 @@ type Config struct {
|
||||||
// Logging in implies approval.
|
// Logging in implies approval.
|
||||||
SkipApprovalScreen bool
|
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.
|
RotateKeysAfter time.Duration // Defaults to 6 hours.
|
||||||
IDTokensValidFor time.Duration // Defaults to 24 hours
|
IDTokensValidFor time.Duration // Defaults to 24 hours
|
||||||
AuthRequestsValidFor time.Duration // Defaults to 24 hours
|
AuthRequestsValidFor time.Duration // Defaults to 24 hours
|
||||||
|
@ -134,6 +137,9 @@ type Server struct {
|
||||||
// If enabled, don't prompt user for approval after logging in through connector.
|
// If enabled, don't prompt user for approval after logging in through connector.
|
||||||
skipApproval bool
|
skipApproval bool
|
||||||
|
|
||||||
|
// If enabled, show the connector selection screen even if there's only one
|
||||||
|
alwaysShowLogin bool
|
||||||
|
|
||||||
supportedResponseTypes map[string]bool
|
supportedResponseTypes map[string]bool
|
||||||
|
|
||||||
now func() time.Time
|
now func() time.Time
|
||||||
|
@ -201,6 +207,7 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
|
||||||
idTokensValidFor: value(c.IDTokensValidFor, 24*time.Hour),
|
idTokensValidFor: value(c.IDTokensValidFor, 24*time.Hour),
|
||||||
authRequestsValidFor: value(c.AuthRequestsValidFor, 24*time.Hour),
|
authRequestsValidFor: value(c.AuthRequestsValidFor, 24*time.Hour),
|
||||||
skipApproval: c.SkipApprovalScreen,
|
skipApproval: c.SkipApprovalScreen,
|
||||||
|
alwaysShowLogin: c.AlwaysShowLoginScreen,
|
||||||
now: now,
|
now: now,
|
||||||
templates: tmpls,
|
templates: tmpls,
|
||||||
logger: c.Logger,
|
logger: c.Logger,
|
||||||
|
|
Reference in a new issue