models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrGInvalidClient       = errors.New("invalid_client")
	ErrGInvalidInteraction  = errors.New("invalid_interaction")
	ErrGInvalidFlag         = errors.New("invalid_flag")
	ErrGInvalidRotation     = errors.New("invalid_rotation")
	ErrGKRNotSupported      = errors.New("key_rotation_not_supported")
	ErrGInvalidContinuation = errors.New("invalid_continuation")
	ErrGUserDenied          = errors.New("user_denied")
	ErrGRequestDenied       = errors.New("request_denied")
	ErrGUnknownUser         = errors.New("unknown_user")
	ErrGUnknownInteraction  = errors.New("unknown_interaction")
	ErrGTooFast             = errors.New("too_fast")
	ErrGTooManyAttempts     = errors.New("too_many_attempts")
)

Errors corresponding to GNAP error codes

View Source
var DefaultDescription = map[string]string{
	"invalid_request":            "The request is missing a required parameter, includes an invalid parameter value or is otherwise malformed.",
	"invalid_client":             "The request was made from a client that was not recognized or allowed by the AS, or the client's signature validation failed.",
	"invalid_interaction":        "The client instance has provided an interaction reference that is incorrect for this request or the interaction modes in use have expired.",
	"invalid_flag":               "The flag configuration is not valid.",
	"invalid_rotation":           "The token rotation request is not valid.",
	"key_rotation_not_supported": "The AS does not allow rotation of this access token's key.",
	"invalid_continuation":       "The continuation of the referenced grant could not be processed.",
	"user_denied":                "The RO denied the request.",
	"request_denied":             "The request was denied for an unspecified reason.",
	"unknown_user":               "The user presented in the request is not known to the AS or does not match the user present during interaction.",
	"unknown_interaction":        "The interaction integrity could not be established.",
	"too_fast":                   "The client instance did not respect the timeout in the wait response before the next call.",
	"too_many_attempts":          "A limit has been reached in the total number of reasonable attempts.",
}

DefaultDescription is the default description for error codes.

View Source
var ErrInvalidAFormat = errors.New("invalid assertion format")

ErrInvalidAFormat is returned when an assertion format not defined in the registry is encountered.

View Source
var ErrInvalidAccessRight = errors.New("invalid access right")

ErrInvalidAccessRight is returned when an access right object is found to be malformed.

View Source
var ErrInvalidDigestAlg = errors.New("invalid content digest algorithm")

ErrInvalidDigestAlg is returned when a content digest algorithm not defined in the registry is encountered.

View Source
var ErrInvalidErrorCode = errors.New("invalid error code")

ErrInvalidErrorCode is returned when the GNAPError.Code field is not defined in the registry of gnap error codes.

View Source
var ErrInvalidFinishMethod = errors.New("invalid finish method")

ErrInvalidFinishMethod is returned when a finish method not defined in the registry is encountered.

View Source
var ErrInvalidHashMethod = errors.New("invalid hash method")

ErrInvalidHashMethod is returned when a hash method that is not defined in the registry is encountered.

View Source
var ErrInvalidKeyFormat = errors.New("invalid key format")

ErrInvalidKeyFormat is returned when a key format not defined in the registry is encountered.

View Source
var ErrInvalidProofMethod = errors.New("invalid proof method")

ErrInvalidProofMethod is returned when a key proof method not defined in the registry is encountered.

View Source
var ErrInvalidSigAlg = errors.New("invalid http signature algorithm")

ErrInvalidSigAlg is returned when a http signature algorithm not defined in the registry is encountered.

View Source
var ErrInvalidStartMode = errors.New("invalid start mode")

ErrInvalidStartMode is returned when a start mode not defined in the registry is encountered.

View Source
var ErrInvalidTokenFlag = errors.New("invalid token flag")

ErrInvalidTokenFlag is returned when a token flag not defined in the registry is encountered.

View Source
var ErrInvalidTokenRequest = errors.New("invalid token request")

ErrInvalidTokenRequest is returned when a token request is found to be malformed.

View Source
var ErrInvalidTokenResponse = errors.New("invalid token response")

ErrInvalidTokenResponse is returned when a token response is found to be malformed.

