summaryrefslogtreecommitdiff
path: root/contrib/tlsauth/gemini.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-10-09 08:56:53 -0600
committertjpcc <tjp@ctrl-c.club>2023-10-09 08:56:53 -0600
commitcedcf58ea7d729acb6ed1a9ab7aec1ae38aed102 (patch)
treec04144501fa461b840cea96951f23d926b596ff7 /contrib/tlsauth/gemini.go
parent1a14f01df1c220f1b8a0dcee1eada007aca8d43f (diff)
more useful tlsauth.Approver type
the predicate function should be able to see the whole context and request
Diffstat (limited to 'contrib/tlsauth/gemini.go')
-rw-r--r--contrib/tlsauth/gemini.go8
1 files changed, 3 insertions, 5 deletions
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)
}