auth

package
v0.0.0-...-00f2437 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const RawStateBytesLen int = 32

RawStateBytesLen is the number of bytes a raw state bytes array should contain

Variables

This section is empty.

Functions

func MakeState

func MakeState(stateSigningPrivKey []byte) string

MakeState return a series of signed bytes which are base64 encoded. Used as the GH auth state. The returned value is in the format: `<state>.<state signature>`

func VerifyState

func VerifyState(stateSigningPubKey []byte, state string) (bool, error)

VerifyState checks to see if a series of bytes was signed by the GH auth state signing key The provided state is expected to be in the format: `<state>.<signed state>`

Types

type AuthToken

type AuthToken struct {
	// Issuer is the name of the service which issued the token
	Issuer string `json:"iss"`

	// Audience is the name of the service who is meant to received the token
	Audience string `json:"aud"`

	// GitHubUserID is the ID of the authenticated GitHub user, used as the subject field in the JWT
	GitHubUserID string `json:"sub"`

	// GitHubAuthToken is the user's GitHub authentication token
	GitHubAuthToken string `json:"github_auth_token"`

	// ZenHubAuthToken is the user's ZenHub authentication token
	ZenHubAuthToken string `json:"zenhub_auth_token"`
}

AuthToken is issued to a user to prove they are authenticated

func NewAuthToken

func NewAuthToken(serviceName, ghUserID, ghAuthToken, zhAuthToken string) AuthToken

NewAuthToken creates a new AuthToken. The serviceName is used for the Issuer and Audience field

func (*AuthToken) Decode

func (t *AuthToken) Decode(tokenStr, signingSecret string) error

Decode an authentication from a string

func (AuthToken) Encode

func (t AuthToken) Encode(signingSecret string) (string, error)

Encode an authentication token into a string

Jump to

Keyboard shortcuts

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