resources

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorize

type Authorize struct {
	Key
	Attributes AuthorizeAttributes `json:"attributes"`
}

type AuthorizeAdmin

type AuthorizeAdmin struct {
	Key
	Attributes AuthorizeAdminAttributes `json:"attributes"`
}

type AuthorizeAdminAttributes

type AuthorizeAdminAttributes struct {
	// Password to get admin permissions
	Password string `json:"password"`
}

type AuthorizeAdminListRequest

type AuthorizeAdminListRequest struct {
	Data     []AuthorizeAdmin `json:"data"`
	Included Included         `json:"included"`
	Links    *Links           `json:"links"`
	Meta     json.RawMessage  `json:"meta,omitempty"`
}

func (*AuthorizeAdminListRequest) GetMeta

func (r *AuthorizeAdminListRequest) GetMeta(out interface{}) error

func (*AuthorizeAdminListRequest) PutMeta

func (r *AuthorizeAdminListRequest) PutMeta(v interface{}) (err error)

type AuthorizeAdminRequest

type AuthorizeAdminRequest struct {
	Data     AuthorizeAdmin `json:"data"`
	Included Included       `json:"included"`
}

type AuthorizeAttributes

type AuthorizeAttributes struct {
	// Backend-generated challenge, signed by user
	Signature string `json:"signature"`
}

type AuthorizeListRequest

type AuthorizeListRequest struct {
	Data     []Authorize     `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*AuthorizeListRequest) GetMeta

func (r *AuthorizeListRequest) GetMeta(out interface{}) error

func (*AuthorizeListRequest) PutMeta

func (r *AuthorizeListRequest) PutMeta(v interface{}) (err error)

type AuthorizeRequest

type AuthorizeRequest struct {
	Data     Authorize `json:"data"`
	Included Included  `json:"included"`
}

type Challenge

type Challenge struct {
	Key
	Attributes ChallengeAttributes `json:"attributes"`
}

type ChallengeAttributes

type ChallengeAttributes struct {
	// Random hex strings challenge which must be signed by user to authorize
	Challenge string `json:"challenge"`
}

type ChallengeListResponse

type ChallengeListResponse struct {
	Data     []Challenge     `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*ChallengeListResponse) GetMeta

func (r *ChallengeListResponse) GetMeta(out interface{}) error

func (*ChallengeListResponse) PutMeta

func (r *ChallengeListResponse) PutMeta(v interface{}) (err error)

type ChallengeResponse

type ChallengeResponse struct {
	Data     Challenge `json:"data"`
	Included Included  `json:"included"`
}

type Claim

type Claim struct {
	// Address authorized with
	Address string `json:"address"`
	// Whether the user has a admin permissions
	IsAdmin bool `json:"is_admin"`
}

Authorized user personal data

type Details

type Details json.RawMessage

func (Details) MarshalJSON

func (d Details) MarshalJSON() ([]byte, error)

MarshalJSON - casts Details to []byte

func (*Details) Scan

func (r *Details) Scan(src interface{}) error

Scan - implements db driver method for auto unmarshal

func (Details) String

func (d Details) String() string

func (*Details) UnmarshalJSON

func (d *Details) UnmarshalJSON(data []byte) error

UnmarshalJSON - casts data to Details

func (Details) Value

func (r Details) Value() (driver.Value, error)

Value - implements db driver method for auto marshal

type Flag

type Flag struct {
	Name  string `json:"name"`
	Value int32  `json:"value"`
}

type Flagger

type Flagger interface {
	IsFlag() bool
}

type Flags

type Flags struct {
	Mask   int32  `json:"mask"`
	Values []Flag `json:"flags"`
}

func FlagsFromMask

func FlagsFromMask(mask int32, allFlags map[int32]string) Flags

type Included

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

Included - an array of Resource objects that are related to the primary data and/or each other (“included resources”).

func (*Included) Add

func (c *Included) Add(includes ...Resource)