View Source
var ErrInvalidURL = errors.New("invalid url")

ErrInvalidURL is the error returned in case of invalid URL during json marshaling, unmarshaling or parsing of URL.

Functions

func MultiToken

func MultiToken(tokens ...TokenRequest) requestOption

MultiToken is an optional parameter for NewRequest to request for multiple access tokens.

func SingleToken

func SingleToken(token TokenRequest) requestOption

SingleToken is an optional parameter for NewRequest to request for single access token.

func WithContinue

func WithContinue(con ContinueResponse) responseOption

WithContinue is an optional parameter for NewResponse to convey the means of flow continuation to the client.

func WithError

func WithError(err GNAPError) responseOption

WithError is an optional parameter for NewResponse to respond with an error to the client.

func WithExpiry

func WithExpiry(seconds int) tokenResponseOption

WithExpiry is optional parameter for NewTokenResponse to provide expiry duration for the access token.

func WithFlag

func WithFlag(flag TokenFlag) tokenRequestOption

WithFlag is optional parameter for NewTokenRequest to mention the flags associated with the token.

func WithFlags

func WithFlags(flags []TokenFlag) tokenResponseOption

WithFlags is optional parameter for NewTokenResponse to mention the flags associated with the access token.

func WithInstanceID

func WithInstanceID(id string) responseOption

WithInstanceID is an optional parameter for NewResponse to attribute a unique instance ID to the ongoing GNAP flow.

func WithInteract

func WithInteract(ia IARequest) requestOption

WithInteract is an optional parameter for NewRequest to convey mode of interaction.

func WithInteractResponse

func WithInteractResponse(ia IAResponse) responseOption

WithInteractResponse is an optional parameter for NewResponse to convey the interaction urls to the client.

func WithKey

func WithKey(key ClientKey) tokenResponseOption

WithKey is optional parameter for NewTokenResponse to provide the key to be presented with the access token.

func WithLabel

func WithLabel(label string) tokenRequestOption

WithLabel is optional parameter for NewTokenRequest to request a label for the token.

func WithLabelResponse

func WithLabelResponse(label string) tokenResponseOption

WithLabelResponse is optional parameter for NewTokenResponse to provide the label with the access token.

func WithManage

func WithManage(manage URL) tokenResponseOption

WithManage is optional parameter for NewTokenResponse to provide the token management URI.

func WithMultiResponse

func WithMultiResponse(tokens ...TokenResponse) responseOption

WithSingleResponse is an optional parameter for NewResponse to grant multiple access token.

func WithSingleResponse

func WithSingleResponse(token TokenResponse) responseOption

WithSingleResponse is an optional parameter for NewResponse to grant single access token.

func WithSubject

func WithSubject(sub SubRequest) requestOption

WithSubject is an optional parameter for NewRequest to request for subject information.

func WithSubjectResponse

func WithSubjectResponse(sub SubResponse) responseOption

WithSubjectResponse is an optional parameter for NewResponse to convey subject information to the client.

func WithUser

func WithUser(user EndUser) requestOption

WithUser is an optional parameter for NewRequest to identify the RO to the AS.

Types

type ATRequest

type ATRequest struct {
	Single   TokenRequest
	Multiple []TokenRequest
}

ATRequest is a wrapper aroung TokenRequest for managing single and multiple access token requests.

func (ATRequest) MarshalJSON

func (req ATRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*ATRequest) UnmarshalJSON

