Skip to content

Commit dab4eb7

Browse files
authored
Fixes to Multiple IDP support in console (#2392)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent 139e908 commit dab4eb7

File tree

19 files changed

+380
-112
lines changed

19 files changed

+380
-112
lines changed

models/login_details.go

Lines changed: 63 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/redirect_rule.go

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operatorapi/embedded_spec.go

Lines changed: 26 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operatorapi/login.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ func getLoginDetailsResponse(params authApi.LoginDetailParams) (*models.LoginDet
101101
r := params.HTTPRequest
102102

103103
loginStrategy := models.LoginDetailsLoginStrategyServiceDashAccount
104-
redirectURL := []string{}
104+
105+
var redirectRules []*models.RedirectRule
105106

106107
if oauth2.IsIDPEnabled() {
107108
loginStrategy = models.LoginDetailsLoginStrategyRedirectDashServiceDashAccount
@@ -115,12 +116,18 @@ func getLoginDetailsResponse(params authApi.LoginDetailParams) (*models.LoginDet
115116
KeyFunc: oauth2.DefaultDerivedKey,
116117
Client: oauth2Client,
117118
}
118-
redirectURL = append(redirectURL, identityProvider.GenerateLoginURL())
119+
120+
newRedirectRule := &models.RedirectRule{
121+
Redirect: identityProvider.GenerateLoginURL(),
122+
DisplayName: "Login with SSO",
123+
}
124+
125+
redirectRules = append(redirectRules, newRedirectRule)
119126
}
120127

121128
loginDetails := &models.LoginDetails{
122129
LoginStrategy: loginStrategy,
123-
Redirect: redirectURL,
130+
RedirectRules: redirectRules,
124131
IsDirectPV: getDirectPVEnabled(),
125132
}
126133
return loginDetails, nil

pkg/auth/idp.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ type IdentityProviderI interface {
4040
type IdentityProvider struct {
4141
KeyFunc oauth2.StateKeyFunc
4242
Client *oauth2.Provider
43+
RoleARN string
4344
}
4445

4546
// VerifyIdentity will verify the user identity against the idp using the authorization code flow
4647
func (c IdentityProvider) VerifyIdentity(ctx context.Context, code, state string) (*credentials.Credentials, error) {
47-
return c.Client.VerifyIdentity(ctx, code, state, c.KeyFunc)
48+
return c.Client.VerifyIdentity(ctx, code, state, c.RoleARN, c.KeyFunc)
4849
}
4950

5051
// VerifyIdentityForOperator will verify the user identity against the idp using the authorization code flow
@@ -54,5 +55,5 @@ func (c IdentityProvider) VerifyIdentityForOperator(ctx context.Context, code, s
5455

5556
// GenerateLoginURL returns a new URL used by the user to login against the idp
5657
func (c IdentityProvider) GenerateLoginURL() string {
57-
return c.Client.GenerateLoginURL(c.KeyFunc)
58+
return c.Client.GenerateLoginURL(c.KeyFunc, c.Client.IDPName)
5859
}

pkg/auth/idp/oauth2/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ func (pc ProviderConfig) GetStateKeyFunc() StateKeyFunc {
4848
}
4949
}
5050

51-
type OpenIDPCfg map[string]ProviderConfig
51+
func (pc ProviderConfig) GetARNInf() string {
52+
return pc.RoleArn
53+
}
5254

53-
var DefaultIDPConfig = "_"
55+
type OpenIDPCfg map[string]ProviderConfig
5456

5557
func GetSTSEndpoint() string {
5658
return strings.TrimSpace(env.Get(ConsoleMinIOServer, "http://localhost:9000"))

pkg/auth/idp/oauth2/const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ const (
2929
ConsoleIDPScopes = "CONSOLE_IDP_SCOPES"
3030
ConsoleIDPUserInfo = "CONSOLE_IDP_USERINFO"
3131
ConsoleIDPTokenExpiration = "CONSOLE_IDP_TOKEN_EXPIRATION"
32+
ConsoleIDPRoleARN = "CONSOLE_IDP_ROLE_ARN"
3233
)

0 commit comments

Comments
 (0)