jcmturner / gokrb5

Pure Go Kerberos library for clients and services
Apache License 2.0
723 stars 245 forks source link

Make Keberos result codes available from errors #440

Open lorenz opened 3 years ago

lorenz commented 3 years ago

This exposes inner errors in Krberror errors as a non-breaking change by making Krberror implement the Unwrap interface.

Example:

err := client.Login()
var krbErr messages.KRBError
if errors.As(err, &krbErr) {
    switch krbErr.ErrorCode {
        case errorcode.KDC_ERR_PREAUTH_FAILED:
            fmt.Println("This is a PREAUTH_FAILED error")
        }
}

Fixes #437