Back to godoc.org

Package api

v0.15.1
Latest Go to latest

The highest tagged major version is .

Published: 2 days ago | License: GPL3 | Module: github.com/nuts-foundation/nuts-auth

Overview

Package api provides primitives to interact the openapi HTTP API.

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

Index

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

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 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"`
}

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      DisclosedAttribute_Value `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 DisclosedAttribute_Value

type DisclosedAttribute_Value struct {
	AdditionalProperties map[string]string `json:"-"`
}

DisclosedAttribute_Value defines model for DisclosedAttribute.Value.

func (DisclosedAttribute_Value) Get

func (a DisclosedAttribute_Value) Get(fieldName string) (value string, found bool)

Getter for additional properties for DisclosedAttribute_Value. Returns the specified element and whether it was found

func (DisclosedAttribute_Value) MarshalJSON

func (a DisclosedAttribute_Value) MarshalJSON() ([]byte, error)

Override default JSON handling for DisclosedAttribute_Value to handle AdditionalProperties

func (*DisclosedAttribute_Value) Set

func (a *DisclosedAttribute_Value) Set(fieldName string, value string)

Setter for additional properties for DisclosedAttribute_Value

func (*DisclosedAttribute_Value) UnmarshalJSON

func (a *DisclosedAttribute_Value) UnmarshalJSON(b []byte) error

Override default JSON handling for DisclosedAttribute_Value to handle AdditionalProperties

type EchoRouter

type EchoRouter 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
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

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 *ProofD_ADisclosed `json:"a_disclosed,omitempty"`
	AResponses *ProofD_AResponses `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 ProofD_ADisclosed

type ProofD_ADisclosed struct {
	AdditionalProperties map[string]float32 `json:"-"`
}

ProofD_ADisclosed defines model for ProofD.ADisclosed.

func (ProofD_ADisclosed) Get

func (a ProofD_ADisclosed) Get(fieldName string) (value float32, found bool)

Getter for additional properties for ProofD_ADisclosed. Returns the specified element and whether it was found

func (ProofD_ADisclosed) MarshalJSON

func (a ProofD_ADisclosed) MarshalJSON() ([]byte, error)

Override default JSON handling for ProofD_ADisclosed to handle AdditionalProperties

func (*ProofD_ADisclosed) Set

func (a *ProofD_ADisclosed) Set(fieldName string, value float32)

Setter for additional properties for ProofD_ADisclosed

func (*ProofD_ADisclosed) UnmarshalJSON

func (a *ProofD_ADisclosed) UnmarshalJSON(b []byte) error

Override default JSON handling for ProofD_ADisclosed to handle AdditionalProperties

type ProofD_AResponses

type ProofD_AResponses struct {
	AdditionalProperties map[string]float32 `json:"-"`
}

ProofD_AResponses defines model for ProofD.AResponses.

func (ProofD_AResponses) Get

func (a ProofD_AResponses) Get(fieldName string) (value float32, found bool)

Getter for additional properties for ProofD_AResponses. Returns the specified element and whether it was found

func (ProofD_AResponses) MarshalJSON

func (a ProofD_AResponses) MarshalJSON() ([]byte, error)

Override default JSON handling for ProofD_AResponses to handle AdditionalProperties

func (*ProofD_AResponses) Set

func (a *ProofD_AResponses) Set(fieldName string, value float32)

Setter for additional properties for ProofD_AResponses

func (*ProofD_AResponses) UnmarshalJSON

func (a *ProofD_AResponses) UnmarshalJSON(b []byte) error

Override default JSON handling for ProofD_AResponses to handle AdditionalProperties

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 X-Nuts-LegalEntity header which should contain the vendor name and must be the same as used in the signed login contract.
	// (POST /auth/accesstoken)
	CreateAccessToken(ctx echo.Context) 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.

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 issuer in the JWT is always the acting party, thus the care organization doing the request.
	// This is used to find the public key of the issuer from the Nuts registry.
	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"`

	// 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 (not a Nuts subject) contains the urn of the custodian. The
	// custodian information is used to find the relevant consent (together with actor
	// and subject).
	Sub *string `json:"sub,omitempty"`

	// Jwt encoded user identity.
	Uid *string `json:"uid,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 ValidationResult_SignerAttributes `json:"signer_attributes"`
	ValidationResult string                            `json:"validation_result"`
}

ValidationResult defines model for ValidationResult.

type ValidationResult_SignerAttributes

type ValidationResult_SignerAttributes struct {
	AdditionalProperties map[string]string `json:"-"`
}

ValidationResult_SignerAttributes defines model for ValidationResult.SignerAttributes.

func (ValidationResult_SignerAttributes) Get

func (a ValidationResult_SignerAttributes) Get(fieldName string) (value string, found bool)

Getter for additional properties for ValidationResult_SignerAttributes. Returns the specified element and whether it was found

func (ValidationResult_SignerAttributes) MarshalJSON

func (a ValidationResult_SignerAttributes) MarshalJSON() ([]byte, error)

Override default JSON handling for ValidationResult_SignerAttributes to handle AdditionalProperties

func (*ValidationResult_SignerAttributes) Set

func (a *ValidationResult_SignerAttributes) Set(fieldName string, value string)

Setter for additional properties for ValidationResult_SignerAttributes

func (*ValidationResult_SignerAttributes) UnmarshalJSON

func (a *ValidationResult_SignerAttributes) UnmarshalJSON(b []byte) error

Override default JSON handling for ValidationResult_SignerAttributes to handle AdditionalProperties

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.

func (*Wrapper) CreateAccessToken

func (api *Wrapper) CreateAccessToken(ctx echo.Context) (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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier