Cleanup options, remove obsolete, rename jwt to auth
This commit is contained in:
+1
-2
@@ -56,8 +56,7 @@ func (app *App) Upgrade(ctx context.Context) (err error) {
|
||||
func (app *App) Initialize(ctx context.Context) (err error) {
|
||||
// Connects to all services it needs to
|
||||
err = service.Initialize(ctx, app.Log, service.Config{
|
||||
Storage: app.Opts.Storage,
|
||||
Corredor: app.Opts.Corredor,
|
||||
Storage: app.Opts.Storage,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -27,7 +27,6 @@ type (
|
||||
|
||||
Config struct {
|
||||
Storage options.StorageOpt
|
||||
Corredor options.CorredorOpt
|
||||
GRPCClientSystem options.GRPCServerOpt
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ func (app *App) Setup(log *zap.Logger, opts *app.Options) (err error) {
|
||||
// that might occur inside auth, mail setup...
|
||||
defer sentry.Recover()
|
||||
|
||||
auth.SetupDefault(opts.JWT.Secret, int(opts.JWT.Expiry/time.Minute))
|
||||
auth.SetupDefault(opts.Auth.Secret, int(opts.Auth.Expiry/time.Minute))
|
||||
mail.SetupDialer(opts.SMTP.Host, opts.SMTP.Port, opts.SMTP.User, opts.SMTP.Pass, opts.SMTP.From)
|
||||
|
||||
http.SetupDefaults(
|
||||
|
||||
+1
-2
@@ -63,8 +63,7 @@ func (app *App) Upgrade(ctx context.Context) (err error) {
|
||||
func (app *App) Initialize(ctx context.Context) (err error) {
|
||||
// Connects to all services it needs to
|
||||
err = service.Initialize(ctx, app.Log, service.Config{
|
||||
Storage: app.Opts.Storage,
|
||||
Corredor: app.Opts.Corredor,
|
||||
Storage: app.Opts.Storage,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -29,8 +29,7 @@ type (
|
||||
}
|
||||
|
||||
Config struct {
|
||||
Storage options.StorageOpt
|
||||
Corredor options.CorredorOpt
|
||||
Storage options.StorageOpt
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ import (
|
||||
type (
|
||||
Options struct {
|
||||
SMTP options.SMTPOpt
|
||||
JWT options.JWTOpt
|
||||
Auth options.AuthOpt
|
||||
HTTPClient options.HTTPClientOpt
|
||||
DB options.DBOpt
|
||||
Upgrade options.UpgradeOpt
|
||||
@@ -30,8 +30,8 @@ func NewOptions(prefix ...string) *Options {
|
||||
}
|
||||
|
||||
return &Options{
|
||||
Auth: *options.Auth(),
|
||||
SMTP: *options.SMTP(p),
|
||||
JWT: *options.JWT(p),
|
||||
HTTPClient: *options.HttpClient(p),
|
||||
DB: *options.DB(p),
|
||||
Upgrade: *options.Upgrade(p),
|
||||
|
||||
@@ -17,12 +17,16 @@ type (
|
||||
MaxBackoffDelay time.Duration `env:"CORREDOR_MAX_BACKOFF_DELAY"`
|
||||
|
||||
DefaultExecTimeout time.Duration `env:"CORREDOR_DEFAULT_EXEC_TIMEOUT"`
|
||||
|
||||
// Allow scripts to have runner explicitly defined
|
||||
RunAsEnabled bool `env:"CORREDOR_RUN_AS_ENABLED"`
|
||||
}
|
||||
)
|
||||
|
||||
func Corredor(pfix string) (o *CorredorOpt) {
|
||||
o = &CorredorOpt{
|
||||
Enabled: true,
|
||||
RunAsEnabled: true,
|
||||
Addr: "corredor:80",
|
||||
MaxBackoffDelay: time.Minute,
|
||||
DefaultExecTimeout: time.Minute,
|
||||
|
||||
@@ -7,20 +7,24 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
JWTOpt struct {
|
||||
AuthOpt struct {
|
||||
Secret string `env:"AUTH_JWT_SECRET"`
|
||||
Expiry time.Duration `env:"AUTH_JWT_EXPIRY"`
|
||||
}
|
||||
)
|
||||
|
||||
func JWT(pfix string) (o *JWTOpt) {
|
||||
o = &JWTOpt{
|
||||
func Auth() (o *AuthOpt) {
|
||||
o = &AuthOpt{
|
||||
Expiry: time.Hour * 24 * 30,
|
||||
}
|
||||
|
||||
fill(o, pfix)
|
||||
fill(o, "")
|
||||
|
||||
// Setting JWT secret to random string to prevent security accidents...
|
||||
//
|
||||
// @todo check if this is a monolith system
|
||||
// on microservice setup we can not afford to autogenerate secret:
|
||||
// each subsystem will get it's own
|
||||
if o.Secret == "" {
|
||||
o.Secret = string(rand.Bytes(32))
|
||||
}
|
||||
|
||||
+1
-2
@@ -59,8 +59,7 @@ func (app *App) Upgrade(ctx context.Context) (err error) {
|
||||
func (app *App) Initialize(ctx context.Context) (err error) {
|
||||
// Connects to all services it needs to
|
||||
err = service.Initialize(ctx, app.Log, service.Config{
|
||||
Storage: app.Opts.Storage,
|
||||
Corredor: app.Opts.Corredor,
|
||||
Storage: app.Opts.Storage,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -26,7 +26,6 @@ type (
|
||||
|
||||
Config struct {
|
||||
Storage options.StorageOpt
|
||||
Corredor options.CorredorOpt
|
||||
GRPCClientSystem options.GRPCServerOpt
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ func NewIntegrationTestApp(service string, parts ...app.Runnable) app.Runnable {
|
||||
opt.Upgrade.Always = true
|
||||
|
||||
// Create a new JWT secret (to prevent any security weirdness)
|
||||
opt.JWT.Secret = string(rand.Bytes(32))
|
||||
opt.JWT.Expiry = time.Minute
|
||||
opt.Auth.Secret = string(rand.Bytes(32))
|
||||
opt.Auth.Expiry = time.Minute
|
||||
|
||||
logger.DefaultLevel.SetLevel(zap.DebugLevel)
|
||||
log := logger.MakeDebugLogger()
|
||||
|
||||
Reference in New Issue
Block a user