Sen descrición

Jonathan Turner 0700a0b142 comments %!s(int64=9) %!d(string=hai) anos
asn1tools b8acc9d8e9 comments %!s(int64=9) %!d(string=hai) anos
client 28c696288e comment updates %!s(int64=9) %!d(string=hai) anos
config f62ca44c30 comment update %!s(int64=9) %!d(string=hai) anos
credentials 28c696288e comment updates %!s(int64=9) %!d(string=hai) anos
crypto c467c01ced comment updates %!s(int64=9) %!d(string=hai) anos
iana c467c01ced comment updates %!s(int64=9) %!d(string=hai) anos
keytab 0700a0b142 comments %!s(int64=9) %!d(string=hai) anos
messages b8acc9d8e9 comments %!s(int64=9) %!d(string=hai) anos
testdata 28c696288e comment updates %!s(int64=9) %!d(string=hai) anos
testenv 8c8a620d09 minor fix %!s(int64=9) %!d(string=hai) anos
types 28c696288e comment updates %!s(int64=9) %!d(string=hai) anos
.gitignore 95ab435b4c initial commit %!s(int64=9) %!d(string=hai) anos
LICENSE caee2dc83a Initial commit %!s(int64=9) %!d(string=hai) anos
README.md 4f2d691fa5 readme update %!s(int64=9) %!d(string=hai) anos
debug.go 0a7b65fa69 tidy %!s(int64=9) %!d(string=hai) anos

README.md

gokrb5

This is work in progress and does not yet fully work...

GoDoc

Implemented Encryption & Checksum Types

The currently implemented encrytion types are:

Implementation Encryption ID Checksum ID
aes128-cts-hmac-sha1-96 17 15
aes256-cts-hmac-sha1-96 18 16

Usage

Configuration

The gokrb5 libraries use the same krb5.conf configuration file format as MIT Kerberos, described here. Config instances can be created by loading from a file path or by passing a string, io.Reader or bufio.Scanner to the relevant method:

import "github.com/jcmturner/gokrb5/config"
cfg, err := config.Load("/path/to/config/file")
cfg, err := config.NewConfigFromString(krb5Str) //String must have appropriate newline separations
cfg, err := config.NewConfigFromReader(reader)
cfg, err := config.NewConfigFromScanner(scanner)

Keytab files

Standard keytab files can be read from a file or from a slice of bytes:

import 	"github.com/jcmturner/gokrb5/keytab"
ktFromFile, err := keytab.Load("/path/to/file.keytab")
ktFromBytes, err := keytab.Parse(b)

Kerberos Client

Create a client instance with either a password or a keytab:

import 	"github.com/jcmturner/gokrb5/client"
cl := client.NewClientWithPassword("username", "REALM.COM", "password")
cl := client.NewClientWithKeytab("username", "REALM.COM", kt)

Provide configuration to the client:

cl.WithConfig(cfg)

Login:

err := cl.Login

(Optional) Enable automatic refresh of Kerberos Ticket Granting Ticket (TGT):

cl.EnableAutoSessionRenewal()

Request a Serivce ticket for a Service Principal Name (SPN). This method will use the client's cache either returning a valid cached ticket, renewing a cached ticket with the KDC or requesting a new ticket from the KDC. Therefore the GetServiceTicket method can be continually used for the most efficient interation with the KDC.

tkt, err := cl.GetServiceTicket("HTTP/host.test.gokrb5")

References

RFCs

Useful Links

Thanks

  • Greg Hudson from the MIT Consortium for Kerberos and Internet Trust for providing useful advice.

Known Issues

Issue Worked around? References
Golang's ASN1 package cannot unmarshal into slice of asn1.RawValue Yes https://github.com/golang/go/issues/17321
Golang's ASN1 package cannot marshal into a GeneralString Yes - using https://github.com/jcmturner/asn1 https://github.com/golang/go/issues/18832
Golang's ASN1 package cannot marshal into slice of strings and pass stringtype parameter tags to members Yes - using https://github.com/jcmturner/asn1 https://github.com/golang/go/issues/18834
Golang's ASN1 package cannot marshal with application tags Yes