Add - adds new include into collection. If one already present - skips it

func (Included) MarshalJSON

func (c Included) MarshalJSON() ([]byte, error)

MarshalJSON - marshals include collection as array of json objects

func (*Included) MustAuthorize

func (c *Included) MustAuthorize(key Key) *Authorize

MustAuthorize - returns Authorize from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustAuthorizeAdmin

func (c *Included) MustAuthorizeAdmin(key Key) *AuthorizeAdmin

MustAuthorizeAdmin - returns AuthorizeAdmin from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustChallenge

func (c *Included) MustChallenge(key Key) *Challenge

MustChallenge - returns Challenge from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustToken

func (c *Included) MustToken(key Key) *Token

MustToken - returns Token from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustValidation

func (c *Included) MustValidation(key Key) *Validation

MustValidation - returns Validation from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) UnmarshalJSON

func (c *Included) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshal array of json objects into include collection

type Jwt

type Jwt struct {
	// Base64 encoded JWT
	Token     string `json:"token"`
	TokenType string `json:"token_type"`
}

JWT token

type Key

type Key struct {
	ID   string       `json:"id"`
	Type ResourceType `json:"type"`
}

func NewKeyInt64

func NewKeyInt64(id int64, resourceType ResourceType) Key

func (Key) AsRelation

func (r Key) AsRelation() *Relation

func (*Key) GetKey

func (r *Key) GetKey() Key

func (Key) GetKeyP

func (r Key) GetKeyP() *Key
type Links struct {
	First string `json:"first,omitempty"`
	Last  string `json:"last,omitempty"`
	Next  string `json:"next,omitempty"`
	Prev  string `json:"prev,omitempty"`
	Self  string `json:"self,omitempty"`
}

type Relation

type Relation struct {
	Data  *Key   `json:"data,omitempty"`
	Links *Links `json:"links,omitempty"`
}

type RelationCollection

type RelationCollection struct {
	Data  []Key  `json:"data"`
	Links *Links `json:"links,omitempty"`
}

func (RelationCollection) MarshalJSON

func (r RelationCollection) MarshalJSON() ([]byte, error)

type Resource

type Resource interface {
	//GetKey - returns key of the Resource
	GetKey() Key
}

type ResourceType

type ResourceType string
const (
	AUTHORIZE  ResourceType = "authorize"
	CHALLENGE  ResourceType = "challenge"
	TOKEN      ResourceType = "token"
	VALIDATION ResourceType = "validation"
)

List of ResourceType

type Token

type Token struct {
	Key
	Attributes TokenAttributes `json:"attributes"`
}

type TokenAttributes

type TokenAttributes struct {
	AccessToken  Jwt `json:"access_token"`
	RefreshToken Jwt `json:"refresh_token"`
}

type TokenListResponse

type TokenListResponse struct {
	Data     []Token         `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*TokenListResponse) GetMeta

func (r *TokenListResponse) GetMeta(out interface{}) error

func (*TokenListResponse) PutMeta

func (r *TokenListResponse) PutMeta(v interface{}) (err error)

type TokenResponse

type TokenResponse struct {
	Data     Token    `json:"data"`
	Included Included `json:"included"`
}

type Validation

type Validation struct {
	Key
	Attributes ValidationAttributes `json:"attributes"`
}

type ValidationAttributes

type ValidationAttributes struct {
	Claims []Claim `json:"claims"`
}

type ValidationListResponse

type ValidationListResponse struct {
	Data     []Validation    `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*ValidationListResponse) GetMeta

func (r *ValidationListResponse) GetMeta(out interface{}) error

func (*ValidationListResponse) PutMeta

func (r *ValidationListResponse) PutMeta(v interface{}) (err error)

type ValidationResponse

type ValidationResponse struct {
	Data     Validation `json:"data"`
	Included Included   `json:"included"`
}

Jump to

Keyboard shortcuts

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