// Package gssapi implements Generic Security Services Application Program Interface required for SPNEGO kerberos authentication.
package gssapiimport ()// GSS-API OID namesconst (// GSS-API OID namesOIDKRB5OIDName = "KRB5"// MechType OID for Kerberos 5OIDMSLegacyKRB5OIDName = "MSLegacyKRB5"// MechType OID for Kerberos 5OIDSPNEGOOIDName = "SPNEGO"OIDGSSIAKerbOIDName = "GSSIAKerb"// Indicates the client cannot get a service ticket and asks the server to serve as an intermediate to the target KDC. http://k5wiki.kerberos.org/wiki/Projects/IAKERB#IAKERB_mech)// GSS-API status valuesconst (StatusBadBindings = 1 << iotaStatusBadMechStatusBadNameStatusBadNameTypeStatusBadStatusStatusBadSigStatusBadMICStatusContextExpiredStatusCredentialsExpiredStatusDefectiveCredentialStatusDefectiveTokenStatusFailureStatusNoContextStatusNoCredStatusBadQOPStatusUnauthorizedStatusUnavailableStatusDuplicateElementStatusNameNotMNStatusCompleteStatusContinueNeededStatusDuplicateTokenStatusOldTokenStatusUnseqTokenStatusGapToken)// ContextToken is an interface for a GSS-API context token.typeContextTokeninterface {Marshal() ([]byte, error)Unmarshal(b []byte) errorVerify() (bool, Status)Context() context.Context}/*CREDENTIAL MANAGEMENTGSS_Acquire_cred acquire credentials for useGSS_Release_cred release credentials after useGSS_Inquire_cred display information about credentialsGSS_Add_cred construct credentials incrementallyGSS_Inquire_cred_by_mech display per-mechanism credential informationCONTEXT-LEVEL CALLSGSS_Init_sec_context initiate outbound security contextGSS_Accept_sec_context accept inbound security contextGSS_Delete_sec_context flush context when no longer neededGSS_Process_context_token process received control token on contextGSS_Context_time indicate validity time remaining on contextGSS_Inquire_context display information about contextGSS_Wrap_size_limit determine GSS_Wrap token size limitGSS_Export_sec_context transfer context to other processGSS_Import_sec_context import transferred contextPER-MESSAGE CALLSGSS_GetMIC apply integrity check, receive as token separate from messageGSS_VerifyMIC validate integrity check token along with messageGSS_Wrap sign, optionally encrypt, encapsulateGSS_Unwrap decapsulate, decrypt if needed, validate integrity checkSUPPORT CALLSGSS_Display_status translate status codes to printable formGSS_Indicate_mechs indicate mech_types supported on local systemGSS_Compare_name compare two names for equalityGSS_Display_name translate name to printable formGSS_Import_name convert printable name to normalized formGSS_Release_name free storage of normalized-form nameGSS_Release_buffer free storage of general GSS-allocated objectGSS_Release_OID_set free storage of OID set objectGSS_Create_empty_OID_set create empty OID setGSS_Add_OID_set_member add member to OID setGSS_Test_OID_set_member test if OID is member of OID setGSS_Inquire_names_for_mech indicate name types supported by mechanismGSS_Inquire_mechs_for_name indicates mechanisms supporting name typeGSS_Canonicalize_name translate name to per-mechanism formGSS_Export_name externalize per-mechanism nameGSS_Duplicate_name duplicate name object*/// Mechanism is the GSS-API interface for authentication mechanisms.typeMechanisminterface {OID() asn1.ObjectIdentifierAcquireCred() error// acquire credentials for use (eg. AS exchange for KRB5)InitSecContext() (ContextToken, error) // initiate outbound security context (eg TGS exchange builds AP_REQ to go into ContextToken to send to service)AcceptSecContext(ct ContextToken) (bool, context.Context, Status) // service verifies the token server side to establish a contextMIC() MICToken// apply integrity check, receive as token separate from messageVerifyMIC(mt MICToken) (bool, error) // validate integrity check token along with messageWrap(msg []byte) WrapToken// sign, optionally encrypt, encapsulateUnwrap(wt WrapToken) []byte// decapsulate, decrypt if needed, validate integrity check}// OIDName is the type for defined GSS-API OIDs.typeOIDNamestring// OID returns the OID for the provided OID name.func ( OIDName) () asn1.ObjectIdentifier {switch {caseOIDSPNEGO:returnasn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 2}caseOIDKRB5:returnasn1.ObjectIdentifier{1, 2, 840, 113554, 1, 2, 2}caseOIDMSLegacyKRB5:returnasn1.ObjectIdentifier{1, 2, 840, 48018, 1, 2, 2}caseOIDGSSIAKerb:returnasn1.ObjectIdentifier{1, 3, 6, 1, 5, 2, 5} }returnasn1.ObjectIdentifier{}}// Status is the GSS-API status and implements the error interface.typeStatusstruct { Code int Message string}// Error returns the Status description.func ( Status) () string {varstringswitch .Code {caseStatusBadBindings: = "channel binding mismatch"caseStatusBadMech: = "unsupported mechanism requested"caseStatusBadName: = "invalid name provided"caseStatusBadNameType: = "name of unsupported type provided"caseStatusBadStatus: = "invalid input status selector"caseStatusBadSig: = "token had invalid integrity check"caseStatusBadMIC: = "preferred alias for GSS_S_BAD_SIG"caseStatusContextExpired: = "specified security context expired"caseStatusCredentialsExpired: = "expired credentials detected"caseStatusDefectiveCredential: = "defective credential detected"caseStatusDefectiveToken: = "defective token detected"caseStatusFailure: = "failure, unspecified at GSS-API level"caseStatusNoContext: = "no valid security context specified"caseStatusNoCred: = "no valid credentials provided"caseStatusBadQOP: = "unsupported QOP valu"caseStatusUnauthorized: = "operation unauthorized"caseStatusUnavailable: = "operation unavailable"caseStatusDuplicateElement: = "duplicate credential element requested"caseStatusNameNotMN: = "name contains multi-mechanism elements"caseStatusComplete: = "normal completion"caseStatusContinueNeeded: = "continuation call to routine required"caseStatusDuplicateToken: = "duplicate per-message token detected"caseStatusOldToken: = "timed-out per-message token detected"caseStatusUnseqToken: = "reordered (early) per-message token detected"caseStatusGapToken: = "skipped predecessor token(s) detected"default: = "unknown GSS-API error status" }if .Message != "" {returnfmt.Sprintf("%s: %s", , .Message) }return}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.