v0

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package v0 provides primitives to interact the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandlers

func RegisterHandlers(router interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

Types

type AccessTokenRequestFailedResponse

type AccessTokenRequestFailedResponse struct {
	Error string `json:"error"`

	// Human-readable ASCII text providing additional information, used to assist the client developer in understanding the error that occurred.
	ErrorDescription string `json:"error_description"`
}

AccessTokenRequestFailedResponse defines model for AccessTokenRequestFailedResponse.

type AccessTokenResponse

type AccessTokenResponse struct {

	// The access token issued by the authorization server.
	// Could be a signed JWT or a random number. It should not have a meaning to the client.
	AccessToken string `json:"access_token"`

	// The lifetime in seconds of the access token.
	ExpiresIn float32 `json:"expires_in"`

	// The type of the token issued
	TokenType string `json:"token_type"`
}

AccessTokenResponse defines model for AccessTokenResponse.

type Contract

type Contract struct {

	// Language of the contract in all caps
	Language           Language  `json:"language"`
	SignerAttributes   *[]string `json:"signer_attributes,omitempty"`
	Template           *string   `json:"template,omitempty"`
	TemplateAttributes *[]string `json:"template_attributes,omitempty"`

	// Type of which contract to sign
	Type Type `json:"type"`

	// Version of the contract
	Version Version `json:"version"`
}

Contract defines model for Contract.

type ContractSigningRequest

type ContractSigningRequest struct {

	// Language of the contract in all caps
	Language Language `json:"language"`

	// Identifier of the legalEntity as registered in the Nuts registry
	LegalEntity LegalEntity `json:"legalEntity"`

	// Type of which contract to sign
	Type Type `json:"type"`

	// ValidFrom describes the time from which this contract should be considered valid
	ValidFrom *string `json:"valid_from,omitempty"`

	// ValidTo describes the time until this contract should be considered valid
	ValidTo *string `json:"valid_to,omitempty"`

	// Version of the contract
	Version Version `json:"version"`
}

ContractSigningRequest defines model for ContractSigningRequest.

type CreateAccessTokenJSONBody

type CreateAccessTokenJSONBody CreateAccessTokenRequest

CreateAccessTokenJSONBody defines parameters for CreateAccessToken.

type CreateAccessTokenJSONRequestBody

type CreateAccessTokenJSONRequestBody CreateAccessTokenJSONBody

CreateAccessTokenRequestBody defines body for CreateAccessToken for application/json ContentType.

type CreateAccessTokenParams

type CreateAccessTokenParams struct {
	XSslClientCert   string  `json:"X-Ssl-Client-Cert"`
	XNutsLegalEntity *string `json:"X-Nuts-LegalEntity,omitempty"`
}

CreateAccessTokenParams defines parameters for CreateAccessToken.

type CreateAccessTokenRequest

type CreateAccessTokenRequest struct {

	// Base64 encoded JWT following rfc7523 and the Nuts documentation
	Assertion string `json:"assertion"`

	// always must contain the value "urn:ietf:params:oauth:grant-type:jwt-bearer"
	GrantType string `json:"grant_type"`
}

CreateAccessTokenRequest defines model for CreateAccessTokenRequest.

type CreateJwtBearerTokenJSONBody

type CreateJwtBearerTokenJSONBody CreateJwtBearerTokenRequest

CreateJwtBearerTokenJSONBody defines parameters for CreateJwtBearerToken.

type CreateJwtBearerTokenJSONRequestBody

type CreateJwtBearerTokenJSONRequestBody CreateJwtBearerTokenJSONBody

CreateJwtBearerTokenRequestBody defines body for CreateJwtBearerToken for application/json ContentType.

type CreateJwtBearerTokenRequest

type CreateJwtBearerTokenRequest struct {
	Actor     string `json:"actor"`
	Custodian string `json:"custodian"`

	// Base64 encoded IRMA contract conaining the identity of the performer
	Identity string `json:"identity"`

	// Space-delimited list of strings. For what kind of operations can the access token be used? Scopes will be specified for each use-case
	Scope   string  `json:"scope"`
	Subject *string `json:"subject,omitempty"`
}

CreateJwtBearerTokenRequest defines model for CreateJwtBearerTokenRequest.

type CreateSessionJSONBody

type CreateSessionJSONBody ContractSigningRequest

CreateSessionJSONBody defines parameters for CreateSession.

type CreateSessionJSONRequestBody

type CreateSessionJSONRequestBody CreateSessionJSONBody

CreateSessionRequestBody defines body for CreateSession for application/json ContentType.

type CreateSessionResult

type CreateSessionResult struct {

	// Qr contains the data of an IRMA session QR (as generated by irma_js), suitable for NewSession()
	QrCodeInfo IrmaQR `json:"qr_code_info"`

	// a session identifier
	SessionId string `json:"session_id"`
}

CreateSessionResult defines model for CreateSessionResult.

type DisclosedAttribute

type DisclosedAttribute struct {
	Identifier string                 `json:"identifier"`
	Rawvalue   *string                `json:"rawvalue,omitempty"`
	Status     string                 `json:"status"`
	Value      map[string]interface{} `json:"value"`
}

DisclosedAttribute defines model for DisclosedAttribute.

type DisclosedAttributeIndex

type DisclosedAttributeIndex struct {
	Attr *int `json:"attr,omitempty"`
	Cred *int `json:"cred,omitempty"`
}

DisclosedAttributeIndex defines model for DisclosedAttributeIndex.

type ErrorString

type ErrorString string

ErrorString defines model for ErrorString.

type GetContractByTypeParams

type GetContractByTypeParams struct {

	// The version of this contract. If omitted, the most recent version will be returned
	Version  *string `json:"version,omitempty"`
	Language *string `json:"language,omitempty"`
}

GetContractByTypeParams defines parameters for GetContractByType.

type IrmaQR

type IrmaQR struct {
	Irmaqr string `json:"irmaqr"`

	// Server with which to perform the session (URL)
	U string `json:"u"`
}

IrmaQR defines model for IrmaQR.

type JwtBearerTokenResponse

type JwtBearerTokenResponse struct {
	BearerToken string `json:"bearer_token"`
}

JwtBearerTokenResponse defines model for JwtBearerTokenResponse.

type Language

type Language string

Language defines model for Language.

type LegalEntity

type LegalEntity string

LegalEntity defines model for LegalEntity.

type Proof

type Proof interface{}

Proof defines model for Proof.

type ProofD

type ProofD struct {
	A          *float32                `json:"A,omitempty"`
	ADisclosed *map[string]interface{} `json:"a_disclosed,omitempty"`
	AResponses *map[string]interface{} `json:"a_responses,omitempty"`
	C          *float32                `json:"c,omitempty"`
	EResponse  *float32                `json:"e_response,omitempty"`
	VResponse  *float32                `json:"v_response,omitempty"`
}

ProofD defines model for ProofD.

type ProofP

type ProofP struct {
	P         *float32 `json:"P,omitempty"`
	C         *float32 `json:"c,omitempty"`
	SResponse *float32 `json:"s_response,omitempty"`
}

ProofP defines model for ProofP.

type ProofS

type ProofS struct {
	C         *float32 `json:"c,omitempty"`
	EResponse *float32 `json:"e_response,omitempty"`
}

ProofS defines model for ProofS.

type ProofU

type ProofU struct {
	U              *float32 `json:"U,omitempty"`
	C              *float32 `json:"c,omitempty"`
	SResponse      *float32 `json:"s_response,omitempty"`
	VPrimeResponse *float32 `json:"v_prime_response,omitempty"`
}

ProofU defines model for ProofU.

type RemoteError

type RemoteError struct {
	Description *string `json:"description,omitempty"`
	Error       *string `json:"error,omitempty"`
	Message     *string `json:"message,omitempty"`
	Stacktrace  *string `json:"stacktrace,omitempty"`
	Status      *int    `json:"status,omitempty"`
}

RemoteError defines model for RemoteError.

type ServerInterface

type ServerInterface interface {
	// Create an access token based on the OAuth JWT Bearer flow.
	// This endpoint must be available to the outside world for other applications to request access tokens.
	// It requires a two-way TLS connection. The client certificate must be a sibling of the signing certificate of the given JWT.
	// The client certificate must be passed using a X-Ssl-Client-Cert header, PEM encoded and urlescaped.
	// (POST /auth/accesstoken)
	CreateAccessToken(ctx echo.Context, params CreateAccessTokenParams) error
	// Verifies the access token given in the Authorization header (as bearer token). If it's a valid access token issued by this server, it'll return a 200 status code.
	// If it cannot be verified it'll return 403. Note that it'll not return the contents of the access token. The introspection API is for that.
	// (HEAD /auth/accesstoken/verify)
	VerifyAccessToken(ctx echo.Context, params VerifyAccessTokenParams) error
	// CreateSessionHandler Initiates an IRMA signing session with the correct contract.
	// (POST /auth/contract/session)
	CreateSession(ctx echo.Context) error
	// returns the result of the contract request
	// (GET /auth/contract/session/{id})
	SessionRequestStatus(ctx echo.Context, id string) error
	// Validate a Nuts Security Contract
	// (POST /auth/contract/validate)
	ValidateContract(ctx echo.Context) error
	// Get a contract by type and version
	// (GET /auth/contract/{contractType})
	GetContractByType(ctx echo.Context, contractType string, params GetContractByTypeParams) error
	// Create a JWT Bearer Token which can be used in the createAccessToken request in the assertion field
	// (POST /auth/jwtbearertoken)
	CreateJwtBearerToken(ctx echo.Context) error
	// Introspection endpoint to retrieve information from an Access Token as described by RFC7662
	// (POST /auth/token_introspection)
	IntrospectAccessToken(ctx echo.Context) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) CreateAccessToken

func (w *ServerInterfaceWrapper) CreateAccessToken(ctx echo.Context) error

CreateAccessToken converts echo context to params.

func (*ServerInterfaceWrapper) CreateJwtBearerToken

func (w *ServerInterfaceWrapper) CreateJwtBearerToken(ctx echo.Context) error

CreateJwtBearerToken converts echo context to params.

func (*ServerInterfaceWrapper) CreateSession

func (w *ServerInterfaceWrapper) CreateSession(ctx echo.Context) error

CreateSession converts echo context to params.

func (*ServerInterfaceWrapper) GetContractByType

func (w *ServerInterfaceWrapper) GetContractByType(ctx echo.Context) error

GetContractByType converts echo context to params.

func (*ServerInterfaceWrapper) IntrospectAccessToken

func (w *ServerInterfaceWrapper) IntrospectAccessToken(ctx echo.Context) error

IntrospectAccessToken converts echo context to params.

func (*ServerInterfaceWrapper) SessionRequestStatus

func (w *ServerInterfaceWrapper) SessionRequestStatus(ctx echo.Context) error

SessionRequestStatus converts echo context to params.

func (*ServerInterfaceWrapper) ValidateContract

func (w *ServerInterfaceWrapper) ValidateContract(ctx echo.Context) error

ValidateContract converts echo context to params.

func (*ServerInterfaceWrapper) VerifyAccessToken

func (w *ServerInterfaceWrapper) VerifyAccessToken(ctx echo.Context) error

VerifyAccessToken converts echo context to params.

type SessionResult

type SessionResult struct {
	Disclosed *[]DisclosedAttribute `json:"disclosed,omitempty"`
	Error     *RemoteError          `json:"error,omitempty"`

	// Base64 encoded JWT that can be used as Bearer Token
	NutsAuthToken *string        `json:"nuts_auth_token,omitempty"`
	ProofStatus   *string        `json:"proofStatus,omitempty"`
	Signature     *SignedMessage `json:"signature,omitempty"`
	Status        string         `json:"status"`

	// the token originally given in the request
	Token string `json:"token"`
	Type  string `json:"type"`
}

SessionResult defines model for SessionResult.

type SignedMessage

type SignedMessage struct {
	Context   *float32                     `json:"context,omitempty"`
	Indices   *[][]DisclosedAttributeIndex `json:"indices,omitempty"`
	Message   *string                      `json:"message,omitempty"`
	Nonce     *float32                     `json:"nonce,omitempty"`
	Signature *[]Proof                     `json:"signature,omitempty"`
	Timestamp *Timestamp                   `json:"timestamp,omitempty"`
}

SignedMessage defines model for SignedMessage.

type Timestamp

type Timestamp struct {
	Time *int64 `json:"time,omitempty"`
}

Timestamp defines model for Timestamp.

type TokenIntrospectionRequest

type TokenIntrospectionRequest struct {
	Token string `json:"token"`
}

TokenIntrospectionRequest defines model for TokenIntrospectionRequest.

type TokenIntrospectionResponse

type TokenIntrospectionResponse struct {

	// True if the token is active, false if the token is expired, malformed etc.
	Active bool `json:"active"`

	// As per rfc7523 https://tools.ietf.org/html/rfc7523>, the aud must be the
	// token endpoint. This can be taken from the Nuts registry.
	Aud *string `json:"aud,omitempty"`

	// End-User's preferred e-mail address. Should be a personal email and can be used to uniquely identify a user. Just like the email used for an account.
	Email *string `json:"email,omitempty"`
	Exp   *int    `json:"exp,omitempty"`

	// Surname(s) or last name(s) of the End-User.
	FamilyName *string `json:"family_name,omitempty"`

	// Given name(s) or first name(s) of the End-User.
	GivenName *string `json:"given_name,omitempty"`
	Iat       *int    `json:"iat,omitempty"`

	// The subject (not a Nuts subject) contains the URN of the custodian.
	Iss *string `json:"iss,omitempty"`

	// End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
	Name *string `json:"name,omitempty"`

	// encoded ops signature. (TBD)
	Osi *string `json:"osi,omitempty"`

	// Surname prefix
	Prefix *string `json:"prefix,omitempty"`
	Scope  *string `json:"scope,omitempty"`

	// The Nuts subject id, patient identifier in the form of an oid encoded BSN.
	Sid *string `json:"sid,omitempty"`

	// The subject is always the acting party, thus the care organization requesting access to data.
	Sub *string `json:"sub,omitempty"`

	// Jwt encoded user identity.
	Usi *string `json:"usi,omitempty"`
}

TokenIntrospectionResponse defines model for TokenIntrospectionResponse.

type Type

type Type string

Type defines model for Type.

type ValidateContractJSONBody

type ValidateContractJSONBody ValidationRequest

ValidateContractJSONBody defines parameters for ValidateContract.

type ValidateContractJSONRequestBody

type ValidateContractJSONRequestBody ValidateContractJSONBody

ValidateContractRequestBody defines body for ValidateContract for application/json ContentType.

type ValidationRequest

type ValidationRequest struct {

	// ActingPartyCN is the common name of the Acting party extracted from the client cert
	ActingPartyCn string `json:"acting_party_cn"`

	// ContractFormat specifies the type of format used for the contract
	ContractFormat string `json:"contract_format"`

	// Base64 encoded contracts, either Irma signature or a JWT
	ContractString string `json:"contract_string"`
}

ValidationRequest defines model for ValidationRequest.

type ValidationResult

type ValidationResult struct {
	ContractFormat   string                 `json:"contract_format"`
	SignerAttributes map[string]interface{} `json:"signer_attributes"`
	ValidationResult string                 `json:"validation_result"`
}

ValidationResult defines model for ValidationResult.

type VerifyAccessTokenParams

type VerifyAccessTokenParams struct {
	Authorization string `json:"Authorization"`
}

VerifyAccessTokenParams defines parameters for VerifyAccessToken.

type Version

type Version string

Version defines model for Version.

type Wrapper

type Wrapper struct {
	Auth pkg.AuthClient
}

Wrapper bridges the generated api types and http logic to the internal types and logic. It checks required parameters and message body. It converts data from api to internal types. Then passes the internal formats to the AuthClient. Converts internal results back to the generated Api types. Handles errors and returns the correct http response. It does not perform any business logic.

This wrapper handles the unversioned, so called v0, API requests. Most of them wil be deprecated and moved to a v1 version

func (*Wrapper) CreateAccessToken

func (api *Wrapper) CreateAccessToken(ctx echo.Context, params CreateAccessTokenParams) (err error)

CreateAccessToken handles the api call to create an access token. It consumes and checks the JWT and returns a smaller sessionToken

func (*Wrapper) CreateJwtBearerToken

func (api *Wrapper) CreateJwtBearerToken(ctx echo.Context) error

CreateJwtBearerToken fills a CreateJwtBearerTokenRequest from the request body and passes it to the auth module.

func (*Wrapper) CreateSession

func (api *Wrapper) CreateSession(ctx echo.Context) error

CreateSession translates http params to internal format, creates a IRMA signing session and returns the session pointer to the HTTP stack.

func (*Wrapper) GetContractByType

func (api *Wrapper) GetContractByType(ctx echo.Context, contractType string, params GetContractByTypeParams) error

GetContractByType calls the engines GetContractByType and translate the answer to the API format and returns the the answer back to the HTTP stack

func (*Wrapper) IntrospectAccessToken

func (api *Wrapper) IntrospectAccessToken(ctx echo.Context) error

IntrospectAccessToken takes the access token from the request form value and passes it to the auth client.

func (*Wrapper) SessionRequestStatus

func (api *Wrapper) SessionRequestStatus(ctx echo.Context, sessionID string) error

SessionRequestStatus gets the current status or the IRMA signing session, it translates the result to the api format and returns it to the HTTP stack If the session is not found it returns a 404

func (*Wrapper) ValidateContract

func (api *Wrapper) ValidateContract(ctx echo.Context) error

ValidateContract first translates the request params to an internal format, it then calls the engine's validator and translates the results to the API format and returns the answer to the HTTP stack

func (*Wrapper) VerifyAccessToken

func (api *Wrapper) VerifyAccessToken(ctx echo.Context, params VerifyAccessTokenParams) error

VerifyAccessToken verifies if a request contains a valid bearer token issued by this server

Jump to

Keyboard shortcuts

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