• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    Go
  • License
    BSD 2-Clause "Sim...
  • Created about 12 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Yubigo is a Yubikey client API library that provides an easy way to integrate the Yubico Yubikey into your existing Go-based user authentication infrastructure.

yubigo

Yubigo is a Yubikey client API library that provides an easy way to integrate the Yubikey into any Go application.

Installation

Installation is simple. Use go get: go get github.com/GeertJohan/yubigo

Usage

Make sure to import the library: import "github.com/GeertJohan/yubigo"

For use with the default Yubico servers, make sure you have an API key. Request a key.

Basic OTP checking usage:

// create a new yubiAuth instance with id and key
yubiAuth, err := yubigo.NewYubiAuth("1234", "fdsaffqaf4vrc2q3cds=")
if err != nil {
	// probably an invalid key was given
	log.Fatalln(err)
}

// verify an OTP string
result, ok, err := yubiAuth.Verify("ccccccbetgjevivbklihljgtbenbfrefccveiglnjfbc")
if err != nil {
	log.Fatalln(err)
}

if ok {
	// succes!! The OTP is valid!
	log.Printf("Used query was: %s\n", result.GetRequestQuery()) // this query string includes the url of the api-server that responded first.
} else {
	// fail! The OTP is invalid or has been used before.
	log.Println("The given OTP is invalid!!!")
}

Use your own HTTP Client with fine-tuned config: While the library works out of the box, it's not recommended to use the default http client. It is better to configure your own http client with useful timeouts.

For example:

yubigo.HTTPClient = &http.Client{
    Timeout: time.Second * 15,
    Transport: &http.Transport{
        MaxConnsPerHost:     20,
        MaxIdleConnsPerHost: 5,
        DialContext: (&net.Dialer{
            Timeout:   30 * time.Second,
            KeepAlive: 60 * time.Second,
        }).DialContext,
        TLSHandshakeTimeout:   10 * time.Second,
        ResponseHeaderTimeout: 10 * time.Second,
        ExpectContinueTimeout: 1 * time.Second,
    },
}

Do not verify HTTPS certificate:

// Disable HTTPS cert verification. Use true to enable again.
yubiAuth.HttpsVerifyCertificate(false)

HTTP instead of HTTPS:

// Disable HTTPS. Use true to enable again.
yubiAuth.UseHttps(false)

Custom API server:

// Set a list of n servers, each server as host + path. 
// Do not prepend with protocol
yubiAuth.SetApiServerList("api0.server.com/api/verify", "api1.server.com/api/verify", "otherserver.com/api/verify")

Licence

This project is licensed under a Simplified BSD license. Please read the LICENSE file.

Todo

  • Test files
  • More documentation
  • Getters/Setters for some options on the YubiAuth object.

Protocol & Package documentation

This project is implementing a pure-Go Yubico OTP Validation Client and is following the Yubico Validation Protocol Version 2.0.

You will find "go doc"-like package documentation at go.pkgdoc.org.

More Repositories

1

go.rice

go.rice is a Go package that makes working with resources such as html,js,css,images,templates, etc very easy.
Go
2,417
star
2

gomatrix

Displays "The Matrix" in a terminal
Go
274
star
3

openwrt-go

Fork of the openwrt project to add gccgo and libgo
C
243
star
4

go.tesseract

go.tesseract is a wrapper for the tesseract-ocr library.
Go
68
star
5

go.linenoise

Linenoise is a lightweight readline library.
C
57
star
6

go.hid

Provides communication with USB Human Interface Devices.
C
53
star
7

go.qrt

QR codes for terminals
Go
24
star
8

fgt

fgt runs any command for you and exits with exitcode 1 when the child process sent anything to stdout or stderr
Go
24
star
9

ango

ango is a tool that generates a protocol for communication between Go and AngularJS over http/websockets.
Go
15
star
10

cgo.wchar

The cgo.wchar package is to be used with go/cgo and helps with the conversion from and to C.wchar_t and wchar_t strings (*C.wchar_t with null terminator or length int).
Go
14
star
11

go.hue

go.hue is a Go package wrapping the Philips Hue bridge interface
Go
14
star
12

go.bitcoin

Go package containing bitcoin utilities and BitcoindClient wrapping the http json-api.
Go
13
star
13

go.leptonica

go.leptonica wraps the leptonica library for "efficient image processing and image analysis operations".
Go
12
star
14

go.ask

Ask questions in cli
Go
8
star
15

aerospike-capacity-calculator

Aerospike capacity calculator
HTML
8
star
16

go.geofence

Go
6
star
17

aerospike-discovery

Aerospike cluster node discovery with etcd
Go
6
star
18

go.incremental

package incremental provides concurency-safe incremental numbers
Go
5
star
19

dockerfiles

Dockerfiles used to build my public images at
4
star
20

tune

Tune is a music-player for the AudioAddict web radio's such as Digitally Imported (di.fm) and RadioTunes.
Go
4
star
21

kube-multi-config

4
star
22

go.cef

CEF for Go. Work in progress..
Go
3
star
23

diffsim

Cryptocoin difficulty re-adjustment algorithm simulator
Go
2
star
24

gocaptcha

Go
2
star
25

gopaint

Go Paint
Go
2
star
26

go.airbrake

Airbrake package
Go
2
star
27

reporef

Go
2
star
28

go-sourcepath

Package sourcepath gives the absolute path for the calling Go file. Extracted from go.rice
Go
1
star
29

go.bapp

Simple library to create a go application with a webinterface as gui (browser, localhost)
Go
1
star
30

ango-old

AngularJS & Go. Communication and data-binding
Go
1
star
31

docker-xpra

XPRA on Docker
1
star
32

mgl

MSI GT laptop keyboard LEDs controller
Go
1
star
33

gotalks

This repo holds slides and stuff for talks
Go
1
star
34

outyet

Server program powering outyet.org
Go
1
star
35

unsolicited-advice

Rust
1
star
36

go.btcqr

bitcoin QR code generator
Go
1
star