Files
stack/libs/go-libs/auth/cli.go
2024-03-12 17:53:14 +00:00

34 lines
1.0 KiB
Go

package auth
import (
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/fx"
)
const (
AuthEnabled = "auth-enabled"
AuthIssuerFlag = "auth-issuer"
AuthReadKeySetMaxRetriesFlag = "auth-read-key-set-max-retries"
AuthCheckScopesFlag = "auth-check-scopes"
AuthServiceFlag = "auth-service"
)
func InitAuthFlags(flags *flag.FlagSet) {
flags.Bool(AuthEnabled, false, "Enable auth")
flags.String(AuthIssuerFlag, "", "Issuer")
flags.Int(AuthReadKeySetMaxRetriesFlag, 10, "ReadKeySetMaxRetries")
flags.Bool(AuthCheckScopesFlag, false, "CheckScopes")
flags.String(AuthServiceFlag, "", "Service")
}
func CLIAuthModule() fx.Option {
return Module(ModuleConfig{
Enabled: viper.GetBool(AuthEnabled),
Issuer: viper.GetString(AuthIssuerFlag),
ReadKeySetMaxRetries: viper.GetInt(AuthReadKeySetMaxRetriesFlag),
CheckScopes: viper.GetBool(AuthCheckScopesFlag),
Service: viper.GetString(AuthServiceFlag),
})
}