duo_go

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

README

Overview

Build Status Coverage Status Go Report Card Pkg.Go.Dev

duo_go - Duo 2FA for Go web applications: https://duo.com/docs/duoweb

Installing

$ go get github.com/mschwager/duo_go

Using

Here's a short snippet of code demonstrating the library:

package main

import (
    "fmt"
    "github.com/mschwager/duo_go"
)

func main() {
    duo_configuration := &duo_go.Web{
        Ikey: "<ikey-here>",
        Skey: "<skey-here>",
        Akey: "<akey-here>",
    }
    sig_request, _ := duo_go.SignRequest(duo_configuration, "example_username")

    fmt.Println("Signature request: " + sig_request)
}
$ go run example.go
Signature request: TX|ZXh...|5ce...:APP|ZXh...|fc2...

For a more complete example, checkout the demo code.

Demo

Configure your ikey, skey, akey, and host, in duo_go_demo.go.

Then run the following command:

$ go run duo_go_demo/duo_go_demo.go

Testing

$ go test

Documentation

Overview

Package duo_go implments the Duo Security WebSDK.

Index

Constants

View Source
const (
	SignatureSeparator = ":"
	ValueSeparator     = "|"

	DuoPrefix  = "TX"
	AppPrefix  = "APP"
	AuthPrefix = "AUTH"

	DuoExpire = 300
	AppExpire = 3600

	IKEYLen = 20
	SKEYLen = 40
	AKEYLen = 40

	ErrUser  = "ERR|The username passed to SignRequest() is invalid."
	ErrIKEY  = "ERR|The Duo integration key passed to SignRequest() is invalid."
	ErrSKEY  = "ERR|The Duo secret key passed to SignRequest() is invalid."
	ErrAKEY  = "ERR|The application secret key passed to SignRequest() must be at least 40 characters."
	ErrParse = "ERR|The response could not be parsed."
)

Variables

This section is empty.

Functions

func SignRequest

func SignRequest(configuration *Web, username string) (signature string, err error)

SignRequest signs a 2FA request for consumption by the Duo service.

func VerifyResponse

func VerifyResponse(configuration *Web, response string) (username string, err error)

VerifyResponse verifies a 2FA response received from the Duo service.

Types

type Web

type Web struct {
	Ikey string
	Skey string
	Akey string
}

Web holds configuration necessary to communicate with the Duo service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL