actually start glauth server

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2020-02-28 09:57:42 +01:00
parent 488a95735f
commit 460cde921d
5 changed files with 160 additions and 33 deletions
+29 -3
View File
@@ -2,7 +2,6 @@ package command
import (
"context"
"errors"
"os"
"os/signal"
"strings"
@@ -11,8 +10,11 @@ import (
"contrib.go.opencensus.io/exporter/jaeger"
"contrib.go.opencensus.io/exporter/ocagent"
"contrib.go.opencensus.io/exporter/zipkin"
glauthcfg "github.com/glauth/glauth/pkg/config"
glauth "github.com/glauth/glauth/pkg/server"
"github.com/micro/cli/v2"
"github.com/oklog/run"
glauthlog "github.com/op/go-logging"
openzipkin "github.com/openzipkin/zipkin-go"
zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http"
"github.com/owncloud/ocis-glauth/pkg/config"
@@ -33,6 +35,8 @@ func Server(cfg *config.Config) *cli.Command {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
cfg.Backend.Servers = c.StringSlice("backend-server")
return nil
},
Action: func(c *cli.Context) error {
@@ -131,8 +135,30 @@ func Server(cfg *config.Config) *cli.Command {
defer cancel()
{
log := glauthlog.MustGetLogger("ocis-glauth")
cfg := glauthcfg.Config{
LDAP: glauthcfg.LDAP{
Enabled: cfg.Ldap.Enabled,
Listen: cfg.Ldap.Address,
},
LDAPS: glauthcfg.LDAPS{
Enabled: cfg.Ldaps.Enabled,
Listen: cfg.Ldaps.Address,
},
Backend: glauthcfg.Backend{
Datastore: cfg.Backend.Datastore,
BaseDN: cfg.Backend.BaseDN,
Insecure: cfg.Backend.Insecure,
NameFormat: cfg.Backend.NameFormat,
GroupFormat: cfg.Backend.GroupFormat,
Servers: cfg.Backend.Servers,
SSHKeyAttr: cfg.Backend.SSHKeyAttr,
UseGraphAPI: cfg.Backend.UseGraphAPI,
},
}
server, err := glauth.NewServer(log, &cfg)
//XXX(deepdiver) start ldap server
err := errors.New("not implemented yet")
//err := errors.New("not implemented yet")
if err != nil {
logger.Info().
@@ -144,7 +170,7 @@ func Server(cfg *config.Config) *cli.Command {
}
gr.Add(func() error {
//return server.Run()
server.ListenAndServe()
return nil
}, func(_ error) {
logger.Info().
+21 -26
View File
@@ -33,37 +33,32 @@ type Tracing struct {
// Ldap defined the available LDAP configuration.
type Ldap struct {
Network string
Address string
UserName string
Password string
BaseDNUsers string
BaseDNGroups string
}
// OpenIDConnect defined the available OpenID Connect configuration.
type OpenIDConnect struct {
Endpoint string
Realm string
SigningAlgs []string
Insecure bool
}
// Reva defines all available REVA configuration.
type Reva struct {
Address string
Enabled bool
}
// Backend defined the available backend configuration.
type Backend struct {
Datastore string
BaseDN string
Insecure bool
NameFormat string
GroupFormat string
Servers []string
SSHKeyAttr string
UseGraphAPI bool
}
// Config combines all available configuration parts.
type Config struct {
File string
Log Log
Debug Debug
HTTP HTTP
Tracing Tracing
Ldap Ldap
OpenIDConnect OpenIDConnect
Reva Reva
File string
Log Log
Debug Debug
HTTP HTTP
Tracing Tracing
Ldap Ldap
Ldaps Ldap
Backend Backend
}
// New initializes a new configuration with or without defaults.
+83 -4
View File
@@ -115,12 +115,91 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"GLAUTH_DEBUG_ZPAGES"},
Destination: &cfg.Debug.Zpages,
},
&cli.StringFlag{
Name: "http-addr",
Name: "ldap-addr",
Value: "0.0.0.0:9125",
Usage: "Address to bind http server",
EnvVars: []string{"GLAUTH_HTTP_ADDR"},
Destination: &cfg.HTTP.Addr,
Usage: "Address to bind ldap server",
EnvVars: []string{"GLAUTH_LDAP_ADDR"},
Destination: &cfg.Ldap.Address,
},
&cli.BoolFlag{
Name: "ldap-enabled",
Value: true,
Usage: "Enable ldap server",
EnvVars: []string{"GLAUTH_LDAP_ENABLED"},
Destination: &cfg.Ldap.Enabled,
},
&cli.StringFlag{
Name: "ldaps-addr",
Value: "0.0.0.0:9126",
Usage: "Address to bind ldap server",
EnvVars: []string{"GLAUTH_LDAPS_ADDR"},
Destination: &cfg.Ldaps.Address,
},
&cli.BoolFlag{
Name: "ldaps-enabled",
Value: false,
Usage: "Enable ldap server",
EnvVars: []string{"GLAUTH_LDAPS_ENABLED"},
Destination: &cfg.Ldaps.Enabled,
},
&cli.StringFlag{
Name: "backend-datastore",
Value: "owncloud",
Usage: "datastore to use as the backend. one of config, ldap or owncloud",
EnvVars: []string{"GLAUTH_BACKEND_DATASTORE"},
Destination: &cfg.Backend.Datastore,
},
&cli.StringFlag{
Name: "backend-basedn",
Value: "dc=owncloud,dc=com",
Usage: "base distinguished name to expose",
EnvVars: []string{"GLAUTH_BACKEND_BASEDN"},
Destination: &cfg.Backend.BaseDN,
},
&cli.BoolFlag{
Name: "backend-insecure",
Value: false,
Usage: "Allow insecure requests to the datastore",
EnvVars: []string{"GLAUTH_BACKEND_INSECURE"},
Destination: &cfg.Backend.Insecure,
},
&cli.StringFlag{
Name: "backend-name-format",
Value: "cn",
Usage: "name attribute for entries to expose. typically cn or uid",
EnvVars: []string{"GLAUTH_BACKEND_NAME_FORMAT"},
Destination: &cfg.Backend.NameFormat,
},
&cli.StringFlag{
Name: "backend-group-format",
Value: "ou",
Usage: "name attribute for entries to expose. typically ou, cn or dc",
EnvVars: []string{"GLAUTH_BACKEND_GROUP_FORMAT"},
Destination: &cfg.Backend.GroupFormat,
},
&cli.StringSliceFlag{
Name: "backend-server",
Value: cli.NewStringSlice("https://demo.owncloud.com"),
Usage: `--backend-servers http://internal1.example.com [--backend-servers http://internal2.example.com]`,
EnvVars: []string{"GLAUTH_BACKEND_SERVERS"},
},
&cli.StringFlag{
Name: "backend-ssh-key-attr",
Value: "sshPublicKey",
Usage: "ssh key attribute for entries to expose",
EnvVars: []string{"GLAUTH_BACKEND_SSH_KEY_ATTR"},
Destination: &cfg.Backend.GroupFormat,
},
&cli.BoolFlag{
Name: "backend-use-graphapi",
Value: true,
Usage: "use Graph API, only for owncloud datastore",
EnvVars: []string{"GLAUTH_BACKEND_USE_GRAPHAPI"},
Destination: &cfg.Backend.UseGraphAPI,
},
}
}