Compare commits
	
		
			1 Commits
		
	
	
		
			v0.1.4
			...
			4afa9a01b6
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 4afa9a01b6 | 
@@ -13,11 +13,15 @@ import (
 | 
			
		||||
	"git.t-juice.club/microfilm/auth"
 | 
			
		||||
	"github.com/golang-jwt/jwt/v5"
 | 
			
		||||
	"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
 | 
			
		||||
	"go.opentelemetry.io/otel"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func VerifyToken(authURL string, permittedRoles []string) func(http.Handler) http.Handler {
 | 
			
		||||
	fn := func(next http.Handler) http.Handler {
 | 
			
		||||
		fn := func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
			ctx, span := otel.GetTracerProvider().Tracer("").Start(r.Context(), "verify-token")
 | 
			
		||||
			defer span.End()
 | 
			
		||||
 | 
			
		||||
			authHeader := r.Header.Get("Authorization")
 | 
			
		||||
			if !strings.Contains(authHeader, "Bearer ") {
 | 
			
		||||
				// No token, pass if unathorized in permitted
 | 
			
		||||
@@ -40,7 +44,7 @@ func VerifyToken(authURL string, permittedRoles []string) func(http.Handler) htt
 | 
			
		||||
 | 
			
		||||
			// Fetch current pubkey
 | 
			
		||||
			url := fmt.Sprintf("%s/key", authURL)
 | 
			
		||||
			ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
 | 
			
		||||
			ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
 | 
			
		||||
			defer cancel()
 | 
			
		||||
 | 
			
		||||
			req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
package auth
 | 
			
		||||
 | 
			
		||||
const Version = "v0.1.4"
 | 
			
		||||
const Version = "v0.1.5"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user