All Projects → ubccr → kerby

ubccr / kerby

Licence: Apache-2.0 license
Go wrapper for Kerberos GSSAPI

Programming Languages

c
50402 projects - #5 most used programming language
go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to kerby

python-krbcontext
A Kerberos context manager
Stars: ✭ 23 (-30.3%)
Mutual labels:  kerberos, gssapi
Cheat-Sheet---Active-Directory
This cheat sheet contains common enumeration and attack methods for Windows Active Directory with the use of powershell.
Stars: ✭ 154 (+366.67%)
Mutual labels:  kerberos
proxyplease
Cross-platform proxy selection with optional native authentication negotiation
Stars: ✭ 37 (+12.12%)
Mutual labels:  kerberos
windows-lab
Windows Automated Lab with Vagrant
Stars: ✭ 78 (+136.36%)
Mutual labels:  kerberos
py-hdfs-mount
Mount HDFS with fuse, works with kerberos!
Stars: ✭ 13 (-60.61%)
Mutual labels:  kerberos
KerberosRun
A little tool to play with Kerberos.
Stars: ✭ 59 (+78.79%)
Mutual labels:  kerberos
vault-plugin-auth-kerberos
[DEPRECATED] Plugin for Hashicorp Vault enabling Kerberos authentication
Stars: ✭ 36 (+9.09%)
Mutual labels:  kerberos
docker-kdc
Docker container generator for a Kerberos KDC.
Stars: ✭ 46 (+39.39%)
Mutual labels:  kerberos
nsspi
A C# / .Net interface to the Win32 SSPI authentication API
Stars: ✭ 60 (+81.82%)
Mutual labels:  kerberos
KerberosConfigMgrIIS
Kerberos Configuration Manager for IIS
Stars: ✭ 40 (+21.21%)
Mutual labels:  kerberos
active-directory-integration2
WordPress plug-in "Next Active Directory Integration"
Stars: ✭ 51 (+54.55%)
Mutual labels:  kerberos
modules
Mesos modules examples and open source modules outside of the Apache Mesos source tree.
Stars: ✭ 26 (-21.21%)
Mutual labels:  kerberos
Impacket
Impacket is a collection of Python classes for working with network protocols.
Stars: ✭ 8,037 (+24254.55%)
Mutual labels:  kerberos
pure-sasl
A pure python SASL client
Stars: ✭ 32 (-3.03%)
Mutual labels:  kerberos
omniauth-kerberos
OmniAuth strategy for kerberos authentication.
Stars: ✭ 13 (-60.61%)
Mutual labels:  kerberos
go-spnego
Wraps gokrb5 and sspi libraries to provide cross-platform way to make HTTP calls with Kerberos authentication
Stars: ✭ 20 (-39.39%)
Mutual labels:  kerberos
OpenAM
OpenAM is an open access management solution that includes Authentication, SSO, Authorization, Federation, Entitlements and Web Services Security.
Stars: ✭ 476 (+1342.42%)
Mutual labels:  kerberos
code
~/code – tools distributed across all of my systems
Stars: ✭ 73 (+121.21%)
Mutual labels:  kerberos
jupyterhub-kdcauthenticator
A Kerberos authenticator module for the JupyterHub platform
Stars: ✭ 22 (-33.33%)
Mutual labels:  kerberos
sieve-connect
A client for the MANAGESIEVE Protocol
Stars: ✭ 60 (+81.82%)
Mutual labels:  gssapi

Kerby - Go wrapper for Kerberos GSSAPI

Godoc

This is a port of the PyKerberos library in Go. The main motivation for this library was to provide HTTP client authentication using Kerberos. The khttp package provides a transport that authenticates all outgoing requests using SPNEGO (negotiate authentication) http://tools.ietf.org/html/rfc4559.

The C code is adapted from PyKerberos http://calendarserver.org/wiki/PyKerberos.

Usage

Note: You need the have the krb5-libs/GSSAPI packages installed for your OS.

Install using go tools:

$ go get github.com/ubccr/kerby

To run the unit tests you must have a valid Kerberos setup on the test machine and you should ensure that you have valid Kerberos tickets (run 'klist' on the command line). If you're authentication using a client keytab file you can optionally export the env variable KRB5_CLIENT_KTNAME:

$ export KRB5_CLIENT_KTNAME=/path/to/client.keytab
$ export KERBY_TEST_SERVICE="service@REALM"
$ export KERBY_TEST_PRINC="princ@REALM"
$ go test

Example HTTP Kerberos client authentication using a client keytab file:

package main

import (
    "fmt"
    "io/ioutil"
    "bytes"
    "net/http"

    "github.com/ubccr/kerby/khttp"
)

func main() {
    payload := []byte(`{"method":"hello_world"}`)
    req, err := http.NewRequest(
        "POST",
        "https://server.example.com/json",
        bytes.NewBuffer(payload))

    req.Header.Set("Content-Type", "application/json")

    t := &khttp.Transport{
        KeyTab: "/path/to/client.keytab",
        Principal: "principal@REALM"}

    client := &http.Client{Transport: t}

    res, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer res.Body.Close()

    data, err := ioutil.ReadAll(res.Body)
    if err != nil {
        panic(err)
    }

    fmt.Printf("%d\n", res.StatusCode)
    fmt.Printf("%s", data)
}

Example HTTP handler supporting Kerberose authentication:

func handler(w http.ResponseWriter, req *http.Request) {
    authReq := strings.Split(req.Header.Get(authorizationHeader), " ")
    if len(authReq) != 2 || authReq[0] != negotiateHeader {
        w.Header().Set(wwwAuthenticateHeader, negotiateHeader)
        http.Error(w, "Invalid authorization header", http.StatusUnauthorized)
        return
    }

    ks := new(kerby.KerbServer)
    err := ks.Init("")
    if err != nil {
        log.Printf("KerbServer Init Error: %s", err.Error())
        http.Error(w, err.Error(), http.StatusInternalServerError)
        return
    }
    defer ks.Clean()


    err = ks.Step(authReq[1])
    w.Header().Set(wwwAuthenticateHeader, negotiateHeader+" "+ks.Response())

    if err != nil {
        log.Printf("KerbServer Step Error: %s", err.Error())
        http.Error(w, err.Error(), http.StatusUnauthorized)
        return
    }

    user := ks.UserName()
    fmt.Fprintf(w, "Hello, %s", user)
}

Example adding Kerberos authentication to an http.FileServer using khttp.Handler:

package main

import (
    "github.com/ubccr/kerby/khttp"
    "log"
    "net/http"
)

func main() {
    http.Handle("/", khttp.Handler(http.FileServer(http.Dir("/tmp"))))
    log.Fatal(http.ListenAndServe(":8000", nil))
}

License

Kerby is released under the Apache 2.0 License. See the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].