auth

package
v0.83.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthenticatedAdmin = &SimpleAuthenticator{
	admin:              true,
	authorizedOrgGUIDs: []string{},
}
View Source
var AuthenticatedNonAdmin = &SimpleAuthenticator{
	admin: false,
	authorizedOrgGUIDs: []string{
		"org_guid",
		"org_guid1",
		"org_guid2",
		"00000001-0001-0000-0000-000000000000",
		"00000001-0002-0000-0000-000000000000",
		"00000001-0003-0000-0000-000000000000",
		"00000002-0001-0000-0000-000000000000",
		"00000002-0002-0000-0000-000000000000",
		"00000003-0005-0000-0000-000000000000",
		"o1s1",
		"o2s1",
	},
}
View Source
var FakeBearerToken = "Bearer FAKE_TOKEN"
View Source
var NonAuthenticated = &SimpleAuthenticator{
	admin:              false,
	authorizedOrgGUIDs: []string{},
	authorizationError: nil,
}

Functions

func CreateConfigFromEnv

func CreateConfigFromEnv() (*oauth2.Config, error)

func GetTokenFromRequest

func GetTokenFromRequest(c echo.Context) (string, error)

func SliceMatches

func SliceMatches(requested, allowed []string) (bool, string)

SliceMatches will iterate through both slices to find any incompatibilities in order to determine if the requested access is indeed allowed.

Types

type Authenticator

type Authenticator interface {
	Exchange(c echo.Context) error
	Authorize(c echo.Context) error
	NewAuthorizer(string) (Authorizer, error)
}

type Authorizer

type Authorizer interface {
	Admin() (bool, error)
	HasBillingAccess([]string) (bool, error)
}

type Claims

type Claims struct {
	Val string `json:"val"`
	jwt.StandardClaims
}

type ClientAuthorizer

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

func (*ClientAuthorizer) Admin

func (a *ClientAuthorizer) Admin() (bool, error)

func (*ClientAuthorizer) HasBillingAccess

func (a *ClientAuthorizer) HasBillingAccess(requestedOrgs []string) (bool, error)

type SimpleAuthenticator

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

func (*SimpleAuthenticator) Authorize

func (sa *SimpleAuthenticator) Authorize(c echo.Context) error

func (*SimpleAuthenticator) Exchange

func (sa *SimpleAuthenticator) Exchange(c echo.Context) error

func (*SimpleAuthenticator) NewAuthorizer

func (sa *SimpleAuthenticator) NewAuthorizer(token string) (Authorizer, error)

type SimpleAuthorizer

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

func (*SimpleAuthorizer) Admin

func (sa *SimpleAuthorizer) Admin() (bool, error)

func (*SimpleAuthorizer) HasBillingAccess

func (sa *SimpleAuthorizer) HasBillingAccess(orgs []string) (bool, error)

type UAA

type UAA struct {
	Config *oauth2.Config
}

func (*UAA) Authorize

func (uaa *UAA) Authorize(c echo.Context) error

func (*UAA) Exchange

func (uaa *UAA) Exchange(c echo.Context) error

func (*UAA) NewAuthorizer

func (uaa *UAA) NewAuthorizer(token string) (Authorizer, error)

type UAAClaims

type UAAClaims struct {
	UserID    string   `json:"user_id"`
	Scope     []string `json:"scope"`
	Email     string   `json:"email"`
	UserName  string   `json:"user_name"`
	IssuedAt  int64    `json:"iat"`
	ExpiresAt int64    `json:"exp"`
}

func (*UAAClaims) Valid

func (claims *UAAClaims) Valid() error

Jump to

Keyboard shortcuts

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