Documentation ¶
Index ¶
- Constants
- func FlattenErrs(in []error) (out []error)
- func FlattenResults(in []interface{}) (out []interface{})
- type AdminRPC
- type GDSClient
- func (c *GDSClient) Close() (err error)
- func (c *GDSClient) ConnectGDS(conf config.DirectoryConfig, opts ...grpc.DialOption) error
- func (c *GDSClient) ConnectMembers(conf config.MembersConfig, opts ...grpc.DialOption) error
- func (c *GDSClient) Details(ctx context.Context, in *members.DetailsRequest, opts ...grpc.CallOption) (*members.MemberDetails, error)
- func (c *GDSClient) List(ctx context.Context, in *members.ListRequest, opts ...grpc.CallOption) (*members.ListReply, error)
- func (c *GDSClient) Lookup(ctx context.Context, in *gds.LookupRequest, opts ...grpc.CallOption) (*gds.LookupReply, error)
- func (c *GDSClient) Register(ctx context.Context, in *gds.RegisterRequest, opts ...grpc.CallOption) (*gds.RegisterReply, error)
- func (c *GDSClient) Search(ctx context.Context, in *gds.SearchRequest, opts ...grpc.CallOption) (*gds.SearchReply, error)
- func (c *GDSClient) Status(ctx context.Context, in *gds.HealthCheck, opts ...grpc.CallOption) (*gds.ServiceState, error)
- func (c *GDSClient) Summary(ctx context.Context, in *members.SummaryRequest, opts ...grpc.CallOption) (*members.SummaryReply, error)
- func (c *GDSClient) Verification(ctx context.Context, in *gds.VerificationRequest, opts ...grpc.CallOption) (*gds.VerificationReply, error)
- func (c *GDSClient) VerifyContact(ctx context.Context, in *gds.VerifyContactRequest, opts ...grpc.CallOption) (*gds.VerifyContactReply, error)
- type GlobalDirectoryClient
- type RPC
- type Server
- func (s *Server) AddCollaborator(c *gin.Context)
- func (s *Server) Announcements(c *gin.Context)
- func (s *Server) Attention(c *gin.Context)
- func (s *Server) Available() gin.HandlerFunc
- func (s *Server) Certificates(c *gin.Context)
- func (s *Server) FindRoleByName(name string) (*management.Role, error)
- func (s *Server) GetCertificates(ctx context.Context, testnetID, mainnetID string) (testnetCerts, mainnetCerts *admin.ListCertificatesReply, ...)
- func (s *Server) GetConf() config.Config
- func (s *Server) GetRouter() http.Handler
- func (s *Server) GetStatuses(ctx context.Context) (testnet, mainnet *gds.ServiceState, err error)
- func (s *Server) GetSummaries(ctx context.Context, testnetID, mainnetID string) (testnetSummary, mainnetSummary *members.SummaryReply, ...)
- func (s *Server) GetURL() string
- func (s *Server) GetVASPs(ctx context.Context, testnetID, mainnetID string) (testnetVASP, mainnetVASP *pb.VASP, testnetErr, mainnetErr error)
- func (s *Server) LoadRegisterForm(c *gin.Context)
- func (s *Server) Login(c *gin.Context)
- func (s *Server) Lookup(c *gin.Context)
- func (s *Server) MakeAnnouncement(c *gin.Context)
- func (s *Server) MemberDetails(c *gin.Context)
- func (s *Server) OrganizationFromClaims(c *gin.Context) (org *models.Organization, err error)
- func (s *Server) Overview(c *gin.Context)
- func (s *Server) ParallelAdminRequests(ctx context.Context, rpc AdminRPC, flatten bool) (results []interface{}, errs []error)
- func (s *Server) ParallelGDSRequests(ctx context.Context, rpc RPC, flatten bool) (results []interface{}, errs []error)
- func (s *Server) RegistrationStatus(c *gin.Context)
- func (s *Server) ReplaceCollaborator(c *gin.Context)
- func (s *Server) SaveAuth0AppMetadata(uid string, appdata auth.AppMetadata) (err error)
- func (s *Server) SaveRegisterForm(c *gin.Context)
- func (s *Server) Serve() (err error)
- func (s *Server) SetAdminClients(testnet, mainnet apiv2.DirectoryAdministrationClient)
- func (s *Server) SetDB(db *db.DB)
- func (s *Server) SetGDSClients(testnet, mainnet *GDSClient)
- func (s *Server) SetHealth(health bool)
- func (s *Server) SetURL(url string)
- func (s *Server) Shutdown() (err error)
- func (s *Server) Status(c *gin.Context)
- func (s *Server) SubmitRegistration(c *gin.Context)
- func (s *Server) VerifyContact(c *gin.Context)
Constants ¶
const ( StartRegistration = "" /* 160-byte string literal not displayed */ CompleteRegistration = "" /* 171-byte string literal not displayed */ SubmitTestnet = "Review and submit your " + testnetName + " registration." SubmitMainnet = "Review and submit your " + mainnetName + " registration." VerifyEmails = "Your organization's %s registration has been submitted and verification emails have been sent to the contacts specified in the form. Contacts and email addresses must be verified as the first step in the approval process. Please request that contacts verify their email addresses promptly so that the TRISA Validation Team can proceed with the validation process. Please contact TRISA support at " + supportEmail + " if contacts have not received the verification email and link." RegistrationPending = "" /* 139-byte string literal not displayed */ RegistrationRejected = "Your organization's %s registration has been rejected by the TRISA Validation Team. This means your organization is not a verified member of the TRISA network and cannot communicate with other members. Please contact TRISA support at " + supportEmail + " for additional details and next steps." RegistrationApproved = "" /* 198-byte string literal not displayed */ RenewCertificate = "" /* 188-byte string literal not displayed */ CertificateRevoked = "Your organization's %s X.509 Identity Certificate has been revoked by TRISA. This means your organization is no longer a verified member of the TRISA network and can no longer communicate with other members. Please contact TRISA support at " + supportEmail + " for additional details and next steps." )
const ( // TODO: do not hard code this value but make it a configuration DefaultRole = "Organization Collaborator" DoubleCookieMaxAge = 24 * time.Hour OrgIDKey = "orgid" VASPsKey = "vasps" )
Variables ¶
This section is empty.
Functions ¶
func FlattenErrs ¶
FlattenErrs removes nil errors from the slice (exported for testing purposes).
func FlattenResults ¶
func FlattenResults(in []interface{}) (out []interface{})
FlattenResults removes nil values from the slice (exported for testing purposes).
Types ¶
type GDSClient ¶ added in v1.5.0
type GDSClient struct {
// contains filtered or unexported fields
}
GDSClient is a unified client which contains sub-clients for interacting with the various GDS services. This helps reduce common client code when making parallel requests to both testnet and mainnet.
func (*GDSClient) Close ¶ added in v1.5.0
Close the connection to both the TRISA directory service and the Members service.
func (*GDSClient) ConnectGDS ¶ added in v1.5.0
func (c *GDSClient) ConnectGDS(conf config.DirectoryConfig, opts ...grpc.DialOption) error
ConnectGDS creates a gRPC client to the TRISA Directory Service specified in the configuration using the provided dial options.
func (*GDSClient) ConnectMembers ¶ added in v1.5.0
func (c *GDSClient) ConnectMembers(conf config.MembersConfig, opts ...grpc.DialOption) error
ConnectMembers creates a gRPC client to the TRISA Members Service specified in the configuration using the provided dial options.
func (*GDSClient) Details ¶ added in v1.5.0
func (c *GDSClient) Details(ctx context.Context, in *members.DetailsRequest, opts ...grpc.CallOption) (*members.MemberDetails, error)
func (*GDSClient) List ¶ added in v1.5.0
func (c *GDSClient) List(ctx context.Context, in *members.ListRequest, opts ...grpc.CallOption) (*members.ListReply, error)
Members methods
func (*GDSClient) Lookup ¶ added in v1.5.0
func (c *GDSClient) Lookup(ctx context.Context, in *gds.LookupRequest, opts ...grpc.CallOption) (*gds.LookupReply, error)
GDS methods
func (*GDSClient) Register ¶ added in v1.5.0
func (c *GDSClient) Register(ctx context.Context, in *gds.RegisterRequest, opts ...grpc.CallOption) (*gds.RegisterReply, error)
func (*GDSClient) Search ¶ added in v1.5.0
func (c *GDSClient) Search(ctx context.Context, in *gds.SearchRequest, opts ...grpc.CallOption) (*gds.SearchReply, error)
func (*GDSClient) Status ¶ added in v1.5.0
func (c *GDSClient) Status(ctx context.Context, in *gds.HealthCheck, opts ...grpc.CallOption) (*gds.ServiceState, error)
func (*GDSClient) Summary ¶ added in v1.5.0
func (c *GDSClient) Summary(ctx context.Context, in *members.SummaryRequest, opts ...grpc.CallOption) (*members.SummaryReply, error)
func (*GDSClient) Verification ¶ added in v1.5.0
func (c *GDSClient) Verification(ctx context.Context, in *gds.VerificationRequest, opts ...grpc.CallOption) (*gds.VerificationReply, error)
func (*GDSClient) VerifyContact ¶ added in v1.5.0
func (c *GDSClient) VerifyContact(ctx context.Context, in *gds.VerifyContactRequest, opts ...grpc.CallOption) (*gds.VerifyContactReply, error)
type GlobalDirectoryClient ¶ added in v1.5.0
type GlobalDirectoryClient interface { gds.TRISADirectoryClient members.TRISAMembersClient }
GlobalDirectoryClient is a unified interface to access multiple GDS services across multiple connections with different client interfaces.
func ConnectGDS ¶
func ConnectGDS(conf config.NetworkConfig) (_ GlobalDirectoryClient, err error)
ConnectGDS creates a unified client to the TRISA Directory Service and TRISA members service specified in the configuration. This method is used to connect to both the TestNet and the MainNet so we can maintain separate clients for each.
type RPC ¶ added in v1.5.0
type RPC func(ctx context.Context, client GlobalDirectoryClient, network string) (proto.Message, error)
RPC allows the BFF to issue arbitrary client methods in parallel to both the testnet and the mainnet. The combined client object, which contains separate sub-clients for the GDS and members services, and network name are passed into the function, allowing the RPC to make any directory service or members service RPC call and log with the associated network.
type Server ¶
func (*Server) AddCollaborator ¶ added in v1.5.2
AddCollaborator creates a new collaborator with the email address in the request. The endpoint adds the collaborator to the organization record associated with the user and sends a verification email to the provided email address, so the user must have the update:collaborators permission.
func (*Server) Announcements ¶ added in v1.5.0
func (*Server) Attention ¶ added in v1.5.0
Attention returns the current attention messages for the authenticated user.
func (*Server) Available ¶
func (s *Server) Available() gin.HandlerFunc
Available is middleware that uses the healthy boolean to return a service unavailable http status code if the server is shutting down. This middleware must be first in the chain to ensure that complex handling to slow the shutdown of the server.
func (*Server) Certificates ¶ added in v1.5.0
Certificates returns the list of certificates for the authenticated user.
func (*Server) FindRoleByName ¶ added in v1.5.0
func (s *Server) FindRoleByName(name string) (*management.Role, error)
func (*Server) GetCertificates ¶ added in v1.5.0
func (s *Server) GetCertificates(ctx context.Context, testnetID, mainnetID string) (testnetCerts, mainnetCerts *admin.ListCertificatesReply, testnetErr, mainnetErr error)
GetCertificates makes parallel calls to the admin services to get the certificate information for both testnet and mainnet. If testnetID or mainnetID are empty strings, this will simply return a nil response for the corresponding network so the caller can distinguish between a non registration and an error.
func (*Server) GetStatuses ¶ added in v1.5.0
GetStatuses makes parallel calls to the directory service to get the status information for both testnet and mainnet.
func (*Server) GetSummaries ¶ added in v1.5.0
func (s *Server) GetSummaries(ctx context.Context, testnetID, mainnetID string) (testnetSummary, mainnetSummary *members.SummaryReply, testnetErr, mainnetErr error)
GetSummaries makes parallel calls to the members service to get the summary information for both testnet and mainnet. If an endpoint returned an error, then a nil value is returned from this function for that endpoint instead of an error.
func (*Server) GetURL ¶
GetURL returns the URL that the server can be reached if it has been started. This accessor is primarily used to create a test client.
func (*Server) GetVASPs ¶ added in v1.5.0
func (s *Server) GetVASPs(ctx context.Context, testnetID, mainnetID string) (testnetVASP, mainnetVASP *pb.VASP, testnetErr, mainnetErr error)
GetVASPs makes parallel calls to the admin APIs to retrieve VASP records from testnet and mainnet. If testnet or mainnet are empty strings, this will simply return a nil response for the corresponding network so the caller can distinguish between a non registration and an error.
func (*Server) LoadRegisterForm ¶ added in v1.5.0
Returns the user's current registration form if it's available
func (*Server) Login ¶ added in v1.5.0
Login performs post-authentication checks and ensures that the user has the proper permissions and roles after they sign in with Auth0. The front-end should call the BFF login endpoint after the user signs in, providing the access_token in the request. If there is no access token a 401 is returned. This endpoint verifies that the user has a role and organization assigned to it and that the organization is up to date with the auth0 app_data. If the user does not have an organization, it is assumed that this is the first time the user has logged in and an organization is created for the user and they are assigned the organization leader role. If they have an organization but no role, they are assigned the organization collaborator role. If the auth0 app data was changed, this returns a response with the refresh_token field set to true, indicating that the frontend should refresh the access token to ensure that the user claims are up to date.
func (*Server) Lookup ¶
Lookup makes a request on behalf of the user to both the TestNet and MainNet GDS servers, returning 1-2 results (e.g. either or both GDS responses). If no results are returned, Lookup returns a 404 not found error. If one of the GDS requests fails, the error is logged, but the valid response is returned. If both GDS requests fail, a 500 error is returned. This endpoint passes through the response from GDS as JSON, the result should contain a registered_directory field that identifies which network the record is associated with.
func (*Server) MakeAnnouncement ¶ added in v1.5.0
func (*Server) MemberDetails ¶ added in v1.5.0
MemberDetails endpoint is an authenticated endpoint that requires the read:vasp permission and returns details about a VASP member.
func (*Server) OrganizationFromClaims ¶ added in v1.5.0
OrganizationFromClaims is a helper method to retrieve the organization for a particular request by fetching the orgID from the claims and querying the database. If there is an error fetching the organization, the appropriate error response is made on the gin writer and logged. The caller should check for error and return.
func (*Server) Overview ¶ added in v1.5.0
Overview endpoint is an authenticated endpoint that requires the read:vasp permission.
func (*Server) ParallelAdminRequests ¶ added in v1.5.0
func (s *Server) ParallelAdminRequests(ctx context.Context, rpc AdminRPC, flatten bool) (results []interface{}, errs []error)
ParallelAdminRequests makes concurrent requests to both the testnet and the mainnet, storing the results and errors in a slice of length 2 ([testnet, mainnet]). If the flatten bool is true, then nil values are removed from the slice (though this will make which network returned the result ambiguous).
func (*Server) ParallelGDSRequests ¶
func (s *Server) ParallelGDSRequests(ctx context.Context, rpc RPC, flatten bool) (results []interface{}, errs []error)
ParallelGDSRequests makes concurrent requests to both the testnet and the mainnet, storing the results and errors in a slice of length 2 ([testnet, mainnet]). If the flatten bool is true, then nil values are removed from the slice (though this will make which network returned the result ambiguous).
func (*Server) RegistrationStatus ¶ added in v1.5.0
RegistrationStatus returns the registration status for both testnet and mainnet for the user.
func (*Server) ReplaceCollaborator ¶ added in v1.5.2
ReplaceCollaborator completely replaces a collaborator on the user's organization with the collaborator in the request. The collaborator object in the request must be valid and the user must have the update:collaborators permission.
func (*Server) SaveAuth0AppMetadata ¶ added in v1.5.0
func (s *Server) SaveAuth0AppMetadata(uid string, appdata auth.AppMetadata) (err error)
func (*Server) SaveRegisterForm ¶ added in v1.5.0
Saves the registration form on the BFF to allow multiple users to edit the registration form before it is submitted to the directory service.
func (*Server) SetAdminClients ¶ added in v1.5.0
func (s *Server) SetAdminClients(testnet, mainnet apiv2.DirectoryAdministrationClient)
SetAdminClients allows tests to set the admin clients to the mocked clients.
func (*Server) SetGDSClients ¶ added in v1.5.0
SetGDSClients allows tests to set a bufconn client to a mock GDS server.
func (*Server) SubmitRegistration ¶ added in v1.5.0
SubmitRegistration makes a request on behalf of the user to either the TestNet or the MainNet GDS server based on the URL endpoint. The endpoint will first load the saved registration form from the front-end and will parse it for some basic validity constraints - it will then submit the form and return any response from the directory.
func (*Server) VerifyContact ¶
VerifyContact is currently a passthrough helper that forwards the verify contact request from the user interface to the GDS that needs contact verification.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
api
|
|
authtest
Package authtest provides a wrapped httptest.Server that will respond to auth0 requests.
|
Package authtest provides a wrapped httptest.Server that will respond to auth0 requests. |
clive
Package clive provides CLI-Live interactions with Auth0 by running a local server for OAuth challenges and handling them on behalf of the user.
|
Package clive provides CLI-Live interactions with Auth0 by running a local server for OAuth challenges and handling them on behalf of the user. |