summaryrefslogtreecommitdiff
path: root/contrib/tlsauth/approver.go
blob: 064056d627c0bfde144f02ee4bb8447dae68c997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package tlsauth

import "crypto/x509"

// Approver is a function that validates a certificate.
//
// It should not be have to handle a nil argument.
type Approver func(*x509.Certificate) bool

// RequireSpecificIdentity builds an approver that demands one specific client certificate.
func RequireSpecificIdentity(identity *x509.Certificate) Approver { return identity.Equal }

// Allow is an approver which permits anything.
func Allow(_ *x509.Certificate) bool { return true }

// Reject is an approver which denies everything.
func Reject(_ *x509.Certificate) bool { return false }