Documentation
¶
Overview ¶
Package saslgssapi implements the SASL GSSAPI mechanism (RFC 4752) — the Kerberos 5 GSS-API mechanism (OID 1.2.840.113554.1.2.2) exposed as a SASL mechanism — so a Go client can authenticate to IMAP, SMTP, LDAP, XMPP, and other SASL-protected services with a Kerberos credential.
v0 is the client (initiator) side only, negotiating the "no security layer" protection (authentication only); transport confidentiality is expected from TLS. It is built to satisfy the emersion/go-sasl client contract so it drops into go-imap and go-smtp.
Example ¶
Example builds the SASL client from a holder-of-key credential cache. The result satisfies emersion/go-sasl's Client, so it plugs straight into go-imap's Authenticate or go-smtp's Auth.
// A ccache already holding a service ticket for the target — from kinit,
// KRB5CCNAME, or an OAuth2-to-Kerberos exchange. No KDC is contacted.
cc, err := credentials.LoadCCache("/tmp/krb5cc_1000")
if err != nil {
log.Fatal(err)
}
krbClient, err := saslgssapi.FromCCache(cc)
if err != nil {
log.Fatal(err)
}
var sc sasl.Client
sc, err = saslgssapi.NewClient(saslgssapi.Config{
Client: krbClient,
Service: "imap/mail.example.com",
})
if err != nil {
log.Fatal(err)
}
// Hand sc to a SASL-capable client, e.g. imapClient.Authenticate(sc).
_ = sc
Index ¶
Examples ¶
Constants ¶
const Mechanism = "GSSAPI"
Mechanism is the SASL mechanism name this client advertises.
const SpecVersion = "v0 (SASL GSSAPI client; RFC 4752)"
SpecVersion is the SASL GSSAPI profile this build implements.
Variables ¶
This section is empty.
Functions ¶
func FromCCache ¶
func FromCCache(cc *credentials.CCache) (*client.Client, error)
FromCCache builds a holder-of-key Kerberos client from an MIT credential cache for use as Config.Client. It is a thin wrapper over client.NewFromCCache: the ccache is expected to already hold the service ticket and its session key, so the client never contacts a KDC.
The returned *client.Client can also be built directly with client.NewFromCCache if the caller needs a non-default krb5 configuration (e.g. to allow a live TGS exchange for tickets not yet cached).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the RFC 4752 SASL GSSAPI client (initiator). It implements github.com/emersion/go-sasl's Client interface, so it drops into go-imap and go-smtp. A Client is single-use: one authentication exchange per Client.
v0 performs authentication only ("no security layer") with mandatory mutual authentication; transport confidentiality is expected from TLS. The Kerberos GSS context establishment (AP-REQ / AP-REP / the RFC 4121 checksum) is handled by github.com/hstern/krb5's krb5context.Initiator; this type adds the RFC 4752 SASL framing and the security-layer negotiation on top.
type Config ¶
type Config struct {
// Client is the Kerberos client holding the credential — typically from
// FromCCache, or built directly with client.NewFromCCache. Required.
Client *client.Client
// Service is the target service principal name (SPN), e.g.
// "imap/mail.example.com" or "imap/mail.example.com@EXAMPLE.COM". Required.
Service string
// AuthzID is the optional authorization identity (authzid) sent in the
// final security-layer message. Empty means authenticate as the ticket's
// client principal.
AuthzID string
}
Config configures a Client.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
seclayer
Package seclayer marshals and unmarshals the RFC 4752 §3.3 security-layer negotiation tokens — the acceptor's offer and the client's selection.
|
Package seclayer marshals and unmarshals the RFC 4752 §3.3 security-layer negotiation tokens — the acceptor's offer and the client's selection. |
|
test
|
|
|
interop/client
command
Command interop-client drives the go-sasl-gssapi client for the interop harness.
|
Command interop-client drives the go-sasl-gssapi client for the interop harness. |