v1.1.0 Latest Latest

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

Go to latest
Published: Aug 17, 2017 License: MIT Imports: 12 Imported by: 0




View Source
const OsiamProviderName = "osiam"

OsiamProviderName const with the name of the provider


This section is empty.


This section is empty.


type Backend

type Backend struct {
	// contains filtered or unexported fields

Backend is the osiam authentication backend.

func NewBackend

func NewBackend(endpoint, clientID, clientSecret string) (*Backend, error)

NewBackend creates a new OSIAM Backend and verifies the parameters.

func (*Backend) Authenticate

func (b *Backend) Authenticate(username, password string) (bool, model.UserInfo, error)

Authenticate the user

type Client

type Client struct {
	Endpoint     string
	ClientID     string
	ClientSecret string

Client is a wrapper for the osiam API.

func NewClient

func NewClient(endpoint string, clientID string, clientSecret string) *Client

NewClient for the osiam API.

func (*Client) GetTokenByPassword

func (c *Client) GetTokenByPassword(username, password string, scopes ...string) (authenticated bool, token *Token, err error)

GetTokenByPassword does an Osiam authorisation by Resource Owner Password Credentials Grant. If no scopes are supplied, the default scope is 'me'.

type OsiamError

type OsiamError struct {
	Error   string
	Message string

OsiamError represents an error response from osiam.

func ParseOsiamError

func ParseOsiamError(jsonBody []byte) OsiamError

ParseOsiamError creates an OsiamError out of a json

func (OsiamError) IsLoginError

func (e OsiamError) IsLoginError() bool

IsLoginError checks, if the grant was invalid

func (OsiamError) IsUnauthorized

func (e OsiamError) IsUnauthorized() bool

IsUnauthorized checks, if the error reason was Unauthorized

type Timestamp

type Timestamp struct {
	T time.Time

Timestamp is a helper class for json handling ht the timestamp

func (*Timestamp) MarshalJSON

func (timestamp *Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON does the marshaling

func (*Timestamp) UnmarshalJSON

func (timestamp *Timestamp) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON does the unmarshaling

type Token

type Token struct {
	TokenType             string    `json:"token_type"`               // example "bearer"
	AccessToken           string    `json:"access_token"`             // example "79f479c2-c0d7-458a-8464-7eb887dbc943"
	RefreshToken          string    `json:"refresh_token"`            // example "3c7c4a87-dc91-4dd0-8ec8-d229a237a47c"
	ClientID              string    `json:"client_id"`                // example "example-client"
	UserName              string    `json:"user_name"`                // example "admin"
	Userid                string    `json:"user_id"`                  // example "84f6cffa-4505-48ec-a851-424160892283"
	Scope                 string    `json:"scope"`                    // example "ME"
	RefreshTokenExpiresAt Timestamp `json:"refresh_token_expires_at"` // example 1479309001813
	ExpiresAt             Timestamp `json:"expires_at"`               // example 1479251401814
	ExpiresIn             int       `json:"expires_in"`               // example 28795

Token represents an osiam auth token

Jump to

Keyboard shortcuts

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