mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-02-28 20:02:04 +00:00
feat: add configuration guide in create oidc client command
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/steveiliop56/tinyauth/internal/utils"
|
"github.com/steveiliop56/tinyauth/internal/utils"
|
||||||
@@ -34,9 +35,37 @@ func createOidcClientCmd() *cli.Command {
|
|||||||
clientId := uuid.String()
|
clientId := uuid.String()
|
||||||
clientSecret := "ta-" + utils.GenerateString(61)
|
clientSecret := "ta-" + utils.GenerateString(61)
|
||||||
|
|
||||||
fmt.Printf("Client Name: %s\n", clientName)
|
uclientName := strings.ToUpper(clientName)
|
||||||
fmt.Printf("Client ID: %s\n", clientId)
|
lclientName := strings.ToLower(clientName)
|
||||||
fmt.Printf("Client Secret: %s\n", clientSecret)
|
|
||||||
|
builder := strings.Builder{}
|
||||||
|
|
||||||
|
// header
|
||||||
|
fmt.Fprintf(&builder, "Created credentials for client %s\n\n", clientName)
|
||||||
|
|
||||||
|
// credentials
|
||||||
|
fmt.Fprintf(&builder, "Client Name: %s\n", clientName)
|
||||||
|
fmt.Fprintf(&builder, "Client ID: %s\n", clientId)
|
||||||
|
fmt.Fprintf(&builder, "Client Secret: %s\n\n", clientSecret)
|
||||||
|
|
||||||
|
// env variables
|
||||||
|
fmt.Fprint(&builder, "Environment variables:\n\n")
|
||||||
|
fmt.Fprintf(&builder, "TINYAUTH_OIDC_CLIENTS_%s_CLIENTID=%s\n", uclientName, clientId)
|
||||||
|
fmt.Fprintf(&builder, "TINYAUTH_OIDC_CLIENTS_%s_CLIENTSECRET=%s\n", uclientName, clientSecret)
|
||||||
|
fmt.Fprintf(&builder, "TINYAUTH_OIDC_CLIENTS_%s_NAME=%s\n\n", uclientName, utils.Capitalize(lclientName))
|
||||||
|
|
||||||
|
// cli flags
|
||||||
|
fmt.Fprint(&builder, "CLI flags:\n\n")
|
||||||
|
fmt.Fprintf(&builder, "--oidc.clients.%s.clientid=%s\n", lclientName, clientId)
|
||||||
|
fmt.Fprintf(&builder, "--oidc.clients.%s.clientsecret=%s\n", lclientName, clientSecret)
|
||||||
|
fmt.Fprintf(&builder, "--oidc.clients.%s.name=%s\n\n", lclientName, utils.Capitalize(lclientName))
|
||||||
|
|
||||||
|
// footer
|
||||||
|
fmt.Fprintln(&builder, "You can use either option to configure your OIDC client. Make sure to save these credentials as there is no way to regenerate them.")
|
||||||
|
|
||||||
|
// print
|
||||||
|
out := builder.String()
|
||||||
|
fmt.Print(out)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user