client

package module
v0.0.0-...-d9180fd Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2017 License: MIT Imports: 8 Imported by: 40

README

Bytemark Auth Client

Bytemark operates a Single Sign-On service, intended to perform the "three As" (Authorization, Authentication and Access Control). This repository contains a small library written in Go to interact with that service.

API documentation: https://www.bytemark.co.uk/docs/api/authentication/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP http.Client
	// contains filtered or unexported fields
}

Client represents a client communicating with auth3

func New

func New(endpoint string) (*Client, error)

New returns a newly initialised client.

func (*Client) CreateImpersonatedSession

func (c *Client) CreateImpersonatedSession(ctx context.Context, token, user string) (*SessionData, error)

CreateImpersonatedSession uses an existing session token to create an impersonated session, returning the session data rather than just the token.

func (*Client) CreateImpersonatedSessionToken

func (c *Client) CreateImpersonatedSessionToken(ctx context.Context, token, username string) (string, error)

CreateImpersonatedSessionToken uses an existing session token to create an impersonated session and returns its token.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, credentials Credentials) (*SessionData, error)

CreateSession creates a session, returning the session data rather than just the token.

func (*Client) CreateSessionToken

func (c *Client) CreateSessionToken(ctx context.Context, credentials Credentials) (string, error)

CreateSessionToken creates a session and returns the token.

func (*Client) ReadSession

func (c *Client) ReadSession(ctx context.Context, token string) (*SessionData, error)

ReadSession takes a session token and returns the session data for that token, or nil is the session is invalid.

type Credentials

type Credentials map[string]string

Credentials provides a number of credentials used to authenticate a session. We expect factor => credential, i.e: {"password" => "foo", "yubikey" => "cccbar"} FIXME: this is a bit of a lie as you also pass the username here

type Error

type Error struct {
	Message string
	Err     error
}

Error wraps an underlying error with a higher level message

func (*Error) Error

func (e *Error) Error() string

Error returns an error message with high and low level components

type SessionData

type SessionData struct {
	Token    string // not actually in the session, but communicate it here
	Username string
	Factors  []string

	// The groups this user is a member of
	GroupMemberships []string `json:"group_memberships"`
}

SessionData collects the data held in a session

Directories

Path Synopsis
Simple auth client executable
Simple auth client executable

Jump to

Keyboard shortcuts

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