This repository has been archived by the owner on Jan 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update config add desktop client with all localhost ports Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
- Loading branch information
Showing
23 changed files
with
3,930 additions
and
1,026 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"os/signal" | ||
"path" | ||
"time" | ||
|
||
"github.com/cs3org/reva/cmd/revad/runtime" | ||
"github.com/gofrs/uuid" | ||
"github.com/micro/cli" | ||
"github.com/oklog/run" | ||
"github.com/owncloud/ocis-reva/pkg/config" | ||
"github.com/owncloud/ocis-reva/pkg/flagset" | ||
"github.com/owncloud/ocis-reva/pkg/server/debug" | ||
) | ||
|
||
// AuthBasic is the entrypoint for the auth-basic command. | ||
func AuthBasic(cfg *config.Config) cli.Command { | ||
return cli.Command{ | ||
Name: "auth-basic", | ||
Usage: "Start reva authprovider for basic auth", | ||
Flags: flagset.ServerWithConfig(cfg), | ||
Action: func(c *cli.Context) error { | ||
logger := NewLogger(cfg) | ||
|
||
if cfg.Tracing.Enabled { | ||
switch t := cfg.Tracing.Type; t { | ||
case "agent": | ||
logger.Error(). | ||
Str("type", t). | ||
Msg("Reva only supports the jaeger tracing backend") | ||
|
||
case "jaeger": | ||
logger.Info(). | ||
Str("type", t). | ||
Msg("configuring reva to use the jaeger tracing backend") | ||
|
||
case "zipkin": | ||
logger.Error(). | ||
Str("type", t). | ||
Msg("Reva only supports the jaeger tracing backend") | ||
|
||
default: | ||
logger.Warn(). | ||
Str("type", t). | ||
Msg("Unknown tracing backend") | ||
} | ||
|
||
} else { | ||
logger.Debug(). | ||
Msg("Tracing is not enabled") | ||
} | ||
|
||
var ( | ||
gr = run.Group{} | ||
ctx, cancel = context.WithCancel(context.Background()) | ||
//metrics = metrics.New() | ||
) | ||
|
||
defer cancel() | ||
|
||
{ | ||
|
||
uuid := uuid.Must(uuid.NewV4()) | ||
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") | ||
|
||
rcfg := map[string]interface{}{ | ||
"core": map[string]interface{}{ | ||
"max_cpus": cfg.Reva.AuthBasic.MaxCPUs, | ||
}, | ||
"grpc": map[string]interface{}{ | ||
"network": cfg.Reva.AuthBasic.Network, | ||
"address": cfg.Reva.AuthBasic.Addr, | ||
// TODO extract interceptor config, which is the same for all grpc services | ||
"interceptors": map[string]interface{}{ | ||
"auth": map[string]interface{}{ | ||
"token_manager": "jwt", | ||
"token_managers": map[string]interface{}{ | ||
"jwt": map[string]interface{}{ | ||
"secret": cfg.Reva.JWTSecret, | ||
}, | ||
}, | ||
}, | ||
}, | ||
// TODO build services dynamically | ||
"services": map[string]interface{}{ | ||
"authprovider": map[string]interface{}{ | ||
"auth_manager": cfg.Reva.Users.Driver, | ||
"auth_managers": map[string]interface{}{ | ||
"json": map[string]interface{}{ | ||
"users": cfg.Reva.Users.JSON, | ||
}, | ||
"ldap": map[string]interface{}{ | ||
"hostname": cfg.Reva.LDAP.Hostname, | ||
"port": cfg.Reva.LDAP.Port, | ||
"base_dn": cfg.Reva.LDAP.BaseDN, | ||
"userfilter": cfg.Reva.LDAP.UserFilter, | ||
"groupfilter": cfg.Reva.LDAP.GroupFilter, | ||
"bind_username": cfg.Reva.LDAP.BindDN, | ||
"bind_password": cfg.Reva.LDAP.BindPassword, | ||
"idp": cfg.Reva.LDAP.IDP, | ||
"schema": map[string]interface{}{ | ||
"dn": "dn", | ||
"uid": cfg.Reva.LDAP.Schema.UID, | ||
"mail": cfg.Reva.LDAP.Schema.Mail, | ||
"displayName": cfg.Reva.LDAP.Schema.DisplayName, | ||
"cn": cfg.Reva.LDAP.Schema.CN, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
gr.Add(func() error { | ||
runtime.Run(rcfg, pidFile) | ||
return nil | ||
}, func(_ error) { | ||
logger.Info(). | ||
Str("server", c.Command.Name). | ||
Msg("Shutting down server") | ||
|
||
cancel() | ||
}) | ||
} | ||
|
||
{ | ||
server, err := debug.Server( | ||
debug.Name(c.Command.Name+"-debug"), | ||
debug.Addr(cfg.Reva.AuthBasic.DebugAddr), | ||
debug.Logger(logger), | ||
debug.Context(ctx), | ||
debug.Config(cfg), | ||
) | ||
|
||
if err != nil { | ||
logger.Info(). | ||
Err(err). | ||
Str("server", "debug"). | ||
Msg("Failed to initialize server") | ||
|
||
return err | ||
} | ||
|
||
gr.Add(func() error { | ||
return server.ListenAndServe() | ||
}, func(_ error) { | ||
ctx, timeout := context.WithTimeout(ctx, 5*time.Second) | ||
|
||
defer timeout() | ||
defer cancel() | ||
|
||
if err := server.Shutdown(ctx); err != nil { | ||
logger.Info(). | ||
Err(err). | ||
Str("server", "debug"). | ||
Msg("Failed to shutdown server") | ||
} else { | ||
logger.Info(). | ||
Str("server", "debug"). | ||
Msg("Shutting down server") | ||
} | ||
}) | ||
} | ||
|
||
{ | ||
stop := make(chan os.Signal, 1) | ||
|
||
gr.Add(func() error { | ||
signal.Notify(stop, os.Interrupt) | ||
|
||
<-stop | ||
|
||
return nil | ||
}, func(err error) { | ||
close(stop) | ||
cancel() | ||
}) | ||
} | ||
|
||
return gr.Run() | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.