diff --git a/cmd/admin-idp-info.go b/cmd/admin-idp-info.go
new file mode 100644
index 00000000..da274a8b
--- /dev/null
+++ b/cmd/admin-idp-info.go
@@ -0,0 +1,139 @@
+// Copyright (c) 2015-2022 MinIO, Inc.
+//
+// This file is part of MinIO Object Storage stack
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package cmd
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+
+ "github.com/charmbracelet/lipgloss"
+ "github.com/minio/cli"
+ json "github.com/minio/colorjson"
+ "github.com/minio/madmin-go"
+ "github.com/minio/mc/pkg/probe"
+)
+
+var adminIDPInfoCmd = cli.Command{
+ Name: "info",
+ Usage: "Show IDP server config info",
+ Before: setGlobalsFromContext,
+ Action: mainAdminIDPGet,
+ OnUsageError: onUsageError,
+ Flags: globalFlags,
+ CustomHelpTemplate: `NAME:
+ {{.HelpName}} - {{.Usage}}
+
+USAGE:
+ {{.HelpName}} TARGET ID_TYPE [CFG_NAME]
+
+FLAGS:
+ {{range .VisibleFlags}}{{.}}
+ {{end}}
+EXAMPLES:
+ 1. Show configuration info for default (un-named) openid configuration.
+ {{.Prompt}} {{.HelpName}} play/ openid
+ 2. Show configuration info for openid configuration named "dex_test".
+ {{.Prompt}} {{.HelpName}} play/ openid dex_test
+`,
+}
+
+func mainAdminIDPGet(ctx *cli.Context) error {
+ if len(ctx.Args()) < 2 || len(ctx.Args()) > 3 {
+ cli.ShowCommandHelpAndExit(ctx, "get", 1)
+ }
+
+ args := ctx.Args()
+ aliasedURL := args.Get(0)
+
+ // Create a new MinIO Admin Client
+ client, err := newAdminClient(aliasedURL)
+ fatalIf(err, "Unable to initialize admin connection.")
+
+ idpType := args.Get(1)
+
+ if idpType != "openid" {
+ fatalIf(probe.NewError(errors.New("not implemented")), "This feature is not yet available")
+ }
+
+ var cfgName string
+ if len(args) == 3 {
+ cfgName = args.Get(2)
+ }
+
+ result, e := client.GetIDPConfig(globalContext, idpType, cfgName)
+ fatalIf(probe.NewError(e), "Unable to get IDP config for '%s' to server", idpType)
+
+ // Print set config result
+ printMsg(idpConfig(result))
+
+ return nil
+}
+
+type idpConfig madmin.IDPConfig
+
+func (i idpConfig) JSON() string {
+ bs, e := json.MarshalIndent(i, "", " ")
+ fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
+
+ return string(bs)
+}
+
+func (i idpConfig) String() string {
+ // Determine required width for key column.
+ fieldColWidth := 0
+ for _, kv := range i.Info {
+ if fieldColWidth < len(kv.Key) {
+ fieldColWidth = len(kv.Key)
+ }
+ }
+ // Add 1 for the colon-suffix in each entry.
+ fieldColWidth++
+
+ fieldColStyle := lipgloss.NewStyle().
+ Width(fieldColWidth).
+ Foreground(lipgloss.Color("#04B575")). // green
+ Bold(true).
+ Align(lipgloss.Right)
+ valueColStyle := lipgloss.NewStyle().
+ PaddingLeft(1).
+ Align(lipgloss.Left)
+ envMarkStyle := lipgloss.NewStyle().
+ Foreground(lipgloss.Color("201")). // pinkish-red
+ PaddingLeft(1)
+
+ var lines []string
+ for _, kv := range i.Info {
+ envStr := ""
+ if kv.IsCfg && kv.IsEnv {
+ envStr = " (environment)"
+ }
+ lines = append(lines, fmt.Sprintf("%s%s%s",
+ fieldColStyle.Render(kv.Key+":"),
+ valueColStyle.Render(kv.Value),
+ envMarkStyle.Render(envStr),
+ ))
+ }
+
+ boxContent := strings.Join(lines, "\n")
+
+ boxStyle := lipgloss.NewStyle().
+ BorderStyle(lipgloss.RoundedBorder())
+
+ return boxStyle.Render(boxContent)
+}
diff --git a/cmd/admin-idp-ls.go b/cmd/admin-idp-ls.go
new file mode 100644
index 00000000..18c61671
--- /dev/null
+++ b/cmd/admin-idp-ls.go
@@ -0,0 +1,171 @@
+// Copyright (c) 2015-2022 MinIO, Inc.
+//
+// This file is part of MinIO Object Storage stack
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package cmd
+
+import (
+ "encoding/json"
+ "errors"
+ "strings"
+
+ "github.com/charmbracelet/lipgloss"
+ "github.com/minio/cli"
+ "github.com/minio/madmin-go"
+ "github.com/minio/mc/pkg/probe"
+)
+
+var adminIDPLsCmd = cli.Command{
+ Name: "ls",
+ Usage: "List IDP configurations",
+ Before: setGlobalsFromContext,
+ Action: mainAdminIDPList,
+ OnUsageError: onUsageError,
+ Flags: globalFlags,
+ CustomHelpTemplate: `NAME:
+ {{.HelpName}} - {{.Usage}}
+
+USAGE:
+ {{.HelpName}} TARGET ID_TYPE
+
+FLAGS:
+ {{range .VisibleFlags}}{{.}}
+ {{end}}
+EXAMPLES:
+ 1. List the available openid configurations.
+ {{.Prompt}} {{.HelpName}} play/ openid
+`,
+}
+
+func mainAdminIDPList(ctx *cli.Context) error {
+ if len(ctx.Args()) != 2 {
+ cli.ShowCommandHelpAndExit(ctx, "ls", 1)
+ }
+
+ args := ctx.Args()
+ aliasedURL := args.Get(0)
+
+ // Create a new MinIO Admin Client
+ client, err := newAdminClient(aliasedURL)
+ fatalIf(err, "Unable to initialize admin connection.")
+
+ idpType := args.Get(1)
+
+ if idpType != "openid" {
+ fatalIf(probe.NewError(errors.New("not implemented")), "This feature is not yet available")
+ }
+
+ result, e := client.ListIDPConfig(globalContext, idpType)
+ fatalIf(probe.NewError(e), "Unable to list IDP config for '%s'", idpType)
+
+ printMsg(idpCfgList(result))
+
+ return nil
+}
+
+type idpCfgList []madmin.IDPListItem
+
+func (i idpCfgList) JSON() string {
+ bs, e := json.MarshalIndent(i, "", " ")
+ fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
+
+ return string(bs)
+}
+
+func (i idpCfgList) String() string {
+ maxNameWidth := len("Name")
+ maxRoleARNWidth := len("RoleArn")
+ for _, item := range i {
+ name := item.Name
+ if name == "_" {
+ name = "(default)" // for the un-named config, don't show `_`
+ }
+ if maxNameWidth < len(name) {
+ maxNameWidth = len(name)
+ }
+ if maxRoleARNWidth < len(item.RoleARN) {
+ maxRoleARNWidth = len(item.RoleARN)
+ }
+ }
+ enabledWidth := 5
+ // Add 2 for padding
+ maxNameWidth += 2
+ maxRoleARNWidth += 2
+
+ enabledColStyle := lipgloss.NewStyle().
+ Align(lipgloss.Center).
+ PaddingLeft(1).
+ PaddingRight(1).
+ Width(enabledWidth)
+ nameColStyle := lipgloss.NewStyle().
+ Align(lipgloss.Right).
+ PaddingLeft(1).
+ PaddingRight(1).
+ Width(maxNameWidth)
+ arnColStyle := lipgloss.NewStyle().
+ Align(lipgloss.Left).
+ PaddingLeft(1).
+ PaddingRight(1).
+ Foreground(lipgloss.Color("#04B575")). // green
+ Width(maxRoleARNWidth)
+
+ styles := []lipgloss.Style{enabledColStyle, nameColStyle, arnColStyle}
+
+ headers := []string{"On?", "Name", "RoleARN"}
+ headerRow := []string{}
+
+ // Override some style settings for the header
+ for ii, hdr := range headers {
+ headerRow = append(headerRow,
+ styles[ii].Copy().
+ Bold(true).
+ Foreground(lipgloss.Color("#6495ed")). // green
+ Align(lipgloss.Center).
+ Render(hdr),
+ )
+ }
+
+ lines := []string{strings.Join(headerRow, "")}
+
+ enabledOff := "🔴"
+ enabledOn := "🟢"
+
+ for _, item := range i {
+ enabled := enabledOff
+ if item.Enabled {
+ enabled = enabledOn
+ }
+
+ line := []string{
+ styles[0].Render(enabled),
+ styles[1].Render(item.Name),
+ styles[2].Render(item.RoleARN),
+ }
+ if item.Name == "_" {
+ // For default config, don't display `_` and make it look faint.
+ line[1] = styles[1].Copy().
+ Faint(true).
+ Render("(default)")
+ }
+ lines = append(lines, strings.Join(line, ""))
+ }
+
+ boxContent := strings.Join(lines, "\n")
+ boxStyle := lipgloss.NewStyle().
+ BorderStyle(lipgloss.RoundedBorder())
+
+ return boxStyle.Render(boxContent)
+}
diff --git a/cmd/admin-idp-rm.go b/cmd/admin-idp-rm.go
new file mode 100644
index 00000000..b9fde81a
--- /dev/null
+++ b/cmd/admin-idp-rm.go
@@ -0,0 +1,78 @@
+// Copyright (c) 2015-2022 MinIO, Inc.
+//
+// This file is part of MinIO Object Storage stack
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package cmd
+
+import (
+ "errors"
+
+ "github.com/minio/cli"
+ "github.com/minio/mc/pkg/probe"
+)
+
+var adminIDPRmCmd = cli.Command{
+ Name: "rm",
+ Usage: "Remove an IDP configuration",
+ Before: setGlobalsFromContext,
+ Action: mainAdminIDPRemove,
+ OnUsageError: onUsageError,
+ Flags: globalFlags,
+ CustomHelpTemplate: `NAME:
+ {{.HelpName}} - {{.Usage}}
+
+USAGE:
+ {{.HelpName}} TARGET IDP_TYPE CFG_NAME
+
+FLAGS:
+ {{range .VisibleFlags}}{{.}}
+ {{end}}
+EXAMPLES:
+ 1. Remove an OpenID configuration from the server.
+ {{.Prompt}} {{.HelpName}} play/ openid myidp
+`,
+}
+
+func mainAdminIDPRemove(ctx *cli.Context) error {
+ if len(ctx.Args()) != 3 {
+ cli.ShowCommandHelpAndExit(ctx, "rm", 1)
+ }
+
+ args := ctx.Args()
+ aliasedURL := args.Get(0)
+
+ // Create a new MinIO Admin Client
+ client, err := newAdminClient(aliasedURL)
+ fatalIf(err, "Unable to initialize admin connection.")
+
+ idpType := args.Get(1)
+
+ if idpType != "openid" {
+ fatalIf(probe.NewError(errors.New("not implemented")), "This feature is not yet available")
+ }
+
+ cfgName := args.Get(2)
+
+ restart, e := client.DeleteIDPConfig(globalContext, idpType, cfgName)
+ fatalIf(probe.NewError(e), "Unable to remove %s IDP config '%s'", idpType, cfgName)
+
+ printMsg(configSetMessage{
+ targetAlias: aliasedURL,
+ restart: restart,
+ })
+
+ return nil
+}
diff --git a/cmd/admin-idp-set.go b/cmd/admin-idp-set.go
new file mode 100644
index 00000000..aacf1c51
--- /dev/null
+++ b/cmd/admin-idp-set.go
@@ -0,0 +1,102 @@
+// Copyright (c) 2015-2022 MinIO, Inc.
+//
+// This file is part of MinIO Object Storage stack
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package cmd
+
+import (
+ "errors"
+ "strings"
+
+ "github.com/minio/cli"
+ "github.com/minio/mc/pkg/probe"
+)
+
+var adminIDPSetCmd = cli.Command{
+ Name: "set",
+ Usage: "Create/Update an IDP server configuration",
+ Before: setGlobalsFromContext,
+ Action: mainAdminIDPSet,
+ OnUsageError: onUsageError,
+ Flags: globalFlags,
+ CustomHelpTemplate: `NAME:
+ {{.HelpName}} - {{.Usage}}
+
+USAGE:
+ {{.HelpName}} TARGET ID_TYPE [CFG_NAME] [CFG_PARAMS...]
+
+FLAGS:
+ {{range .VisibleFlags}}{{.}}
+ {{end}}
+EXAMPLES:
+ 1. Create/Update the default OpenID IDP configuration (CFG_NAME is omitted).
+ {{.Prompt}} {{.HelpName}} play/ openid \
+ client_id=minio-client-app \
+ client_secret=minio-client-app-secret \
+ config_url="http://localhost:5556/dex/.well-known/openid-configuration" \
+ scopes="openid,groups" \
+ redirect_uri="http://127.0.0.1:10000/oauth_callback" \
+ role_policy="consoleAdmin"
+ 2. Create/Update configuration for OpenID IDP configuration named "dex_test".
+ {{.Prompt}} {{.HelpName}} play/ openid dex_test \
+ client_id=minio-client-app \
+ client_secret=minio-client-app-secret \
+ config_url="http://localhost:5556/dex/.well-known/openid-configuration" \
+ scopes="openid,groups" \
+ redirect_uri="http://127.0.0.1:10000/oauth_callback" \
+ role_policy="consoleAdmin"
+`,
+}
+
+func mainAdminIDPSet(ctx *cli.Context) error {
+ if len(ctx.Args()) < 3 {
+ cli.ShowCommandHelpAndExit(ctx, "set", 1)
+ }
+
+ args := ctx.Args()
+
+ aliasedURL := args.Get(0)
+
+ // Create a new MinIO Admin Client
+ client, err := newAdminClient(aliasedURL)
+ fatalIf(err, "Unable to initialize admin connection.")
+
+ idpType := args.Get(1)
+
+ if idpType != "openid" {
+ fatalIf(probe.NewError(errors.New("not implemented")), "This feature is not yet available")
+ }
+
+ var cfgName string
+ input := args[2:]
+ if !strings.Contains(args.Get(2), "=") {
+ cfgName = args.Get(2)
+ input = args[3:]
+ }
+
+ inputCfg := strings.Join(input, " ")
+
+ restart, e := client.SetIDPConfig(globalContext, idpType, cfgName, inputCfg)
+ fatalIf(probe.NewError(e), "Unable to set IDP config for '%s' to server", idpType)
+
+ // Print set config result
+ printMsg(configSetMessage{
+ targetAlias: aliasedURL,
+ restart: restart,
+ })
+
+ return nil
+}
diff --git a/cmd/admin-idp.go b/cmd/admin-idp.go
new file mode 100644
index 00000000..2de65de6
--- /dev/null
+++ b/cmd/admin-idp.go
@@ -0,0 +1,42 @@
+// Copyright (c) 2015-2022 MinIO, Inc.
+//
+// This file is part of MinIO Object Storage stack
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package cmd
+
+import "github.com/minio/cli"
+
+var adminIDPSubcommands = []cli.Command{
+ adminIDPSetCmd,
+ adminIDPInfoCmd,
+ adminIDPLsCmd,
+ adminIDPRmCmd,
+}
+
+var adminIDPCmd = cli.Command{
+ Name: "idp",
+ Usage: "manage MinIO IDentity Provider server configuration",
+ Action: mainAdminIDP,
+ Before: setGlobalsFromContext,
+ Flags: globalFlags,
+ Subcommands: adminIDPSubcommands,
+ HideHelpCommand: true,
+}
+
+func mainAdminIDP(ctx *cli.Context) error {
+ commandNotFound(ctx, adminIDPSubcommands)
+ return nil
+}
diff --git a/cmd/admin-main.go b/cmd/admin-main.go
index 7b9a798d..e0741985 100644
--- a/cmd/admin-main.go
+++ b/cmd/admin-main.go
@@ -37,6 +37,7 @@ var adminCmdSubcommands = []cli.Command{
adminGroupCmd,
adminPolicyCmd,
adminReplicateCmd,
+ adminIDPCmd,
adminConfigCmd,
adminDecommissionCmd,
adminHealCmd,
diff --git a/cmd/auto-complete.go b/cmd/auto-complete.go
index 2b25728e..39e6fd59 100644
--- a/cmd/auto-complete.go
+++ b/cmd/auto-complete.go
@@ -343,6 +343,11 @@ var completeCmds = map[string]complete.Predictor{
"/admin/profile/start": aliasCompleter,
"/admin/profile/stop": aliasCompleter,
+ "/admin/idp/set": aliasCompleter,
+ "/admin/idp/info": aliasCompleter,
+ "/admin/idp/ls": aliasCompleter,
+ "/admin/idp/rm": aliasCompleter,
+
"/admin/policy/info": aliasCompleter,
"/admin/policy/set": aliasCompleter,
"/admin/policy/unset": aliasCompleter,