🐛 Fix auth context middleware force provide token
This commit is contained in:
		@@ -6,6 +6,10 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func ContextMiddleware(c *fiber.Ctx) error {
 | 
					func ContextMiddleware(c *fiber.Ctx) error {
 | 
				
			||||||
	atk := tokenExtract(c)
 | 
						atk := tokenExtract(c)
 | 
				
			||||||
 | 
						if len(atk) == 0 {
 | 
				
			||||||
 | 
							return c.Next()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.Locals("nex_in_token", atk)
 | 
						c.Locals("nex_in_token", atk)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if claims, err := tokenRead(atk); err == nil && claims != nil {
 | 
						if claims, err := tokenRead(atk); err == nil && claims != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,8 +8,6 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func MapAPIs(app *fiber.App) {
 | 
					func MapAPIs(app *fiber.App) {
 | 
				
			||||||
	app.Use(auth.ContextMiddleware)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Some built-in public-accessible APIs
 | 
						// Some built-in public-accessible APIs
 | 
				
			||||||
	wellKnown := app.Group("/.well-known").Name("Well Known")
 | 
						wellKnown := app.Group("/.well-known").Name("Well Known")
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package server
 | 
					package server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
 | 
				
			||||||
	"git.solsynth.dev/hypernet/nexus/pkg/internal/http/api"
 | 
						"git.solsynth.dev/hypernet/nexus/pkg/internal/http/api"
 | 
				
			||||||
	"github.com/goccy/go-json"
 | 
						"github.com/goccy/go-json"
 | 
				
			||||||
	"github.com/gofiber/fiber/v2"
 | 
						"github.com/gofiber/fiber/v2"
 | 
				
			||||||
@@ -42,6 +43,8 @@ func NewServer() *HTTPApp {
 | 
				
			|||||||
		Output: log.Logger,
 | 
							Output: log.Logger,
 | 
				
			||||||
	}))
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						app.Use(auth.ContextMiddleware)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	api.MapAPIs(app)
 | 
						api.MapAPIs(app)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &HTTPApp{app}
 | 
						return &HTTPApp{app}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user