Skip to content

Commit 8426db3

Browse files
committed
chore: rabbit comments
1 parent 4b323d0 commit 8426db3

8 files changed

Lines changed: 23 additions & 25 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ require (
2121
github.com/stretchr/testify v1.11.1
2222
github.com/tinyauthapp/paerser v0.0.0-20260410140347-85c3740d6298
2323
github.com/weppos/publicsuffix-go v0.50.3
24+
go.uber.org/dig v1.19.0
2425
golang.org/x/crypto v0.52.0
2526
golang.org/x/oauth2 v0.36.0
2627
golang.org/x/tools v0.45.0
@@ -152,7 +153,6 @@ require (
152153
go.opentelemetry.io/otel/sdk v1.43.0 // indirect
153154
go.opentelemetry.io/otel/sdk/metric v1.43.0 // indirect
154155
go.opentelemetry.io/otel/trace v1.43.0 // indirect
155-
go.uber.org/dig v1.19.0 // indirect
156156
go.yaml.in/yaml/v2 v2.4.3 // indirect
157157
go4.org/mem v0.0.0-20240501181205-ae6ca9944745 // indirect
158158
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect

internal/bootstrap/app_bootstrap.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,6 @@ func (app *BootstrapApp) Setup() error {
163163
app.runtime.OAuthProviders[id] = provider
164164
}
165165

166-
// setup oidc clients
167-
for id, client := range app.config.OIDC.Clients {
168-
client.ID = id
169-
app.runtime.OIDCClients = append(app.runtime.OIDCClients, client)
170-
}
171-
172166
// cookie domain
173167
cookieDomainResolver := utils.GetCookieDomain
174168

internal/bootstrap/service_bootstrap.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,11 @@ func (app *BootstrapApp) setupServices() error {
7171
}
7272

7373
err = app.dig.Invoke(func(i svcInput) error {
74-
app.services = Services{
75-
accessControlService: i.AccessControlService,
76-
authService: i.AuthService,
77-
ldapService: i.LDAPService,
78-
oauthBrokerService: i.OAuthBrokerService,
79-
tailscaleService: i.TailscaleService,
80-
}
74+
app.services.accessControlService = i.AccessControlService
75+
app.services.authService = i.AuthService
76+
app.services.ldapService = i.LDAPService
77+
app.services.oauthBrokerService = i.OAuthBrokerService
78+
app.services.tailscaleService = i.TailscaleService
8179
return nil
8280
})
8381

internal/controller/well_known_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type WellKnownControllerInput struct {
3535
dig.In
3636

3737
OIDCService *service.OIDCService
38-
RouterGroup *gin.RouterGroup `name:"apiRouterGroup"`
38+
RouterGroup *gin.RouterGroup `name:"mainRouterGroup"`
3939
}
4040

4141
func NewWellKnownController(i WellKnownControllerInput) *WellKnownController {

internal/model/runtime.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ type RuntimeConfig struct {
1212
OAuthProviders map[string]OAuthServiceConfig
1313
OAuthWhitelist []string
1414
ConfiguredProviders []Provider
15-
OIDCClients []OIDCClientConfig
1615
TrustedDomains []string
1716
}
1817

internal/service/auth_service_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55

66
"github.com/stretchr/testify/assert"
7+
"github.com/stretchr/testify/require"
78
"github.com/tinyauthapp/tinyauth/internal/model"
89
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
910
)
@@ -12,6 +13,19 @@ func TestIsEmailWhitelistedUsesProviderSpecificList(t *testing.T) {
1213
log := logger.NewLogger().WithTestConfig()
1314
log.Init()
1415

16+
policyEngine, err := NewPolicyEngine(PolicyEngineInput{
17+
Log: log,
18+
Config: &model.Config{
19+
Auth: model.AuthConfig{
20+
ACLs: model.ACLsConfig{
21+
Policy: string(PolicyAllow),
22+
},
23+
},
24+
},
25+
})
26+
27+
require.NoError(t, err)
28+
1529
auth := &AuthService{
1630
log: log,
1731
runtime: &model.RuntimeConfig{
@@ -28,6 +42,7 @@ func TestIsEmailWhitelistedUsesProviderSpecificList(t *testing.T) {
2842
},
2943
},
3044
},
45+
policyEngine: policyEngine,
3146
}
3247

3348
assert.True(t, auth.IsEmailWhitelisted("github", "github@example.com"))

internal/service/oidc_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ type OIDCServiceInput struct {
163163

164164
func NewOIDCService(i OIDCServiceInput) (*OIDCService, error) {
165165
// If not configured, skip init
166-
if len(i.Runtime.OIDCClients) == 0 {
166+
if len(i.Config.OIDC.Clients) == 0 {
167167
return nil, nil
168168
}
169169

internal/test/test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,6 @@ func CreateTestConfigs(t *testing.T) (model.Config, model.RuntimeConfig) {
121121
CookieDomain: "example.com",
122122
AppURL: "https://tinyauth.example.com",
123123
SessionCookieName: "tinyauth-session",
124-
OIDCClients: func() []model.OIDCClientConfig {
125-
var clients []model.OIDCClientConfig
126-
for id, client := range config.OIDC.Clients {
127-
client.ID = id
128-
clients = append(clients, client)
129-
}
130-
return clients
131-
}(),
132124
}
133125

134126
return config, runtime

0 commit comments

Comments
 (0)