func (req *ATRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.UnmarshalJSON interface.

type ATResponse

type ATResponse struct {
	Single   TokenResponse
	Multiple []TokenResponse
}

ATResponse is a wrapper around TokenResponse for managing single and multiple access token responses.

func (ATResponse) MarshalJSON

func (req ATResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*ATResponse) UnmarshalJSON

func (req *ATResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type AccessRight

type AccessRight struct {
	Type       string   `json:"type"`
	Actions    []string `json:"actions,omitempty"`
	Locations  []string `json:"locations,omitempty"`
	Datatypes  []string `json:"datatypes,omitempty"`
	Identifier string   `json:"identifier,omitempty"`
	Privileges []string `json:"privileges,omitempty"`
	Ref        string   `json:"-"`
}

AccessRight represents the rights and privileges requested or granted during a gnap request flow.

func (AccessRight) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (*AccessRight) UnmarshalJSON

func (r *AccessRight) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Assertion

type Assertion struct {
	Value  string          `json:"value"`
	Format AssertionFormat `json:"format"`
}

Assertion represents identity assertions used to convey subject information.

type AssertionFormat

type AssertionFormat string

AssertionFormat is a valid assertion format as defined in the draft.

const (
	AFidToken AssertionFormat = "id_token"
	AFsaml2   AssertionFormat = "saml2"
)

Registry of valid assertion formats.

func (AssertionFormat) MarshalJSON

func (af AssertionFormat) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*AssertionFormat) UnmarshalJSON

func (af *AssertionFormat) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type ClientDisplay

type ClientDisplay struct {
	Name string `json:"name"`
	URI  URL    `json:"uri,omitempty"`
}

ClientDisplay presents information regarding the client instance for displaying to the user.

type ClientInstance

type ClientInstance struct {
	Key     ClientKey     `json:"key"`
	ClassID string        `json:"class_id,omitempty"`
	Display ClientDisplay `json:"display,omitempty"`
	Ref     string
}

ClientInstance defines a client by reference (string) or by value (object).

func NewClient

func NewClient(key ClientKey, options ...clientOption) (client ClientInstance, err error)

NewClient is the constructor for client instance by value (object).

type ClientKey

type ClientKey struct {
	Proof    Proofer         `json:"proof"`
	JWK      json.RawMessage `json:"jwk,omitempty"`
	Cert     string          `json:"cert,omitempty"`
	CertS256 string          `json:"cert#S256,omitempty"`
	Ref      string          `json:"-"`
}

ClientKey the key object of the client. It is used as either a key object by value (object) or by reference (string).

type ContinueRequest

type ContinueRequest struct {
	InteractRef string `json:"interact_ref"`
}

ContinueRequest represents the continuation request sent by the client instance after successful interaction.

type ContinueResponse

type ContinueResponse struct {
	URI   URL           `json:"uri"`
	Wait  int           `json:"wait"`
	Token ContinueToken `json:"access_token"`
}

ContinueResponse represents the continuation object returned by the AS during the gnap request flow.

type ContinueToken

type ContinueToken struct {
	Value     string      `json:"value"`
	Label     string      `json:"label,omitempty"`
	Manage    URL         `json:"manage,omitempty"`
	ExpiresIn int         `json:"expires_in,omitempty"`
	Flags     []TokenFlag `json:"flags,omitempty"`
}

ContinueToken represents continuation access token to be presented for continuation request.

type DigestAlg

type DigestAlg string

DigestAlg represents HTTP Content Digest algorithm.

const (
	DigestSha256 DigestAlg = httpsign.DigestSha256
	DigestSha512 DigestAlg = httpsign.DigestSha512
)

Registry of http content digest algorithms.

func (DigestAlg) MarshalJSON

func (alg DigestAlg) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*DigestAlg) UnmarshalJSON

func (alg *DigestAlg) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type Discovery

type Discovery struct {
	GrantRequest  URL               `json:"grant_request_endpoint"`
	StartModes    []StartMode       `json:"interaction_start_modes_supported,omitempty"`
	FinishMethods []FinishMethod    `json:"interaction_finish_methods_supported,omitempty"`
	KeyProofs     []ProofMethod     `json:"key_proofs_supported,omitempty"`
	SubFormats    []subject.Format  `json:"sub_id_formats_supported,omitempty"`
	AFormats      []AssertionFormat `json:"assertion_formats_supported,omitempty"`
	KeyRotation   bool              `json:"key_rotation_supported,omitempty"`
}

Discovery represents the server's discovery information.

type EndUser

type EndUser struct {
	SubIDs     []subject.ID `json:"sub_ids,omitempty"`
	Assertions []Assertion  `json:"assertions,omitempty"`
	Ref        string       `json:"-"`
}

EndUser identifies the end user to the AS in a manner that the AS can verify (by value or by reference), either directly or by interacting with the end user to determine their status as the RO.

func (EndUser) MarshalJSON

func (u EndUser) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*EndUser) UnmarshalJSON

func (u *EndUser) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type FinishMethod

type FinishMethod string

FinishMethod indicates how the client instance can receive an indication that interaction has finished at the AS.

const (
	MethodPush     FinishMethod = "push"
	MethodRedirect FinishMethod = "redirect"
)

Contents of Interaction Finish Methods Registry.

func (FinishMethod) MarshalJSON

func (fm FinishMethod) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*FinishMethod) UnmarshalJSON

func (fm *FinishMethod) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type GNAPError

type GNAPError struct {
	Code string `json:"code"`
	Desc string `json:"description,omitempty"`
}

GNAPError is the error occurred during the GNAP protocol.

Example

ExampleGNAPError decodes a json data into GNAPError and checks that error is equivalent to ErrGInvalidClient.

type response struct {
	Token string    `json:"token,omitempty"`
	Error GNAPError `json:"error,omitempty"`
}
data := []byte(`{"error":{"code": "invalid_client","description":"client not recognized"}}`)
var res response
_ = json.Unmarshal(data, &res)
fmt.Println(res.Error)
fmt.Println(errors.Is(res.Error, ErrGInvalidClient))
Output:

invalid_client: client not recognized
true

func (GNAPError) Error

func (e GNAPError) Error() string

Error implements error interface.

func (GNAPError) Is

func (e GNAPError) Is(target error) bool

Is implements errors.Is.

func (GNAPError) Unwrap

func (e GNAPError) Unwrap() error

Unwrap returns the underlying error corresponding to the status code, or ErrInvalidErrorCode if status code is invalid.

type GrantRequest

type GrantRequest struct {
	AccessToken ATRequest      `json:"access_token,omitempty"`
	Subject     SubRequest     `json:"subject,omitempty"`
	Client      ClientInstance `json:"client"`
	User        EndUser        `json:"user,omitempty"`
	Interact    IARequest      `json:"interact,omitempty"`
}

GrantRequest represents the grant request for initiation of the gnap flow.

func NewRequest

func NewRequest(client ClientInstance, options ...requestOption) (req GrantRequest, err error)

NewRequest is constructor for GrantRequest with mandatory client and optional parameters.

type GrantResponse

type GrantResponse struct {
	Continue    ContinueResponse `json:"continue,omitempty"`
	AccessToken ATResponse       `json:"access_token,omitempty"`
	Interact    IAResponse       `json:"interact,omitempty"`
	Subject     SubResponse      `json:"subject,omitempty"`
	InstanceID  string           `json:"instance_id,omitempty"`
	Error       GNAPError        `json:"error,omitempty"`
}

GrantResponse represents the AS response to a grant request.

func NewResponse

func NewResponse(options ...responseOption) (res GrantResponse, err error)

NewRequest is constructor for GrantResponse with optional parameters.

type HTTPSig

type HTTPSig struct {
	Method    ProofMethod `json:"method"` // == "httpsig"
	SigAlg    HTTPSigAlg  `json:"alg"`
	DigestAlg DigestAlg   `json:"content-digest"`
}

HTTPSig represents HTTP signature proofing method.

func (HTTPSig) Proof

func (sig HTTPSig) Proof() ProofMethod

Proof implements Proofer interface.

type HTTPSigAlg

type HTTPSigAlg string

HTTPSigAlg represents http signature algorithm.

const (
	RSA_PSS_SHA512    HTTPSigAlg = "rsa-pss-sha512"
	RSA_SHA256        HTTPSigAlg = "rsa-v1_5-sha256"
	HMAC_SHA256       HTTPSigAlg = "hmac-sha256"
	ECDSA_P256_SHA256 HTTPSigAlg = "ecdsa-p256-sha256"
	ECDSA_P384_SHA384 HTTPSigAlg = "ecdsa-p384-sha384"
	ED25519           HTTPSigAlg = "ed25519"
)

Registry of http signature algorithms.

func (HTTPSigAlg) MarshalJSON

func (alg HTTPSigAlg) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*HTTPSigAlg) UnmarshalJSON

func (alg *HTTPSigAlg) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type HashMethod

type HashMethod string

HashMethod is a hash name string from IANA Named Information Hash Algorithm Registry.

Example
package main

import (
	"encoding/hex"
	"encoding/json"
	"fmt"
)

var data = []byte("hello world")

func main() {
	var hash HashMethod
	_ = json.Unmarshal([]byte(`"sha-512"`), &hash)
	bytes := hash.Sum(data)
	fmt.Println(hex.EncodeToString(bytes))
}
Output:

309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
const (
	SHA_256  HashMethod = "sha-256"  // [RFC6920]
	SHA_384  HashMethod = "sha-384"  // [FIPS 180-4]
	SHA_512  HashMethod = "sha-512"  // [FIPS 180-4]
	SHA3_224 HashMethod = "sha3-224" // [FIPS 202]
	SHA3_384 HashMethod = "sha3-384" // [FIPS 202]
	SHA3_512 HashMethod = "sha3-512" // [FIPS 202]

	BLAKE2s_256 HashMethod = "blake2s-256" // [RFC7693]
	BLAKE2b_256 HashMethod = "blake2b-256" // [RFC7693]
	BLAKE2b_512 HashMethod = "blake2b-512" // [RFC7693]
)

Contents of IANA Named Information Hash Algorithm Registry.

func (HashMethod) MarshalJSON

func (hm HashMethod) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (HashMethod) Sum

func (hm HashMethod) Sum(data []byte) []byte

Sum calculates cryptographic hash digest using hm HashMethod. Returns nil if the hash algorithm is not present in the registry.

func (*HashMethod) UnmarshalJSON

func (hm *HashMethod) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type IACallback

type IACallback struct {
	Hash        string `json:"hash"`
	InteractRef string `json:"interact_ref"`
}

IACallback represents the information conveyed to the client through the interaction callback.

func FromQuery

func FromQuery(params url.Values) IACallback

FromQuery constructs a new IACallback from the given query string parameters.

func (IACallback) Encode

func (c IACallback) Encode() url.Values

Encode creates query parameters from the IACallback object.

type IACodeURI

type IACodeURI struct {
	Code string `json:"code"`
	URI  URL    `json:"uri"`
}

IACodeURI represents a User Code or URI object that indicates a short user-typable code and a short URI.

type IAFinish

type IAFinish struct {
	Method     FinishMethod `json:"method"`
	URI        *URL         `json:"uri"`
	Nonce      string       `json:"nonce"`
	HashMethod HashMethod   `json:"hash_method,omitempty"`
}

IAFinish indicates how the client instance can receive an indication that interaction has finished at the AS.

type IAHints

type IAHints struct {
	UILocales []string `json:"ui_locales,omitempty"`
}

IAHints provides additional information to inform the interaction process at the AS.

type IARequest

type IARequest struct {
	Start  []IAStart `json:"start"`
	Finish *IAFinish `json:"finish,omitempty"`
	Hints  *IAHints  `json:"hints,omitempty"`
}

IARequest describes the modes that the client instance supports for allowing the RO to interact with the AS and modes for the client instance to receive updates when interaction is complete.

type IAResponse

type IAResponse struct {
	Redirect  *URL       `json:"redirect,omitempty"`
	App       *URL       `json:"app,omitempty"`
	UserCode  string     `json:"user_code,omitempty"`
	CodeURI   *IACodeURI `json:"user_code_uri,omitempty"`
	Finish    string     `json:"finish,omitempty"`
	ExpiresIn int        `json:"expires_in,omitempty"`
}

IAResponse indicates that interaction through some set of defined mechanisms needs to take place.

type IAStart

type IAStart struct {
	Mode  StartMode `json:"mode"`
	IsRef bool      `json:"-"`
}

IAStart indicates how the client instance can start an interaction.

func (IAStart) MarshalJSON

func (ias IAStart) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. Encodes to json string or json object with mode property.

func (*IAStart) UnmarshalJSON

func (ias *IAStart) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface. Decodes from a start mode string or a start mode object.

type KeyFormat

type KeyFormat string

KeyFormat defines enum of permitted key formats.

const (
	FormatJWK      KeyFormat = "jwk"
	FormatCert     KeyFormat = "cert"
	FormatCertS256 KeyFormat = "cert#S256"
)

Registry of KeyFormat values.

func (KeyFormat) MarshalJSON

func (kf KeyFormat) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.MarshalJSON interface.

