mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-06-23 11:50:13 +00:00
feat: inject runtime helpers to controllers and services
This commit is contained in:
@@ -28,6 +28,7 @@ type OAuthController struct {
|
||||
config *model.Config
|
||||
runtime *model.RuntimeConfig
|
||||
auth *service.AuthService
|
||||
helpers *model.RuntimeHelpers
|
||||
}
|
||||
|
||||
type OAuthControllerInput struct {
|
||||
@@ -36,6 +37,7 @@ type OAuthControllerInput struct {
|
||||
Log *logger.Logger
|
||||
Config *model.Config
|
||||
RuntimeConfig *model.RuntimeConfig
|
||||
Helpers *model.RuntimeHelpers
|
||||
RouterGroup *gin.RouterGroup `name:"apiRouterGroup"`
|
||||
AuthService *service.AuthService
|
||||
}
|
||||
@@ -46,6 +48,7 @@ func NewOAuthController(i OAuthControllerInput) *OAuthController {
|
||||
config: i.Config,
|
||||
runtime: i.RuntimeConfig,
|
||||
auth: i.AuthService,
|
||||
helpers: i.Helpers,
|
||||
}
|
||||
|
||||
oauthGroup := i.RouterGroup.Group("/oauth")
|
||||
|
||||
@@ -35,6 +35,8 @@ type OIDCController struct {
|
||||
log *logger.Logger
|
||||
oidc *service.OIDCService
|
||||
runtime *model.RuntimeConfig
|
||||
helpers *model.RuntimeHelpers
|
||||
config *model.Config
|
||||
}
|
||||
|
||||
type AuthorizeCallback struct {
|
||||
@@ -91,6 +93,8 @@ type OIDCControllerInput struct {
|
||||
RuntimeConfig *model.RuntimeConfig
|
||||
RouterGroup *gin.RouterGroup `name:"apiRouterGroup"`
|
||||
MainRouter *gin.RouterGroup `name:"mainRouterGroup"`
|
||||
Helpers *model.RuntimeHelpers
|
||||
Config *model.Config
|
||||
}
|
||||
|
||||
func NewOIDCController(i OIDCControllerInput) *OIDCController {
|
||||
@@ -98,6 +102,8 @@ func NewOIDCController(i OIDCControllerInput) *OIDCController {
|
||||
log: i.Log,
|
||||
oidc: i.OIDCService,
|
||||
runtime: i.RuntimeConfig,
|
||||
helpers: i.Helpers,
|
||||
config: i.Config,
|
||||
}
|
||||
|
||||
i.MainRouter.POST("/authorize", controller.authorize)
|
||||
|
||||
@@ -864,6 +864,8 @@ func TestOIDCController(t *testing.T) {
|
||||
RuntimeConfig: &runtime,
|
||||
RouterGroup: group,
|
||||
MainRouter: &router.RouterGroup,
|
||||
Helpers: helpers,
|
||||
Config: &cfg,
|
||||
})
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
|
||||
@@ -721,6 +721,7 @@ func TestProxyController(t *testing.T) {
|
||||
OAuthBroker: broker,
|
||||
Tailscale: nil,
|
||||
PolicyEngine: policyEngine,
|
||||
Helpers: helpers,
|
||||
})
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
@@ -555,6 +555,7 @@ func TestUserController(t *testing.T) {
|
||||
OAuthBroker: broker,
|
||||
Tailscale: nil,
|
||||
PolicyEngine: policyEngine,
|
||||
Helpers: helpers,
|
||||
})
|
||||
|
||||
beforeEach := func() {
|
||||
|
||||
Reference in New Issue
Block a user