mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-30 10:10:44 +02:00
fix command
This commit is contained in:
parent
19ac4fbcaf
commit
0ec2399a2c
64
cmd/cmd.go
64
cmd/cmd.go
@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/micro/go-micro/v2/auth"
|
||||
"github.com/micro/go-micro/v2/auth/provider"
|
||||
"github.com/micro/go-micro/v2/broker"
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/client/grpc"
|
||||
@ -69,10 +68,6 @@ import (
|
||||
|
||||
// auth
|
||||
jwtAuth "github.com/micro/go-micro/v2/auth/jwt"
|
||||
|
||||
// auth providers
|
||||
"github.com/micro/go-micro/v2/auth/provider/basic"
|
||||
"github.com/micro/go-micro/v2/auth/provider/oauth"
|
||||
)
|
||||
|
||||
type Cmd interface {
|
||||
@ -283,36 +278,6 @@ var (
|
||||
EnvVars: []string{"MICRO_AUTH_PRIVATE_KEY"},
|
||||
Usage: "Private key for JWT auth (base64 encoded PEM)",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth_provider",
|
||||
EnvVars: []string{"MICRO_AUTH_PROVIDER"},
|
||||
Usage: "Auth provider used to login user",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth_provider_client_id",
|
||||
EnvVars: []string{"MICRO_AUTH_PROVIDER_CLIENT_ID"},
|
||||
Usage: "The client id to be used for oauth",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth_provider_client_secret",
|
||||
EnvVars: []string{"MICRO_AUTH_PROVIDER_CLIENT_SECRET"},
|
||||
Usage: "The client secret to be used for oauth",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth_provider_endpoint",
|
||||
EnvVars: []string{"MICRO_AUTH_PROVIDER_ENDPOINT"},
|
||||
Usage: "The enpoint to be used for oauth",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth_provider_redirect",
|
||||
EnvVars: []string{"MICRO_AUTH_PROVIDER_REDIRECT"},
|
||||
Usage: "The redirect to be used for oauth",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "auth_provider_scope",
|
||||
EnvVars: []string{"MICRO_AUTH_PROVIDER_SCOPE"},
|
||||
Usage: "The scope to be used for oauth",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "config",
|
||||
EnvVars: []string{"MICRO_CONFIG"},
|
||||
@ -371,11 +336,6 @@ var (
|
||||
"jwt": jwtAuth.NewAuth,
|
||||
}
|
||||
|
||||
DefaultAuthProviders = map[string]func(...provider.Option) provider.Provider{
|
||||
"oauth": oauth.NewProvider,
|
||||
"basic": basic.NewProvider,
|
||||
}
|
||||
|
||||
DefaultProfiles = map[string]func(...profile.Option) profile.Profile{
|
||||
"http": http.NewProfile,
|
||||
"pprof": pprof.NewProfile,
|
||||
@ -528,30 +488,6 @@ func (c *cmd) Before(ctx *cli.Context) error {
|
||||
if len(ctx.String("auth_namespace")) > 0 {
|
||||
authOpts = append(authOpts, auth.Namespace(ctx.String("auth_namespace")))
|
||||
}
|
||||
if name := ctx.String("auth_provider"); len(name) > 0 {
|
||||
p, ok := DefaultAuthProviders[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("AuthProvider %s not found", name)
|
||||
}
|
||||
|
||||
var provOpts []provider.Option
|
||||
clientID := ctx.String("auth_provider_client_id")
|
||||
clientSecret := ctx.String("auth_provider_client_secret")
|
||||
if len(clientID) > 0 || len(clientSecret) > 0 {
|
||||
provOpts = append(provOpts, provider.Credentials(clientID, clientSecret))
|
||||
}
|
||||
if e := ctx.String("auth_provider_endpoint"); len(e) > 0 {
|
||||
provOpts = append(provOpts, provider.Endpoint(e))
|
||||
}
|
||||
if r := ctx.String("auth_provider_redirect"); len(r) > 0 {
|
||||
provOpts = append(provOpts, provider.Redirect(r))
|
||||
}
|
||||
if s := ctx.String("auth_provider_scope"); len(s) > 0 {
|
||||
provOpts = append(provOpts, provider.Scope(s))
|
||||
}
|
||||
|
||||
authOpts = append(authOpts, auth.Provider(p(provOpts...)))
|
||||
}
|
||||
|
||||
// Set the registry
|
||||
if name := ctx.String("registry"); len(name) > 0 && (*c.opts.Registry).String() != name {
|
||||
|
Loading…
Reference in New Issue
Block a user