extauthapi

package module
v0.0.0-...-7712ad2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package extauthapi implementaton for debugging and testing.

Index

Constants

View Source
const (
	// SessionCookieName is a name of HTTP cookie with session token.
	SessionCookieName = "__AuthKey"
	// CSRFTokenCookieName is a name of HTTP cookie with CSRF token.
	CSRFTokenCookieName = "__CSRFToken" //nolint:gosec
	// CSRFTokenHeaderName is a name of HTTP header with CSRF token bound to session token.
	CSRFTokenHeaderName = "X-CSRFTokenBound" //nolint:gosec
)

Variables

View Source
var NoID = ID(uuid.Nil)

NoID means absent user ID.

Functions

This section is empty.

Types

type Authz

type Authz struct {
	User    bool
	Admin   bool
	Manager bool
}

Authz describes user roles/permissions.

type Client

type Client struct {
}

Client for extauthapi.

func NewClient

func NewClient(endpoint string, tlsConfig *tls.Config, autoRetryCSRF bool) (*Client, error)

NewClient creates and return new client for extauthapi.

func (*Client) GetUserProfile

func (c *Client) GetUserProfile(ctx context.Context, rawCookies string) (*Profile, error)

GetUserProfile gets a cookie with the userID and isolatedEntityID separated by a dot(.) and returns a profile with the values from the cookie. Authn is always true.

func (*Client) Validate

func (c *Client) Validate(ctx context.Context, token, remoteIP string) error

Validate return nil if token is valid

type ID

type ID uuid.UUID

ID contains user ID (UUIDv4) or NoID. On Scan/Unmarshal values nil and empty string are considered NoID. On String/Value/Marshal NoID is 00000000-0000-0000-0000-000000000000.

func MustParseID

func MustParseID(input string) ID

MustParseID returns ID parsed from string input. Same behavior as ParseID, but panics on error.

func NewID

func NewID() ID

NewID returns new user ID.

func ParseID

func ParseID(input string) (id ID, err error)

ParseID returns ID parsed from string input. Input is expected in a form accepted by UnmarshalText.

func (*ID) Scan

func (id *ID) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (ID) String

func (id ID) String() string

Returns canonical string representation of UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

func (*ID) UnmarshalText

func (id *ID) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (ID) Value

func (id ID) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Profile

type Profile struct {
	ID               ID
	Authn            bool
	Authz            Authz
	IsolatedEntityID ID
	DepartmentID     int
	DepartmentName   string
}

Profile describes user profile returned by /get-user-profile.

Jump to

Keyboard shortcuts

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