mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-03-13 18:22:02 +00:00
wip
This commit is contained in:
@@ -45,6 +45,7 @@ func (app *BootstrapApp) Setup() error {
|
||||
if app.config.Auth.SessionMaxLifetime != 0 && app.config.Auth.SessionMaxLifetime < app.config.Auth.SessionExpiry {
|
||||
return fmt.Errorf("session max lifetime cannot be less than session expiry")
|
||||
}
|
||||
|
||||
// Parse users
|
||||
users, err := utils.GetUsers(app.config.Auth.Users, app.config.Auth.UsersFile)
|
||||
|
||||
@@ -203,6 +204,19 @@ func (app *BootstrapApp) Setup() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If we have tailscale configured, we will listen on it
|
||||
if app.services.tailscaleService.IsConfigured() {
|
||||
ln, err := app.services.tailscaleService.CreateListener()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create listener: %w", err)
|
||||
}
|
||||
|
||||
if err := router.RunListener(ln); err != nil {
|
||||
tlog.App.Fatal().Err(err).Msg("Failed to start tailscale listener")
|
||||
}
|
||||
}
|
||||
|
||||
// Start server
|
||||
address := fmt.Sprintf("%s:%d", app.config.Server.Address, app.config.Server.Port)
|
||||
tlog.App.Info().Msgf("Starting server on %s", address)
|
||||
|
||||
@@ -12,6 +12,7 @@ type Services struct {
|
||||
dockerService *service.DockerService
|
||||
ldapService *service.LdapService
|
||||
oauthBrokerService *service.OAuthBrokerService
|
||||
tailscaleService *service.TailscaleService
|
||||
}
|
||||
|
||||
func (app *BootstrapApp) initServices(queries *repository.Queries) (Services, error) {
|
||||
@@ -36,6 +37,19 @@ func (app *BootstrapApp) initServices(queries *repository.Queries) (Services, er
|
||||
tlog.App.Warn().Err(err).Msg("Failed to initialize LDAP service, continuing without it")
|
||||
}
|
||||
|
||||
tailscaleService := service.NewTailscaleService(service.TailscaleServiceConfig{
|
||||
AuthKey: app.config.Tailscale.AuthKey,
|
||||
Hostname: app.config.Tailscale.Hostname,
|
||||
})
|
||||
|
||||
err = tailscaleService.Init()
|
||||
|
||||
if err != nil {
|
||||
return Services{}, err
|
||||
}
|
||||
|
||||
services.tailscaleService = tailscaleService
|
||||
|
||||
dockerService := service.NewDockerService()
|
||||
|
||||
err = dockerService.Init()
|
||||
@@ -68,7 +82,7 @@ func (app *BootstrapApp) initServices(queries *repository.Queries) (Services, er
|
||||
SessionCookieName: app.context.sessionCookieName,
|
||||
IP: app.config.Auth.IP,
|
||||
LDAPGroupsCacheTTL: app.config.Ldap.GroupCacheTTL,
|
||||
}, dockerService, services.ldapService, queries)
|
||||
}, dockerService, services.ldapService, services.tailscaleService, queries)
|
||||
|
||||
err = authService.Init()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user