mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-19 19:17:01 -07:00
Tidied up environment var related code
This commit is contained in:
parent
2d982d2bb6
commit
198da56791
4 changed files with 50 additions and 7 deletions
10
cmd/root.go
10
cmd/root.go
|
|
@ -31,7 +31,6 @@ var rootCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
func Execute() {
|
||||
initialize()
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to start CLI: %s", err)
|
||||
os.Exit(1)
|
||||
|
|
@ -39,14 +38,19 @@ func Execute() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&config.Options.Verbose, "verbose", "v", false, "set the verbose flag")
|
||||
cobra.OnInitialize(initialize)
|
||||
rootCmd.PersistentFlags().BoolVarP(&config.Options.Verbose, "verbose", "v", config.Options.Verbose, "set the verbose flag")
|
||||
rootCmd.PersistentFlags().StringVarP(&confPath, "config", "c", "", "set the config path")
|
||||
rootCmd.PersistentFlags().StringVar(&config.Options.CachePath, "cache", "", "set the cache path")
|
||||
}
|
||||
|
||||
func initialize() {
|
||||
initConfig()
|
||||
initEnv()
|
||||
err := initEnv()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Println("WARNING: Ignoring environment variables with errors.")
|
||||
}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ var serveCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
serveCmd.Flags().StringVar(&config.Server.Issuer.Host, "host", "127.0.0.1", "set the identity provider host")
|
||||
serveCmd.Flags().IntVar(&config.Server.Issuer.Port, "port", 3332, "set the identity provider port")
|
||||
serveCmd.Flags().StringVar(&endpoints.Authorization, "endpoints.authorization", "", "set the authorization endpoint for the identity provider")
|
||||
serveCmd.Flags().StringVar(&endpoints.Token, "endpoints.token", "", "set the token endpoint for the identity provider")
|
||||
serveCmd.Flags().StringVar(&endpoints.JwksUri, "endpoints.jwks_uri", "", "set the JWKS endpoints for the identity provider")
|
||||
serveCmd.Flags().IntVar(&config.Server.Issuer.Port, "port", config.Server.Issuer.Port, "set the identity provider port")
|
||||
serveCmd.Flags().StringVar(&endpoints.Authorization, "endpoints.authorization", endpoints.Authorization, "set the authorization endpoint for the identity provider")
|
||||
serveCmd.Flags().StringVar(&endpoints.Token, "endpoints.token", endpoints.Token, "set the token endpoint for the identity provider")
|
||||
serveCmd.Flags().StringVar(&endpoints.JwksUri, "endpoints.jwks_uri", endpoints.JwksUri, "set the JWKS endpoints for the identity provider")
|
||||
|
||||
rootCmd.AddCommand(serveCmd)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ func NewConfig() Config {
|
|||
Host: "127.0.0.1",
|
||||
Port: 3333,
|
||||
Issuer: server.IdentityProviderServer{
|
||||
Host: "127.0.0.1",
|
||||
Port: 3332,
|
||||
Endpoints: oidc.Endpoints{
|
||||
Authorization: "",
|
||||
Token: "",
|
||||
|
|
|
|||
|
|
@ -75,6 +75,43 @@ func NewIdentityProvider() *IdentityProvider {
|
|||
return p
|
||||
}
|
||||
|
||||
func (p *IdentityProvider) NewEndpoints() *Endpoints {
|
||||
return &Endpoints{
|
||||
Authorization: p.Issuer + "/oauth/authorize",
|
||||
Token: p.Issuer + "/oauth/token",
|
||||
Revocation: p.Issuer + "/oauth/revocation",
|
||||
Introspection: p.Issuer + "/oauth/introspect",
|
||||
UserInfo: p.Issuer + "/oauth/userinfo",
|
||||
JwksUri: p.Issuer + "/oauth/discovery/keys",
|
||||
}
|
||||
}
|
||||
|
||||
func (p *IdentityProvider) NewSupported() *Supported {
|
||||
return &Supported{
|
||||
ResponseTypes: []string{"code"},
|
||||
ResponseModes: []string{"query"},
|
||||
GrantTypes: []string{
|
||||
"authorization_code",
|
||||
"client_credentials",
|
||||
"refresh_token",
|
||||
},
|
||||
TokenEndpointAuthMethods: []string{
|
||||
"client_secret_basic",
|
||||
"client_secret_post",
|
||||
},
|
||||
SubjectTypes: []string{"public"},
|
||||
IdTokenSigningAlgValues: []string{"RS256"},
|
||||
ClaimTypes: []string{"normal"},
|
||||
Claims: []string{
|
||||
"iss",
|
||||
"sub",
|
||||
"aud",
|
||||
"exp",
|
||||
"iat",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p *IdentityProvider) ParseServerConfig(data []byte) error {
|
||||
// parse JSON into IdentityProvider fields
|
||||
var ep Endpoints
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue