Categorygithub.com/ian-ross/EdgeAuth/golang
package
0.0.1
Repository: https://github.com/ian-ross/edgeauth.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

Phenix EdgeAuth Digest Tokens for Go

Easily generate secure digest tokens to use with the Phenix platform without requiring any networking activity.

Installation

To install the edgeauth Go executable to create Phenix Edge Authorization Digest Tokens (this installs the executable into $GOPATH/bin):

$ go install github.com/ian-ross/EdgeAuth/golang/[email protected]

To install the Go package to develop against:

$ go get github.com/ian-ross/EdgeAuth/[email protected]

To build the edgeauth executable from source, clone this repository and in the golang directory:

$ go build ./cmd/edgeauth

Testing

In the golang directory:

$ cd test
$ go test -v

To run Behavior-Driven Development tests with godog, in the golang directory:

$ go install github.com/cucumber/godog/cmd/[email protected]
$ cd bdd
$ godog run

Example

After installing the golang package as described above, create a Go test program:

$ mkdir ~/edgeauth-test
$ cd ~/edgeauth-test
$ go mod init example.com/edgeauth-test

Copy the following text into a main.go file:

package main

import (
	"fmt"
	edgeauth "github.com/ian-ross/EdgeAuth/golang"
)

func main() {
	// Create a token to access a channel
	token, err := edgeauth.NewTokenBuilder().
		WithApplicationID("my-application-id").
		WithSecret("my-secret").
		ExpiresInSeconds(3600).
		ForChannel("us-northeast#my-application-id#my-channel.1345").
		Build()
    
	if err != nil {
		fmt.Println("Token encoding error:", err.Error())
	} else {
		fmt.Println(*token)
	}
}

Build and run the example:

$ go get github.com/ian-ross/EdgeAuth/[email protected]
$ go build
$ ./edgeauth-test

Command Line Examples

Using the edgeauth program installed or build as described above, display the help information:

$ edgeauth -help

Create a token for channel access:

$ edgeauth -application_id "my-application-id" -secret "my-secret" -expires_in_seconds 3600 -channel "us-northeast#my-application-id#my-channel.1345"