Documentation ¶
Index ¶
- Variables
- func MustRefreshToken(c *gin.Context, err interface{})
- func NotAllowed(c *gin.Context)
- func NotFound(c *gin.Context)
- type APIv1
- func (s *APIv1) AddCollaborator(ctx context.Context, request *models.Collaborator) (collaborator *models.Collaborator, err error)
- func (s *APIv1) Announcements(ctx context.Context) (out *AnnouncementsReply, err error)
- func (s *APIv1) Attention(ctx context.Context) (out *AttentionReply, err error)
- func (s *APIv1) Certificates(ctx context.Context) (out *CertificatesReply, err error)
- func (s *APIv1) Do(req *http.Request, data interface{}, checkStatus bool) (rep *http.Response, err error)
- func (s *APIv1) LoadRegistrationForm(ctx context.Context) (form *models.RegistrationForm, err error)
- func (s *APIv1) Login(ctx context.Context) (err error)
- func (s *APIv1) Lookup(ctx context.Context, in *LookupParams) (out *LookupReply, err error)
- func (s *APIv1) MakeAnnouncement(ctx context.Context, in *models.Announcement) (err error)
- func (s *APIv1) MemberDetails(ctx context.Context, in *MemberDetailsParams) (out *MemberDetailsReply, err error)
- func (s *APIv1) NewRequest(ctx context.Context, method, path string, data interface{}, params *url.Values) (req *http.Request, err error)
- func (s *APIv1) Overview(ctx context.Context) (out *OverviewReply, err error)
- func (s *APIv1) RegistrationStatus(ctx context.Context) (out *RegistrationStatus, err error)
- func (s *APIv1) ReplaceCollaborator(ctx context.Context, request *models.Collaborator) (collaborator *models.Collaborator, err error)
- func (s *APIv1) SaveRegistrationForm(ctx context.Context, form *models.RegistrationForm) (out *models.RegistrationForm, err error)
- func (c *APIv1) SetCSRFProtect(protect bool) error
- func (c *APIv1) SetCredentials(creds Credentials)
- func (s *APIv1) Status(ctx context.Context, in *StatusParams) (out *StatusReply, err error)
- func (s *APIv1) SubmitRegistration(ctx context.Context, network string) (out *RegisterReply, err error)
- func (s *APIv1) VerifyContact(ctx context.Context, in *VerifyContactParams) (out *VerifyContactReply, err error)
- type AnnouncementsReply
- type AttentionMessage
- type AttentionReply
- type Auth0Token
- type BFFClient
- type Certificate
- type CertificatesReply
- type ClientOption
- type Credentials
- type LocalCredentials
- type LookupParams
- type LookupReply
- type MemberDetails
- type MemberDetailsParams
- type MemberDetailsReply
- type NetworkError
- type NetworkOverview
- type OverviewReply
- type RegisterReply
- type RegistrationStatus
- type Reply
- type StatusParams
- type StatusReply
- type Token
- type VerifyContactParams
- type VerifyContactReply
Constants ¶
This section is empty.
Variables ¶
var ( ErrNetworkRequired = fmt.Errorf("request requires a valid network (%s or %s)", config.TestNet, config.MainNet) ErrInvalidCredentials = errors.New("auth0 credentials are missing or invalid") ErrExpiredCredentials = errors.New("auth0 credentials have expired") ErrPathRequired = errors.New("local credentials requires a path to the stored json credential") )
Functions ¶
func MustRefreshToken ¶ added in v1.5.0
MustRefreshToken returns a JSON 401 response with the refresh_token flag set to true.
func NotAllowed ¶
NotAllowed returns a JSON 405 response for the API.
Types ¶
type APIv1 ¶
type APIv1 struct {
// contains filtered or unexported fields
}
APIv1 implements the BFFClient interface.
func (*APIv1) AddCollaborator ¶ added in v1.5.2
func (s *APIv1) AddCollaborator(ctx context.Context, request *models.Collaborator) (collaborator *models.Collaborator, err error)
Add a collaborator to an organization.
func (*APIv1) Announcements ¶ added in v1.5.0
func (s *APIv1) Announcements(ctx context.Context) (out *AnnouncementsReply, err error)
Announcements returns a list of network announcments made by the admins.
func (*APIv1) Attention ¶ added in v1.5.0
func (s *APIv1) Attention(ctx context.Context) (out *AttentionReply, err error)
Attention returns the set of current attention messages for the organization.
func (*APIv1) Certificates ¶ added in v1.5.0
func (s *APIv1) Certificates(ctx context.Context) (out *CertificatesReply, err error)
Certificates returns the list of certificates associated with the organization.
func (*APIv1) Do ¶
func (s *APIv1) Do(req *http.Request, data interface{}, checkStatus bool) (rep *http.Response, err error)
Do executes an http request against the server, performs error checking, and deserializes the response data into the specified struct if requested.
func (*APIv1) LoadRegistrationForm ¶ added in v1.5.0
func (s *APIv1) LoadRegistrationForm(ctx context.Context) (form *models.RegistrationForm, err error)
Load registration form data from the server to populate the front-end form.
func (*APIv1) Login ¶ added in v1.5.0
Login post-processes an Auth0 login or registration and sets CSRF cookies.
func (*APIv1) Lookup ¶
func (s *APIv1) Lookup(ctx context.Context, in *LookupParams) (out *LookupReply, err error)
Lookup a VASP record in both the TestNet and the MainNet.
func (*APIv1) MakeAnnouncement ¶ added in v1.5.0
MakeAnnouncement allows administrators to post new network announcements.
func (*APIv1) MemberDetails ¶ added in v1.5.0
func (s *APIv1) MemberDetails(ctx context.Context, in *MemberDetailsParams) (out *MemberDetailsReply, err error)
Details returns the sensitive details for a VASP member.
func (*APIv1) NewRequest ¶
func (s *APIv1) NewRequest(ctx context.Context, method, path string, data interface{}, params *url.Values) (req *http.Request, err error)
NewRequest creates an http.Request with the specified context and method, resolving the path to the root endpoint of the API (e.g. /v2) and serializes the data to JSON. This method also sets the default headers of all GDS Admin API v2 client requests.
func (*APIv1) Overview ¶ added in v1.5.0
func (s *APIv1) Overview(ctx context.Context) (out *OverviewReply, err error)
Overview returns a high-level summary of the organization account and networks.
func (*APIv1) RegistrationStatus ¶ added in v1.5.0
func (s *APIv1) RegistrationStatus(ctx context.Context) (out *RegistrationStatus, err error)
RegistrationStatus returns the status of the VASP registrations for the organization.
func (*APIv1) ReplaceCollaborator ¶ added in v1.5.2
func (s *APIv1) ReplaceCollaborator(ctx context.Context, request *models.Collaborator) (collaborator *models.Collaborator, err error)
Replace a collaborator in an organization.
func (*APIv1) SaveRegistrationForm ¶ added in v1.5.0
func (s *APIv1) SaveRegistrationForm(ctx context.Context, form *models.RegistrationForm) (out *models.RegistrationForm, err error)
Save registration form data to the server in preparation for submitting it.
func (*APIv1) SetCSRFProtect ¶ added in v1.5.0
SetCSRFProtect is a helper function to set CSRF cookies on the client. This is not possible in a browser because of the HttpOnly flag. This method should only be used for testing purposes and an error is returned if the URL is not localhost. For live clients - the server should set these cookies. If protect is false, then the cookies are removed from the client by setting the cookies to an empty slice.
func (*APIv1) SetCredentials ¶ added in v1.5.0
func (c *APIv1) SetCredentials(creds Credentials)
SetCredentials is a helper function for external users to override credentials at runtime and is used extensively in testing the BFF server.
func (*APIv1) Status ¶
func (s *APIv1) Status(ctx context.Context, in *StatusParams) (out *StatusReply, err error)
Status performs a health check request to the BFF.
func (*APIv1) SubmitRegistration ¶ added in v1.5.0
func (s *APIv1) SubmitRegistration(ctx context.Context, network string) (out *RegisterReply, err error)
Submit the registration form to the specified network (testnet or mainnet).
func (*APIv1) VerifyContact ¶
func (s *APIv1) VerifyContact(ctx context.Context, in *VerifyContactParams) (out *VerifyContactReply, err error)
Verify a contact with the token sent to their email address.
type AnnouncementsReply ¶ added in v1.5.0
type AnnouncementsReply struct { Announcements []*models.Announcement `json:"announcements"` LastUpdated string `json:"last_updated,omitempty"` }
AnnouncementsReply contains up to the last 10 network announcements that were made in the past month. It does not require pagination since only relevant results are returned.
type AttentionMessage ¶ added in v1.5.0
type AttentionMessage struct { Message string `json:"message"` Severity string `json:"severity"` Action string `json:"action"` }
AttentionMessage contains details about a single attention message.
type AttentionReply ¶ added in v1.5.0
type AttentionReply struct {
Messages []*AttentionMessage `json:"messages"`
}
AttentionReply contains all the current attention messages relevant to an organization.
type Auth0Token ¶ added in v1.5.0
type Auth0Token struct { Token string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` Scope string `json:"scope"` Type string `json:"token_type"` CreatedAt time.Time `json:"created_at"` ExpiresAt time.Time `json:"expires_at"` }
Auth0Token is a JSON representation of the Token returned by Auth0
func (*Auth0Token) AccessToken ¶ added in v1.5.0
func (t *Auth0Token) AccessToken() (_ string, err error)
AccessToken implements the Credentials interface and ensures that a token is present and that the token has not expired yet. It relies on the data structure from Auth0 rather than parsing the jwt token directly.
type BFFClient ¶
type BFFClient interface { // Unauthenticated Endpoints Status(context.Context, *StatusParams) (*StatusReply, error) Lookup(context.Context, *LookupParams) (*LookupReply, error) VerifyContact(context.Context, *VerifyContactParams) (*VerifyContactReply, error) // User Management Endpoints Login(context.Context) error // Authenticated Endpoints AddCollaborator(context.Context, *models.Collaborator) (*models.Collaborator, error) ReplaceCollaborator(context.Context, *models.Collaborator) (*models.Collaborator, error) LoadRegistrationForm(context.Context) (*models.RegistrationForm, error) SaveRegistrationForm(context.Context, *models.RegistrationForm) (*models.RegistrationForm, error) SubmitRegistration(_ context.Context, network string) (*RegisterReply, error) RegistrationStatus(context.Context) (*RegistrationStatus, error) Overview(context.Context) (*OverviewReply, error) Announcements(context.Context) (*AnnouncementsReply, error) MakeAnnouncement(context.Context, *models.Announcement) error Certificates(context.Context) (*CertificatesReply, error) MemberDetails(context.Context, *MemberDetailsParams) (*MemberDetailsReply, error) Attention(context.Context) (*AttentionReply, error) }
type Certificate ¶ added in v1.5.0
type Certificate struct { SerialNumber string `json:"serial_number"` IssuedAt string `json:"issued_at"` ExpiresAt string `json:"expires_at"` Revoked bool `json:"revoked"` Details map[string]interface{} `json:"details"` }
Certificate contains details about a certificate issued to a VASP.
type CertificatesReply ¶ added in v1.5.0
type CertificatesReply struct { Error NetworkError `json:"network_error,omitempty"` TestNet []Certificate `json:"testnet"` MainNet []Certificate `json:"mainnet"` }
CertificatesReply is returned on certificates requests.
type ClientOption ¶ added in v1.5.0
ClientOption allows us to configure the APIv1 client when it is created.
func WithClient ¶ added in v1.5.0
func WithClient(client *http.Client) ClientOption
func WithCredentials ¶ added in v1.5.0
func WithCredentials(creds Credentials) ClientOption
type Credentials ¶ added in v1.5.0
Credentials provides a basic interface for loading an access token from Auth0 into the BFF API Client. Credentials can be loaded from disk, generated, or directly authenticated with Auth0 via a machine-to-machine token.
NOTE: this is a fundamentally different mechanism than the GDS Admin API credentials because the Admin API generates its own tokens, and Auth0 manages the BFF credentials.
type LocalCredentials ¶ added in v1.5.0
type LocalCredentials struct { Path string Token *Auth0Token }
LocalCredentials loads and saves the access token from disk.
func (*LocalCredentials) AccessToken ¶ added in v1.5.0
func (t *LocalCredentials) AccessToken() (_ string, err error)
AccessToken implements the Credentials interface by checking if the token has been loaded, and if not, it loads the token from disk. Validation is performed by the Auth0Token to ensure the credentials are valid and not expired.
func (*LocalCredentials) Dump ¶ added in v1.5.0
func (t *LocalCredentials) Dump() (err error)
Dump the credentials to store them to the path on disk.
func (*LocalCredentials) Load ¶ added in v1.5.0
func (t *LocalCredentials) Load() (err error)
Load the credentials from the path on disk.
type LookupParams ¶
type LookupParams struct { ID string `url:"uuid,omitempty" form:"uuid"` CommonName string `url:"common_name,omitempty" form:"common_name"` }
LookupParams is converted into a GDS LookupRequest.
type LookupReply ¶
type LookupReply struct { TestNet map[string]interface{} `json:"testnet"` MainNet map[string]interface{} `json:"mainnet"` }
LookupReply can return 1-2 results either one result found from one directory service or results found from both TestNet and MainNet. If no results are found, the Lookup endpoint returns a 404 error (not found). The result is the simplest case, just a JSON serialization of the protocol buffers returned from GDS to help long term maintainability. The protocol buffers contain a "registered_directory" field that will have either vaspdirectory.net or trisatest.net inside of it - which can be used to identify which network the record is associated with. The protocol buffers may also contain an "error" field - the BFF will handle this field by logging the error but will exclude it from any results returned.
type MemberDetails ¶ added in v1.5.0
type MemberDetails struct { ID string `json:"id"` Status string `json:"status"` CountryCode string `json:"country_code"` FirstListed string `json:"first_listed"` VerifiedOn string `json:"verified_on"` LastUpdated string `json:"last_updated"` Certificate map[string]interface{} `json:"certificate"` }
MemberDetails contains VASP-specific information.
type MemberDetailsParams ¶ added in v1.5.0
type MemberDetailsParams struct { ID string `url:"vaspID,omitempty" form:"vaspID"` Directory string `url:"registered_directory,omitempty" form:"registered_directory"` }
MemberDetailsParams contains details required to identify a VASP member for the MembersDetails request.
type MemberDetailsReply ¶ added in v1.5.0
type MemberDetailsReply struct { Summary *members.VASPMember `json:"summary"` LegalPerson map[string]interface{} `json:"legal_person"` Trixo map[string]interface{} `json:"trixo"` }
MemberDetailsReply contains sensitive details about a VASP member.
type NetworkError ¶ added in v1.5.0
type NetworkError struct { TestNet string `json:"testnet,omitempty"` MainNet string `json:"mainnet,omitempty"` }
NetworkError is populated when the BFF receives an error from a network endpoint, containing an error string for each network that errored. This allows the client to distinguish between network errors and BFF errors and determine which network the errors originated from.
type NetworkOverview ¶ added in v1.5.0
type NetworkOverview struct { Status string `json:"status"` Vasps int `json:"vasps"` CertificatesIssued int `json:"certificates_issued"` NewMembers int `json:"new_members"` MemberDetails MemberDetails `json:"member_details"` }
NetworkOverview contains network-specific information.
type OverviewReply ¶ added in v1.5.0
type OverviewReply struct { Error NetworkError `json:"error,omitempty"` OrgID string `json:"org_id"` TestNet NetworkOverview `json:"testnet"` MainNet NetworkOverview `json:"mainnet"` }
OverviewReply is returned on overview requests.
type RegisterReply ¶
type RegisterReply struct { Error map[string]interface{} `json:"error,omitempty"` Id string `json:"id"` RegisteredDirectory string `json:"registered_directory"` CommonName string `json:"common_name"` Status string `json:"status"` Message string `json:"message"` PKCS12Password string `json:"pkcs12password"` RefreshToken bool `json:"refresh_token,omitempty"` }
RegisterReply is converted from a protocol buffer RegisterReply.
type RegistrationStatus ¶ added in v1.5.0
type RegistrationStatus struct { TestNetSubmitted string `json:"testnet_submitted,omitempty"` MainNetSubmitted string `json:"mainnet_submitted,omitempty"` }
RegistrationStatus is returned on registration status requests. This will contain RFC3339 formatted timestamps indicating when the registration was submitted for testnet and mainnet.
type Reply ¶
type Reply struct { Success bool `json:"success"` Error string `json:"error,omitempty" yaml:"error,omitempty"` RefreshToken bool `json:"refresh_token,omitempty" yaml:"refresh_token,omitempty"` }
Reply contains standard fields that are used for generic API responses and errors
func ErrorResponse ¶
func ErrorResponse(err interface{}) Reply
ErrorResponse constructs an new response from the error or returns a success: false.
type StatusParams ¶
type StatusParams struct {
NoGDS bool `url:"nogds,omitempty" form:"nogds" default:"false"`
}
StatusParams is parsed from the query parameters of the GET request
type StatusReply ¶
type StatusReply struct { Status string `json:"status"` Uptime string `json:"uptime,omitempty"` Version string `json:"version,omitempty"` TestNet string `json:"testnet,omitempty"` MainNet string `json:"mainnet,omitempty"` }
StatusReply is returned on status requests. Note that no request is needed.
type Token ¶ added in v1.5.0
type Token string
A Token is just the JWT base64 encoded token string that can be obtained from the Auth0 debugger or created in memory for tests using Token("mytoken"). Token implements the Credentials interface so it can be passed directly to the client.
func (Token) AccessToken ¶ added in v1.5.0
Token implements the Credentials interface but performs limited validation on the string.
type VerifyContactParams ¶
type VerifyContactParams struct { ID string `url:"vaspID,omitempty" form:"vaspID"` Token string `url:"token,omitempty" form:"token"` Directory string `url:"registered_directory,omitempty" form:"registered_directory"` }
VerifyContactParams is converted into a GDS VerifyContactRequest.
type VerifyContactReply ¶
type VerifyContactReply struct { Error map[string]interface{} `json:"error,omitempty"` Status string `json:"status"` Message string `json:"message"` }
VerifyContactReply