mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-06-16 20:08:59 -04:00
* adds pkg/jmap/jmap_integration_test.go
* uses ghcr.io/stalwartlabs/stalwart:v0.13.2-alpine
* can be disabled by setting one of the following environment
variables, in the same fashion as ca0493b28
- CI=woodpecker
- CI_SYSTEM_NAME=woodpecker
- USE_TESTCONTAINERS=false
* dependencies:
- bump github.com/go-test/deep from 1.1.0 to 1.1.1
- add github.com/cention-sany/utf7
- add github.com/dustinkirkland/golang-petname
- add github.com/emersion/go-imap/v2
- add github.com/emersion/go-message
- add github.com/emersion/go-sasl
- add github.com/go-crypt/crypt
- add github.com/go-crypt/x
- add github.com/gogs/chardet
- add github.com/inbucket/html2text
- add github.com/jhilleryerd/enmime/v2
- add github.com/ssor/bom
- add gopkg.in/loremipsum.v1
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package sasl
|
|
|
|
// The ANONYMOUS mechanism name.
|
|
const Anonymous = "ANONYMOUS"
|
|
|
|
type anonymousClient struct {
|
|
Trace string
|
|
}
|
|
|
|
func (c *anonymousClient) Start() (mech string, ir []byte, err error) {
|
|
mech = Anonymous
|
|
ir = []byte(c.Trace)
|
|
return
|
|
}
|
|
|
|
func (c *anonymousClient) Next(challenge []byte) (response []byte, err error) {
|
|
return nil, ErrUnexpectedServerChallenge
|
|
}
|
|
|
|
// A client implementation of the ANONYMOUS authentication mechanism, as
|
|
// described in RFC 4505.
|
|
func NewAnonymousClient(trace string) Client {
|
|
return &anonymousClient{trace}
|
|
}
|
|
|
|
// Get trace information from clients logging in anonymously.
|
|
type AnonymousAuthenticator func(trace string) error
|
|
|
|
type anonymousServer struct {
|
|
done bool
|
|
authenticate AnonymousAuthenticator
|
|
}
|
|
|
|
func (s *anonymousServer) Next(response []byte) (challenge []byte, done bool, err error) {
|
|
if s.done {
|
|
err = ErrUnexpectedClientResponse
|
|
return
|
|
}
|
|
|
|
// No initial response, send an empty challenge
|
|
if response == nil {
|
|
return []byte{}, false, nil
|
|
}
|
|
|
|
s.done = true
|
|
|
|
err = s.authenticate(string(response))
|
|
done = true
|
|
return
|
|
}
|
|
|
|
// A server implementation of the ANONYMOUS authentication mechanism, as
|
|
// described in RFC 4505.
|
|
func NewAnonymousServer(authenticator AnonymousAuthenticator) Server {
|
|
return &anonymousServer{authenticate: authenticator}
|
|
}
|