Documentation ¶
Overview ¶
Package x509request provides a request authenticator that validates and extracts user information from client certificates
Index ¶
- Variables
- func DefaultVerifyOptions() x509.VerifyOptions
- func NewVerifier(opts x509.VerifyOptions, auth authenticator.Request) authenticator.Request
- func SubjectToUser(subject pkix.Name) user.Info
- func UserToSubject(u user.Info) pkix.Name
- type Authenticator
- type UserConversion
- type UserConversionFunc
- type Verifier
Constants ¶
This section is empty.
Variables ¶
var CommonNameUserConversion = UserConversionFunc(func(chain []*x509.Certificate) (user.Info, bool, error) { if len(chain[0].Subject.CommonName) == 0 { return nil, false, nil } return &user.DefaultInfo{Name: chain[0].Subject.CommonName}, true, nil })
CommonNameUserConversion builds user info from a certificate chain using the subject's CommonName
var DNSNameUserConversion = UserConversionFunc(func(chain []*x509.Certificate) (user.Info, bool, error) { if len(chain[0].DNSNames) == 0 { return nil, false, nil } return &user.DefaultInfo{Name: chain[0].DNSNames[0]}, true, nil })
DNSNameUserConversion builds user info from a certificate chain using the first DNSName on the certificate
var EmailAddressUserConversion = UserConversionFunc(func(chain []*x509.Certificate) (user.Info, bool, error) { if len(chain[0].EmailAddresses) == 0 { return nil, false, nil } return &user.DefaultInfo{Name: chain[0].EmailAddresses[0]}, true, nil })
EmailAddressUserConversion builds user info from a certificate chain using the first EmailAddress on the certificate
var SubjectToUserConversion = UserConversionFunc(func(chain []*x509.Certificate) (user.Info, bool, error) { user := SubjectToUser(chain[0].Subject) if len(user.GetName()) == 0 { return nil, false, nil } return user, true, nil })
SubjectToUserConversion calls SubjectToUser on the subject of the first certificate in the chain. If the resulting user has no name, it returns nil, false, nil
Functions ¶
func DefaultVerifyOptions ¶
func DefaultVerifyOptions() x509.VerifyOptions
DefaultVerifyOptions returns VerifyOptions that use the system root certificates, current time, and requires certificates to be valid for client auth (x509.ExtKeyUsageClientAuth)
func NewVerifier ¶ added in v0.4.2
func NewVerifier(opts x509.VerifyOptions, auth authenticator.Request) authenticator.Request
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator implements request.Authenticator by extracting user info from verified client certificates
func New ¶
func New(opts x509.VerifyOptions, user UserConversion) *Authenticator
New returns a request.Authenticator that verifies client certificates using the provided VerifyOptions, and converts valid certificate chains into user.Info using the provided UserConversion
func (*Authenticator) AuthenticateRequest ¶
AuthenticateRequest authenticates the request using presented client certificates
type UserConversion ¶
UserConversion defines an interface for extracting user info from a client certificate chain
type UserConversionFunc ¶
UserConversionFunc is a function that implements the UserConversion interface.
func (UserConversionFunc) User ¶
func (f UserConversionFunc) User(chain []*x509.Certificate) (user.Info, bool, error)
User implements x509.UserConversion