From cedcf58ea7d729acb6ed1a9ab7aec1ae38aed102 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 9 Oct 2023 08:56:53 -0600 Subject: more useful tlsauth.Approver type the predicate function should be able to see the whole context and request --- contrib/tlsauth/gemini.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'contrib/tlsauth/gemini.go') diff --git a/contrib/tlsauth/gemini.go b/contrib/tlsauth/gemini.go index 9996595..9bf07bd 100644 --- a/contrib/tlsauth/gemini.go +++ b/contrib/tlsauth/gemini.go @@ -15,11 +15,10 @@ import ( func GeminiAuth(approver Approver) sr.Middleware { return func(inner sr.Handler) sr.Handler { return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response { - identity := Identity(request) - if identity == nil { + if Identity(request) == nil { return geminiMissingCert(ctx, request) } - if !approver(identity) { + if !approver(ctx, request) { return geminiCertNotAuthorized(ctx, request) } @@ -36,8 +35,7 @@ func GeminiAuth(approver Approver) sr.Middleware { func GeminiOptionalAuth(approver Approver) sr.Middleware { return func(inner sr.Handler) sr.Handler { return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response { - identity := Identity(request) - if identity != nil && !approver(identity) { + if Identity(request) != nil && !approver(ctx, request) { return geminiCertNotAuthorized(ctx, request) } -- cgit v1.2.3