diff options
author | 2021-08-12 21:03:24 +0200 | |
---|---|---|
committer | 2021-08-12 21:03:24 +0200 | |
commit | 98263a7de64269898a2f81207e38943b5c8e8653 (patch) | |
tree | 743c90f109a6c5d27832d1dcef2388d939f0f77a /vendor/mellium.im/sasl/options.go | |
parent | Text duplication fix (#137) (diff) | |
download | gotosocial-98263a7de64269898a2f81207e38943b5c8e8653.tar.xz |
Grand test fixup (#138)
* start fixing up tests
* fix up tests + automate with drone
* fiddle with linting
* messing about with drone.yml
* some more fiddling
* hmmm
* add cache
* add vendor directory
* verbose
* ci updates
* update some little things
* update sig
Diffstat (limited to 'vendor/mellium.im/sasl/options.go')
-rw-r--r-- | vendor/mellium.im/sasl/options.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/mellium.im/sasl/options.go b/vendor/mellium.im/sasl/options.go new file mode 100644 index 000000000..427a2be59 --- /dev/null +++ b/vendor/mellium.im/sasl/options.go @@ -0,0 +1,53 @@ +// Copyright 2016 The Mellium Contributors. +// Use of this source code is governed by the BSD 2-clause license that can be +// found in the LICENSE file. + +package sasl + +import ( + "crypto/tls" +) + +// An Option represents an input to a SASL state machine. +type Option func(*Negotiator) + +func getOpts(n *Negotiator, o ...Option) { + n.credentials = func() (username, password, identity []byte) { + return + } + n.permissions = func(_ *Negotiator) bool { + return false + } + for _, f := range o { + f(n) + } +} + +// TLSState lets the state machine negotiate channel binding with a TLS session +// if supported by the underlying mechanism. +func TLSState(cs tls.ConnectionState) Option { + return func(n *Negotiator) { + n.tlsState = &cs + } +} + +// RemoteMechanisms sets a list of mechanisms supported by the remote client or +// server with which the state machine will be negotiating. +// It is used to determine if the server supports channel binding. +func RemoteMechanisms(m ...string) Option { + return func(n *Negotiator) { + n.remoteMechanisms = m + } +} + +// Credentials provides the negotiator with a username and password to +// authenticate with and (optionally) an authorization identity. +// Identity will normally be left empty to act as the username. +// The Credentials function is called lazily and may be called multiple times by +// the mechanism. +// It is not memoized by the negotiator. +func Credentials(f func() (Username, Password, Identity []byte)) Option { + return func(n *Negotiator) { + n.credentials = f + } +} |