mcf

package module
v0.0.0-...-05a1410 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2018 License: MIT Imports: 16 Imported by: 0

README

GO-MCF

Common helper methods for MCF golang applications

Base url resolver

This provide a safe approach to concatenate a base url with path string, and resolve the joining slash between the 2

Parameter Type Description
Base URL String Scheme + host name of URL
Path String Path of URL
path := ResolveURL("http://somebasepath", "/path")
fmt.Print(path)

Result: http://somebasepath/path

Cryptography

Provide the following methods to get and initialize a Signer object which is then use to retrieve a authorization token from a token issuing server.

Parameter Type Description
Private key file String Location of file containing private key
Service Id String ID of requesting service
Authenticator String Location of service authenticator
Token Life Time Clock Skew Int64 Time to live for request
Signer := GetSigner("./resources/private_key.pem", "7ac7681a3e0649ecb9cc1e2f0b3c8a07", "http://authenticator.com", 1000000)

Signer.InitSigner()

token := Signer.GetAuthToken()

Result: token issued by issuing server

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveURL

func ResolveURL(base string, path string) (string, error)

ResolveURL concates base url with extended path

Types

type Cryptography

type Cryptography struct {
	// contains filtered or unexported fields
}

Cryptography describe the utils to import the private key from file

type Signer

type Signer struct {
	Cryptography interface {
		// contains filtered or unexported methods
	}
	// contains filtered or unexported fields
}

Signer describe the imported private key and token from svc-auth

func GetSigner

func GetSigner(privateKeyLoc string, serviceID string, authenticator string, tokenLifeTimeClockSkew int64) *Signer

GetSigner return a new Signer instance

func (*Signer) GetAuthToken

func (r *Signer) GetAuthToken() string

GetAuthToken returns access token

func (*Signer) InitSigner

func (r *Signer) InitSigner()

InitSigner initial Signer with private key

Jump to

Keyboard shortcuts

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