fix: custom check middleware enabling

This commit is contained in:
janishutz committed 2026-09-28 11:50:26 +02:00
1 parent 6bcaff2d88
commit d6a551d80f
1 file changed
+19 -4
+19 -4
View File
@@ -32,14 +32,29 @@ var (
// Wraps the normal configure function, but also gives you access to change the User Function, which is called upon login.
// It is used to create or update a user.
// The check middleware may be nil, in which case a default is used. Otherwise should be a valid gin middleware, calling c.Next() if okay to proceed.
func ConfigureFull(r *gin.Engine, app_url string, default_redirect string, user_function UserFunc, stubs_on_unconfigured bool, check_middleware func(c *gin.Context)) {
func ConfigureFull(
r *gin.Engine,
app_url string,
default_redirect string,
user_function UserFunc,
stubs_on_unconfigured bool,
use_custom_check_middleware bool,
check_middleware func(c *gin.Context),
) {
userFunc = user_function
Configure(r, app_url, default_redirect, stubs_on_unconfigured, check_middleware)
Configure(r, app_url, default_redirect, stubs_on_unconfigured, use_custom_check_middleware, check_middleware)
}
// Configure and set up the login SDK
// The check middleware may be nil, in which case a default is used. Otherwise should be a valid gin middleware, calling c.Next() if okay to proceed.
func Configure(r *gin.Engine, app_url string, default_redirect string, stubs_on_unconfigured bool, check_middleware func(c *gin.Context)) {
func Configure(
r *gin.Engine,
app_url string,
default_redirect string,
stubs_on_unconfigured bool,
use_custom_check_middleware bool,
check_middleware func(c *gin.Context),
) {
issuer := os.Getenv("OIDC_ISSUER")
clientID := os.Getenv("OIDC_CLIENT_ID")
clientSecret := os.Getenv("OIDC_CLIENT_SECRET")
@@ -73,7 +88,7 @@ func Configure(r *gin.Engine, app_url string, default_redirect string, stubs_on_
r.GET("/auth/v2/login", loginHandler)
r.GET("/auth/v2/verify", callbackHandler)
check_finalizer := func(ctx *gin.Context) { ctx.JSON(200, gin.H{"success": "true"}) }
if check_middleware == nil {
if use_custom_check_middleware {
r.GET("/auth/v2/check", EnsureLogin(false), check_finalizer)
} else {
log.Println("[JHID] Custom check middleware enabled")