Skip to content

Commit 135d9fe

Browse files
authored
Merge pull request #8 from georgmangold/fix-oidc
fix: Added Console Login with OIDC
2 parents 7eda7cc + 99fbf4e commit 135d9fe

4 files changed

Lines changed: 89 additions & 0 deletions

File tree

api/config.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,32 @@ func getConsoleDevMode() bool {
299299
func getConsoleBrowserRedirectURL() string {
300300
return env.Get(ConsoleBrowserRedirectURL, "")
301301
}
302+
303+
func BuildOpenIDConsoleConfig() oauth2.OpenIDPCfg {
304+
pcfg := map[string]oauth2.ProviderConfig{}
305+
306+
url := env.Get(ConsoleIDPURL, env.Get(MinioIdentifyOpenIDConfigURL, ""))
307+
clientID := env.Get(ConsoleIDPClientID, env.Get(MinioIdentifyOpenIDClientID, ""))
308+
clientSecret := env.Get(ConsoleIDPSecret, env.Get(MinioIdentifyOpenIDClientSecret, ""))
309+
redirectCallback := env.Get(ConsoleIDPCallbackURL, env.Get(MinioBrowserRedirectURL, ""))
310+
311+
// Only set config if url, clientID, clientSecret and redirectCallback are provided
312+
if url != "" && clientID != "" && clientSecret != "" && redirectCallback != "" {
313+
pcfg = map[string]oauth2.ProviderConfig{
314+
"OIDC": {
315+
URL: url,
316+
ClientID: clientID,
317+
ClientSecret: clientSecret,
318+
RedirectCallback: redirectCallback,
319+
DisplayName: env.Get(ConsoleIDPDisplayName, env.Get(MinioIdentifyOpenIDDisplayName, "")),
320+
Scopes: env.Get(ConsoleIDPScopes, env.Get(MinioIdentifyOpenIDScopes, "openid,profile,email")),
321+
Userinfo: env.Get(ConsoleIDPUserInfo, env.Get(MinioIdentifyOpenIDClaimUserinfo, "")) == "on",
322+
RedirectCallbackDynamic: env.Get(ConsoleIDPCallbackURLDynamic, env.Get(MinioIdentifyOpenIDRedirectURIDynamic, "")) == "on",
323+
RoleArn: env.Get(ConsoleIDPRolePolicy, env.Get(MinioIdentifyOpenIDRolePolicy, "")),
324+
EndSessionEndpoint: env.Get(ConsoleIDPEndSessionEndpoint, ""),
325+
},
326+
}
327+
}
328+
329+
return pcfg
330+
}

api/consts.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,26 @@ const (
5959
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
6060
SlashSeparator = "/"
6161
LocalAddress = "127.0.0.1"
62+
63+
// Parts of Environment constants for console OIDC/ IDP/SSO as defined in pkg/auth/idp/oath2
64+
ConsoleIDPDisplayName = "CONSOLE_IDP_DISPLAY_NAME"
65+
ConsoleIDPURL = "CONSOLE_IDP_URL"
66+
ConsoleIDPClientID = "CONSOLE_IDP_CLIENT_ID"
67+
ConsoleIDPSecret = "CONSOLE_IDP_SECRET"
68+
ConsoleIDPCallbackURL = "CONSOLE_IDP_CALLBACK"
69+
ConsoleIDPCallbackURLDynamic = "CONSOLE_IDP_CALLBACK_DYNAMIC"
70+
ConsoleIDPScopes = "CONSOLE_IDP_SCOPES"
71+
ConsoleIDPUserInfo = "CONSOLE_IDP_USERINFO"
72+
ConsoleIDPRolePolicy = "CONSOLE_IDP_ROLE_POLICY"
73+
ConsoleIDPEndSessionEndpoint = "CONSOLE_IDP_END_SESSION_ENDPOINT"
74+
// MinIO Server constants for OIDC
75+
MinioIdentifyOpenIDDisplayName = "MINIO_IDENTITY_OPENID_DISPLAY_NAME"
76+
MinioIdentifyOpenIDConfigURL = "MINIO_IDENTITY_OPENID_CONFIG_URL"
77+
MinioIdentifyOpenIDClientID = "MINIO_IDENTITY_OPENID_CLIENT_ID"
78+
MinioIdentifyOpenIDClientSecret = "MINIO_IDENTITY_OPENID_CLIENT_SECRET"
79+
MinioBrowserRedirectURL = "MINIO_BROWSER_REDIRECT_URL"
80+
MinioIdentifyOpenIDRedirectURIDynamic = "MINIO_IDENTITY_OPENID_REDIRECT_URI_DYNAMIC"
81+
MinioIdentifyOpenIDScopes = "MINIO_IDENTITY_OPENID_SCOPES"
82+
MinioIdentifyOpenIDClaimUserinfo = "MINIO_IDENTITY_OPENID_CLAIM_USERINFO"
83+
MinioIdentifyOpenIDRolePolicy = "MINIO_IDENTITY_OPENID_ROLE_POLICY"
6284
)

cmd/console/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ func buildServer() (*api.Server, error) {
100100

101101
consoleAPI := operations.NewConsoleAPI(swaggerSpec)
102102
consoleAPI.Logger = api.LogInfo
103+
// Pass in console application config. This needs to happen before the
104+
// ConfigureAPI() call.
105+
api.GlobalMinIOConfig = api.MinIOConfig{
106+
OpenIDProviders: api.BuildOpenIDConsoleConfig(),
107+
}
103108
server := api.NewServer(consoleAPI)
104109

105110
parser := flags.NewParser(server, flags.Default)

docs/OIDC.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# OIDC
2+
When the console is running separately and is not embedded in the same binary as the server, the OIDC SSO login configuration is not set from the server.
3+
4+
It needs to be configured using Environment Variables like this:
5+
``` bash
6+
export CONSOLE_MINIO_SERVER="http://127.0.0.1:9000";
7+
8+
export CONSOLE_IDP_URL="http://PROVIDER:5556/.well-known/openid-configuration";
9+
export CONSOLE_IDP_CLIENT_ID="minio-client-app";
10+
export CONSOLE_IDP_SECRET="minio-client-app-secret";
11+
export CONSOLE_IDP_CALLBACK="http://CONSOLE:9090/oauth_callback";
12+
export CONSOLE_IDP_DISPLAY_NAME="Login with OIDC";
13+
14+
./console server
15+
```
16+
> [!IMPORTANT]
17+
> Currently, the following environment variables are mandatory: `CONSOLE_IDP_URL`, `CONSOLE_IDP_CLIENT_ID`, `CONSOLE_IDP_SECRET` and `CONSOLE_IDP_CALLBACK`.
18+
19+
For convenience, the same environment variables are supported as for the server, with the `CONSOLE_` ones taking precedence over the `MINIO_` ones.
20+
This means you can use the same variables as you would set on the server and share them with the console.
21+
22+
| Console Environment Variables | MinIO Server Environment Variables | Required | Example |
23+
| -- | -- | -- | -- |
24+
CONSOLE_IDP_DISPLAY_NAME | MINIO_IDENTITY_OPENID_DISPLAY_NAME | | "Login with OIDC"
25+
CONSOLE_IDP_URL | MINIO_IDENTITY_OPENID_CONFIG_URL | ✓ | https://provider/.well-known/openid-configuration"
26+
CONSOLE_IDP_CLIENT_ID | MINIO_IDENTITY_OPENID_CLIENT_ID | ✓ | minio-client-app
27+
CONSOLE_IDP_SECRET | MINIO_IDENTITY_OPENID_CLIENT_SECRET | ✓ | minio-client-app-secret
28+
CONSOLE_IDP_CALLBACK | MINIO_BROWSER_REDIRECT_URL | ✓ | https://console/oauth_callback" |
29+
CONSOLE_IDP_CALLBACK_DYNAMIC | MINIO_IDENTITY_OPENID_REDIRECT_URI_DYNAMIC | | on / off |
30+
CONSOLE_IDP_SCOPES | MINIO_IDENTITY_OPENID_SCOPES | | "openid,profile,email"
31+
CONSOLE_IDP_USERINFO | MINIO_IDENTITY_OPENID_CLAIM_USERINFO | |on / off |
32+
CONSOLE_IDP_ROLE_POLICY | MINIO_IDENTITY_OPENID_ROLE_POLICY | | "app-bucket-write,app-bucket-list" |
33+
CONSOLE_IDP_END_SESSION_ENDPOINT | | |

0 commit comments

Comments
 (0)