func (*KeyFormat) UnmarshalJSON

func (kf *KeyFormat) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type ProofMethod

type ProofMethod string

ProofMethod represents the proofing method for presenting the key.

const (
	ProofHTTPSig ProofMethod = "httpsig"
	ProofMTLS    ProofMethod = "mtls"
	ProofJWSD    ProofMethod = "jwsd"
	ProofJWS     ProofMethod = "jws"
)

Registry of permitted ProofMethods.

func (ProofMethod) MarshalJSON

func (p ProofMethod) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (ProofMethod) Proof

func (p ProofMethod) Proof() ProofMethod

Proof implements the [Proof] interface.

func (*ProofMethod) UnmarshalJSON

func (p *ProofMethod) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Proofer

type Proofer interface {
	Proof() ProofMethod
}

Proofer describes any object that conveys the proofing information.

type StartMode

type StartMode string

StartMode indicates how the client instance can start an interaction.

const (
	ModeRedirect StartMode = "redirect"
	ModeApp      StartMode = "app"
	ModeCode     StartMode = "user_code"
	ModeCodeURI  StartMode = "user_code_uri"
)

Contents of Interaction Start Modes Registry.

func (StartMode) MarshalJSON

func (sm StartMode) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*StartMode) UnmarshalJSON

func (sm *StartMode) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type SubRequest

type SubRequest struct {
	SFormats []subject.Format  `json:"sub_id_formats,omitempty"`
	AFormats []AssertionFormat `json:"assertion_formats,omitempty"`
	SubIDs   []subject.ID      `json:"sub_ids,omitempty"`
}

SubRequest describes the information about the RO that the client instance is requesting to be returned directly in the response from the AS.

type SubResponse

type SubResponse struct {
	SubIDs     []subject.ID `json:"sub_ids,omitempty"`
	Assertions []Assertion  `json:"assertions,omitempty"`
	UpdatedAt  time.Time    `json:"updated_at,omitempty"`
}

SubResponse contains claims about the RO as known and declared by the AS.

type TokenFlag

type TokenFlag string

TokenFlag represents GNAP access token flags.

const (
	FlagBearer  TokenFlag = "bearer"
	FlagDurable TokenFlag = "durable"
)

Registry of access token flags.

func (TokenFlag) MarshalJSON

func (tf TokenFlag) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*TokenFlag) UnmarshalJSON

func (tf *TokenFlag) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type TokenRequest

type TokenRequest struct {
	Access []AccessRight `json:"access"`
	Label  string        `json:"label,omitempty"`
	Flags  []TokenFlag   `json:"flags,omitempty"`
}

TokenRequest represents access token request object for requesting access to resources.

func NewTokenRequest

func NewTokenRequest(rights []AccessRight, options ...tokenRequestOption) (req TokenRequest, err error)

NewTokenRequest is a constructor for TokenRequest.

type TokenResponse

type TokenResponse struct {
	Value     string        `json:"value"`
	Label     string        `json:"label,omitempty"`
	Manage    URL           `json:"manage,omitempty"`
	Access    []AccessRight `json:"access"`
	ExpiresIn int           `json:"expires_in,omitempty"`
	Key       ClientKey     `json:"key,omitempty"`
	Flags     []TokenFlag   `json:"flags,omitempty"`
}

TokenResponse represents the access token granted by the AS.

func NewTokenResponse

func NewTokenResponse(value string, access []AccessRight, options ...tokenResponseOption) (res TokenResponse, err error)

NewTokenResponse is constructor for TokenResponse.

type URL

type URL struct {
	*url.URL
}

URL is wrapper around url.URL with json marshaling and unmarshaling.

Example
type request struct {
	URL  URL    `json:"url"`
	Name string `json:"name"`
}
data := `{"name":"GitHub","url":"https://github.com/"}`
var req request
_ = json.Unmarshal([]byte(data), &req)
fmt.Println(req.Name, req.URL)
Output:

GitHub https://github.com/

func ParseURL

func ParseURL(raw string) (URL, error)

ParseURL is a helper function for creating URL. It is perfectly alright to directly create URL from struct literals.

func (URL) MarshalJSON

func (u URL) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

Jump to

Keyboard shortcuts

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