goidentity

package module
v0.0.0-...-63451c2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

goidentity

Standard interface for holding authenticated identities and their attributes.

This project has now been converted to use Go modules. Please refer to the latest major version sub directory. This follows the practice outlines at https://blog.golang.org/v2-go-modules

Version

Documentation

Index

Constants

View Source
const (
	CTXKey = "jcmturner/goidentity"
)

Variables

This section is empty.

Functions

func AddToHTTPRequestContext

func AddToHTTPRequestContext(id Identity, r *http.Request) *http.Request

Types

type Authenticator

type Authenticator interface {
	Authenticate() (Identity, bool, error)
	Mechanism() string // gives the name of the type of authentication mechanism
}

type Identity

type Identity interface {
	UserName() string
	SetUserName(s string)
	Domain() string
	SetDomain(s string)
	DisplayName() string
	SetDisplayName(s string)
	Human() bool
	SetHuman(b bool)
	AuthTime() time.Time
	SetAuthTime(t time.Time)
	AuthzAttributes() []string
	AddAuthzAttribute(a string)
	RemoveAuthzAttribute(a string)
	Authenticated() bool
	SetAuthenticated(b bool)
	Authorized(a string) bool
	SessionID() string
	Expired() bool
	Attributes() map[string]interface{}
	SetAttribute(k string, v interface{})
	SetAttributes(map[string]interface{})
	RemoveAttribute(k string)
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
}

func FromHTTPRequestContext

func FromHTTPRequestContext(r *http.Request) Identity

type User

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

func NewUser

func NewUser(username string) User

func (*User) AddAuthzAttribute

func (u *User) AddAuthzAttribute(a string)

func (*User) Attributes

func (u *User) Attributes() map[string]interface{}

func (*User) AuthTime

func (u *User) AuthTime() time.Time

func (*User) Authenticated

func (u *User) Authenticated() bool

func (*User) Authorized

func (u *User) Authorized(a string) bool

func (*User) AuthzAttributes

func (u *User) AuthzAttributes() []string

func (*User) DisableAuthzAttribute

func (u *User) DisableAuthzAttribute(a string)

func (*User) DisplayName

func (u *User) DisplayName() string

func (*User) Domain

func (u *User) Domain() string

func (*User) EnableAuthzAttribute

func (u *User) EnableAuthzAttribute(a string)

func (*User) Expired

func (u *User) Expired() bool

func (*User) Human

func (u *User) Human() bool

func (*User) Marshal

func (u *User) Marshal() ([]byte, error)

func (*User) RemoveAttribute

func (u *User) RemoveAttribute(k string)

func (*User) RemoveAuthzAttribute

func (u *User) RemoveAuthzAttribute(a string)

func (*User) SessionID

func (u *User) SessionID() string

func (*User) SetAttribute

func (u *User) SetAttribute(k string, v interface{})

func (*User) SetAttributes

func (u *User) SetAttributes(a map[string]interface{})

func (*User) SetAuthTime

func (u *User) SetAuthTime(t time.Time)

func (*User) SetAuthenticated

func (u *User) SetAuthenticated(b bool)

func (*User) SetDisplayName

func (u *User) SetDisplayName(s string)

func (*User) SetDomain

func (u *User) SetDomain(s string)

func (*User) SetExpiry

func (u *User) SetExpiry(t time.Time)

func (*User) SetHuman

func (u *User) SetHuman(b bool)

func (*User) SetUserName

func (u *User) SetUserName(s string)

func (*User) Unmarshal

func (u *User) Unmarshal(b []byte) error

func (*User) UserName

func (u *User) UserName() string

Jump to

Keyboard shortcuts

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