Merge pull request #12 from owncloud/ocis-single-binary-defaults

Change default settings to be able to run ocis server without any con…
This commit is contained in:
Michael Barz
2020-03-18 21:36:16 +01:00
committed by GitHub
6 changed files with 170 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package command
import (
"context"
"github.com/owncloud/ocis-glauth/pkg/crypto"
"os"
"os/signal"
"strings"
@@ -245,6 +246,14 @@ func Server(cfg *config.Config) *cli.Command {
},
},
}
if cfg.LDAPS.Enabled {
// GenCert has side effects as it writes 2 files to the binary running location
if err := crypto.GenCert("ldap.crt", "ldap.key", logger); err != nil {
logger.Fatal().Err(err).Msgf("Could not generate test-certificate")
}
}
server, err := glauth.NewServer(
glauth.Logger(log),
glauth.Config(&cfg),
@@ -267,6 +276,7 @@ func Server(cfg *config.Config) *cli.Command {
case err <- server.ListenAndServe():
return <-err
}
}, func(_ error) {
logger.Info().
Str("transport", "ldap").
@@ -276,6 +286,24 @@ func Server(cfg *config.Config) *cli.Command {
cancel()
})
gr.Add(func() error {
err := make(chan error)
select {
case <-ctx.Done():
return nil
case err <- server.ListenAndServeTLS():
return <-err
}
}, func(_ error) {
logger.Info().
Str("transport", "ldaps").
Msg("Shutting down server")
server.Shutdown()
cancel()
})
}
{