@@ -4,21 +4,11 @@ import (
44 "fmt"
55 "os"
66
7- "github.com/tinyauthapp/tinyauth/internal/model"
87 "github.com/tinyauthapp/tinyauth/internal/service"
98)
109
1110func (app * BootstrapApp ) setupServices () error {
12- ldapService := service .NewLdapService (service.LdapServiceConfig {
13- Address : app .config .LDAP .Address ,
14- BindDN : app .config .LDAP .BindDN ,
15- BindPassword : app .config .LDAP .BindPassword ,
16- BaseDN : app .config .LDAP .BaseDN ,
17- Insecure : app .config .LDAP .Insecure ,
18- SearchFilter : app .config .LDAP .SearchFilter ,
19- AuthCert : app .config .LDAP .AuthCert ,
20- AuthKey : app .config .LDAP .AuthKey ,
21- })
11+ ldapService := service .NewLdapService (app .log , app .config , app .ctx )
2212
2313 err := ldapService .Init ()
2414
@@ -32,10 +22,12 @@ func (app *BootstrapApp) setupServices() error {
3222 useKubernetes := app .config .LabelProvider == "kubernetes" ||
3323 (app .config .LabelProvider == "auto" && os .Getenv ("KUBERNETES_SERVICE_HOST" ) != "" )
3424
25+ var labelProvider service.LabelProviderImpl
26+
3527 if useKubernetes {
3628 app .log .App .Debug ().Msg ("Using Kubernetes label provider" )
3729
38- kubernetesService := service .NewKubernetesService ()
30+ kubernetesService := service .NewKubernetesService (app . log , app . ctx )
3931
4032 err = kubernetesService .Init ()
4133
@@ -44,11 +36,11 @@ func (app *BootstrapApp) setupServices() error {
4436 }
4537
4638 app .services .kubernetesService = kubernetesService
47- app . runtime . LabelProvider = model . LabelProviderKubernetes
39+ labelProvider = kubernetesService
4840 } else {
4941 app .log .App .Debug ().Msg ("Using Docker label provider" )
5042
51- dockerService := service .NewDockerService ()
43+ dockerService := service .NewDockerService (app . log , app . ctx )
5244
5345 err = dockerService .Init ()
5446
@@ -57,10 +49,10 @@ func (app *BootstrapApp) setupServices() error {
5749 }
5850
5951 app .services .dockerService = dockerService
60- app . runtime . LabelProvider = model . LabelProviderDocker
52+ labelProvider = dockerService
6153 }
6254
63- accessControlsService := service .NewAccessControlsService (app .runtime . LabelProvider , app .config .Apps )
55+ accessControlsService := service .NewAccessControlsService (app .log , labelProvider , app .config .Apps )
6456
6557 err = accessControlsService .Init ()
6658
@@ -70,7 +62,7 @@ func (app *BootstrapApp) setupServices() error {
7062
7163 app .services .accessControlService = accessControlsService
7264
73- oauthBrokerService := service .NewOAuthBrokerService (app .runtime .OAuthProviders )
65+ oauthBrokerService := service .NewOAuthBrokerService (app .log , app . runtime .OAuthProviders )
7466
7567 err = oauthBrokerService .Init ()
7668
@@ -80,20 +72,7 @@ func (app *BootstrapApp) setupServices() error {
8072
8173 app .services .oauthBrokerService = oauthBrokerService
8274
83- authService := service .NewAuthService (service.AuthServiceConfig {
84- LocalUsers : & app .runtime .LocalUsers ,
85- OauthWhitelist : app .runtime .OAuthWhitelist ,
86- SessionExpiry : app .config .Auth .SessionExpiry ,
87- SessionMaxLifetime : app .config .Auth .SessionMaxLifetime ,
88- SecureCookie : app .config .Auth .SecureCookie ,
89- CookieDomain : app .runtime .CookieDomain ,
90- LoginTimeout : app .config .Auth .LoginTimeout ,
91- LoginMaxRetries : app .config .Auth .LoginMaxRetries ,
92- SessionCookieName : app .runtime .SessionCookieName ,
93- IP : app .config .Auth .IP ,
94- LDAPGroupsCacheTTL : app .config .LDAP .GroupCacheTTL ,
95- SubdomainsEnabled : app .config .Auth .SubdomainsEnabled ,
96- }, app .services .ldapService , app .queries , app .services .oauthBrokerService )
75+ authService := service .NewAuthService (app .log , app .config , app .runtime , app .ctx , app .services .ldapService , app .queries , app .services .oauthBrokerService )
9776
9877 err = authService .Init ()
9978
@@ -103,13 +82,7 @@ func (app *BootstrapApp) setupServices() error {
10382
10483 app .services .authService = authService
10584
106- oidcService := service .NewOIDCService (service.OIDCServiceConfig {
107- Clients : app .config .OIDC .Clients ,
108- PrivateKeyPath : app .config .OIDC .PrivateKeyPath ,
109- PublicKeyPath : app .config .OIDC .PublicKeyPath ,
110- Issuer : app .config .AppURL ,
111- SessionExpiry : app .config .Auth .SessionExpiry ,
112- }, app .queries )
85+ oidcService := service .NewOIDCService (app .log , app .config , app .runtime , app .queries , app .ctx )
11386
11487 err = oidcService .Init ()
11588
0 commit comments