diff --git a/src/main/audit_paths.go b/src/main/audit_paths.go new file mode 100644 index 0000000..71511cc --- /dev/null +++ b/src/main/audit_paths.go @@ -0,0 +1,3 @@ +package main + +const GetOrgLogs = "/v1/organizations/{orgID}/logs" diff --git a/src/main/config_paths.go b/src/main/config_paths.go new file mode 100644 index 0000000..62758d3 --- /dev/null +++ b/src/main/config_paths.go @@ -0,0 +1,36 @@ +package main + +// Global policy configuration +const GetGlobalPolicyConfiguration = "/v1/organizations/{organizationID}/global-policy-configuration" +const UpdateGlobalPolicyConfiguration = "/v1/organizations/{organizationID}/global-policy-configuration" + +// Data agreements +const AddConsentPurposes = "/v1/organizations/{organizationID}/purposes" +const GetPurposes = "/v1/organizations/{organizationID}/purposes" +const DeleteConsentPurposeByID = "/v1/organizations/{organizationID}/purposes/{purposeID}" +const UpdatePurposeByID = "/v1/organizations/{organizationID}/purposes/{purposeID}" +const GetPurposeByID = "/v1/organizations/{organizationID}/purposes/{purposeID}" + +// Data attributes +const AddConsentTemplates = "/v1/organizations/{organizationID}/templates" +const GetTemplates = "/v1/organizations/{organizationID}/templates" +const DeleteConsentTemplateByID = "/v1/organizations/{organizationID}/templates/{templateID}" +const GetTemplateByID = "/v1/organizations/{organizationID}/templates/{templateID}" +const UpdateTemplateByID = "/v1/organizations/{organizationID}/templates/{templateID}" +const DeleteConsentTemplatesByID = "/v1/organizations/{organizationID}/purposes/{purposeID}/templates" + +// Webhooks +const GetWebhookPayloadContentTypes = "/v1/organizations/webhooks/payload/content-types" +const CreateWebhook = "/v1/organizations/{orgID}/webhooks" +const GetAllWebhooks = "/v1/organizations/{orgID}/webhooks" +const GetWebhook = "/v1/organizations/{orgID}/webhooks/{webhookID}" +const DeleteWebhook = "/v1/organizations/{orgID}/webhooks/{webhookID}" +const UpdateWebhook = "/v1/organizations/{orgID}/webhooks/{webhookID}" +const PingWebhook = "/v1/organizations/{orgID}/webhooks/{webhookID}/ping" +const GetRecentWebhookDeliveries = "/v1/organizations/{orgID}/webhooks/{webhookID}/delivery" +const GetWebhookDeliveryByID = "/v1/organizations/{orgID}/webhooks/{webhookID}/delivery/{deliveryID}" +const ReDeliverWebhook = "/v1/organizations/{orgID}/webhooks/{webhookID}/delivery/{deliveryID}/redeliver" + +// Filtering individuals by consents +const GetAllUsersConsentedToAttribute = "/v1/organizations/{orgID}/purposes/{purposeID}/attributes/{attributeID}/consented/users" +const GetAllUsersConsentedToPurpose = "/v1/organizations/{orgID}/purposes/{purposeID}/consented/users" diff --git a/src/main/onboard_paths.go b/src/main/onboard_paths.go new file mode 100644 index 0000000..2b9efb6 --- /dev/null +++ b/src/main/onboard_paths.go @@ -0,0 +1,81 @@ +package main + +const AddOrganization = "/v1/organizations" +const GetOrganizationRoles = "/v1/organizations/roles" +const GetSubscribeMethods = "/v1/organizations/subscribe-methods" +const GetDataRequestStatus = "/v1/organizations/data-requests" +const GetOrganizationTypes = "/v1/organizations/types" +const AddOrganizationType = "/v1/organizations/types" +const UpdateOrganizationType = "/v1/organizations/types/{typeID}" +const DeleteOrganizationType = "/v1/organizations/types/{typeID}" +const GetOrganizationTypeByID = "/v1/organizations/types/{typeID}" +const UpdateOrganizationTypeImage = "/v1/organizations/types/{typeID}/image" +const GetOrganizationTypeImage = "/v1/organizations/types/{typeID}/image" + +const GetWebhookEventTypes = "/v1/organizations/webhooks/event-types" + +const GetOrganizationByID = "/v1/organizations/{organizationID}" +const UpdateOrganization = "/v1/organizations/{organizationID}" +const UpdateOrganizationCoverImage = "/v1/organizations/{organizationID}/coverimage" +const UpdateOrganizationLogoImage = "/v1/organizations/{organizationID}/logoimage" +const GetOrganizationImage = "/v1/organizations/{organizationID}/image/{imageID}" +const GetOrganizationImageWeb = "/v1/organizations/{organizationID}/image/{imageID}/web" + +const UpdateOrgEula = "/v1/organizations/{organizationID}/eulaURL" +const DeleteOrgEula = "/v1/organizations/{organizationID}/eulaURL" + +const AddOrgAdmin = "/v1/organizations/{organizationID}/admins" +const GetOrgAdmins = "/v1/organizations/{organizationID}/admins" +const DeleteOrgAdmin = "/v1/organizations/{organizationID}/admins" + +// Organisation identity provider related API(s) +const AddIdentityProvider = "/v1/organizations/{organizationID}/idp/open-id" +const UpdateIdentityProvider = "/v1/organizations/{organizationID}/idp/open-id" +const DeleteIdentityProvider = "/v1/organizations/{organizationID}/idp/open-id" +const GetIdentityProvider = "/v1/organizations/{organizationID}/idp/open-id" + +// Login +const RegisterUser = "/v1/users/register" +const LoginUser = "/v1/users/login" +const LoginUserV11 = "/v1.1/users/login" +const ValidateUserEmail = "/v1/users/validate/email" +const ValidatePhoneNumber = "/v1/users/validate/phone" +const VerifyPhoneNumber = "/v1/users/verify/phone" +const VerifyOtp = "/v1/users/verify/otp" + +// Admin login +const LoginAdminUser = "/v1/users/admin/login" +const GetToken = "/v1/users/token" +const ResetPassword = "/v1/user/password/reset" +const ForgotPassword = "/v1/user/password/forgot" +const LogoutUser = "/v1/users/logout" +const UnregisterUser = "/v1/users/unregister" + +const GetCurrentUser = "/v1/user" +const UpdateCurrentUser = "/v1/user" +const UserClientRegisterIOS = "/v1/user/register/ios" +const UserClientRegisterAndroid = "/v1/user/register/android" + +const CreateAPIKey = "/v1/user/apikey" +const DeleteAPIKey = "/v1/user/apikey/revoke" +const GetAPIKey = "/v1/user/apikey" + +const EnableOrganizationSubscription = "/v1/organizations/{organizationID}/subscription/enable" +const DisableOrganizationSubscription = "/v1/organizations/{organizationID}/subscription/disable" +const GetSubscribeMethod = "/v1/organizations/{organizationID}/subscribe-method" +const SetSubscribeMethod = "/v1/organizations/{organizationID}/subscribe-method" +const GetSubscribeKey = "/v1/organizations/{organizationID}/subscribe-key" +const RenewSubscribeKey = "/v1/organizations/{organizationID}/subscribe-key/renew" +const GetOrganizationSubscriptionStatus = "/v1/organizations/{organizationID}/subscription" + +const GetDataRequests = "/v1/organizations/{orgID}/data-requests" +const GetDataRequest = "/v1/organizations/{orgID}/data-requests/{dataReqID}" +const UpdateDataRequests = "/v1/organizations/{orgID}/data-requests/{dataReqID}" + +const NotifyDataBreach = "/v1/organizations/{orgID}/notify-data-breach" +const NotifyEvents = "/v1/organizations/{orgID}/notify-events" + +const AddUserToOrganization = "/v1/organizations/{organizationID}/users" +const DeleteUserFromOrganization = "/v1/organizations/{organizationID}/users/{userID}" +const GetOrganizationUsers = "/v1/organizations/{organizationID}/users" +const GetOrganizationUsersCount = "/v1/organizations/{organizationID}/users/count" diff --git a/src/main/routes.go b/src/main/routes.go index 155c59b..8b15797 100644 --- a/src/main/routes.go +++ b/src/main/routes.go @@ -19,145 +19,145 @@ func healthz(w http.ResponseWriter, r *http.Request) { func SetRoutes(r *mux.Router, e *casbin.Enforcer) { r.HandleFunc("/", healthz).Methods("GET") - r.Handle("/v1/organizations", m.Chain(handler.AddOrganization, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/roles", m.Chain(handler.GetOrganizationRoles, m.Logger(), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/subscribe-methods", m.Chain(handler.GetSubscribeMethods, m.Logger(), m.Authenticate())).Methods("GET") + r.Handle(AddOrganization, m.Chain(handler.AddOrganization, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetOrganizationRoles, m.Chain(handler.GetOrganizationRoles, m.Logger(), m.Authenticate())).Methods("GET") + r.Handle(GetSubscribeMethods, m.Chain(handler.GetSubscribeMethods, m.Logger(), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/data-requests", m.Chain(handler.GetDataRequestStatus, m.Logger(), m.Authenticate())).Methods("GET") + r.Handle(GetDataRequestStatus, m.Chain(handler.GetDataRequestStatus, m.Logger(), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/types", m.Chain(handler.GetOrganizationTypes, m.LoggerNoAuth())).Methods("GET") - r.Handle("/v1/organizations/types", m.Chain(handler.AddOrganizationType, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/types/{typeID}", m.Chain(handler.UpdateOrganizationType, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") - r.Handle("/v1/organizations/types/{typeID}", m.Chain(handler.DeleteOrganizationType, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - r.Handle("/v1/organizations/types/{typeID}", m.Chain(handler.GetOrganizationTypeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/types/{typeID}/image", m.Chain(handler.UpdateOrganizationTypeImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/types/{typeID}/image", m.Chain(handler.GetOrganizationTypeImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetOrganizationTypes, m.Chain(handler.GetOrganizationTypes, m.LoggerNoAuth())).Methods("GET") + r.Handle(AddOrganizationType, m.Chain(handler.AddOrganizationType, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(UpdateOrganizationType, m.Chain(handler.UpdateOrganizationType, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") + r.Handle(DeleteOrganizationType, m.Chain(handler.DeleteOrganizationType, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + r.Handle(GetOrganizationTypeByID, m.Chain(handler.GetOrganizationTypeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(UpdateOrganizationTypeImage, m.Chain(handler.UpdateOrganizationTypeImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetOrganizationTypeImage, m.Chain(handler.GetOrganizationTypeImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") // Organization webhook event types - r.Handle("/v1/organizations/webhooks/event-types", m.Chain(handler.GetWebhookEventTypes, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - - r.Handle("/v1/organizations/{organizationID}", m.Chain(handler.GetOrganizationByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}", m.Chain(handler.UpdateOrganization, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") - r.Handle("/v1/organizations/{organizationID}/coverimage", m.Chain(handler.UpdateOrganizationCoverImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/logoimage", m.Chain(handler.UpdateOrganizationLogoImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/image/{imageID}", m.Chain(handler.GetOrganizationImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/image/{imageID}/web", m.Chain(handler.GetOrganizationImageWeb, m.LoggerNoAuth())).Methods("GET") - - r.Handle("/v1/organizations/{organizationID}/eulaURL", m.Chain(handler.UpdateOrgEula, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/eulaURL", m.Chain(handler.DeleteOrgEula, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - - r.Handle("/v1/organizations/{organizationID}/admins", m.Chain(handler.AddOrgAdmin, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/admins", m.Chain(handler.GetOrgAdmins, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/admins", m.Chain(handler.DeleteOrgAdmin, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - - r.Handle("/v1/organizations/{organizationID}/purposes", m.Chain(handler.AddConsentPurposes, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/purposes", m.Chain(handler.GetPurposes, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/purposes/{purposeID}", m.Chain(handler.DeleteConsentPurposeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - r.Handle("/v1/organizations/{organizationID}/purposes/{purposeID}", m.Chain(handler.UpdatePurposeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") - r.Handle("/v1/organizations/{organizationID}/purposes/{purposeID}", m.Chain(handler.GetPurposeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - - r.Handle("/v1/organizations/{organizationID}/templates", m.Chain(handler.AddConsentTemplates, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/templates", m.Chain(handler.GetTemplates, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/templates/{templateID}", m.Chain(handler.DeleteConsentTemplateByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - r.Handle("/v1/organizations/{organizationID}/purposes/{purposeID}/templates", m.Chain(handler.DeleteConsentTemplatesByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - r.Handle("/v1/organizations/{organizationID}/templates/{templateID}", m.Chain(handler.GetTemplateByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/templates/{templateID}", m.Chain(handler.UpdateTemplateByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") - - r.Handle("/v1/organizations/{organizationID}/users", m.Chain(handler.AddUserToOrganization, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/users/{userID}", m.Chain(handler.DeleteUserFromOrganization, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - r.Handle("/v1/organizations/{organizationID}/users", m.Chain(handler.GetOrganizationUsers, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/users/count", m.Chain(handler.GetOrganizationUsersCount, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetWebhookEventTypes, m.Chain(handler.GetWebhookEventTypes, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + + r.Handle(GetOrganizationByID, m.Chain(handler.GetOrganizationByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(UpdateOrganization, m.Chain(handler.UpdateOrganization, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") + r.Handle(UpdateOrganizationCoverImage, m.Chain(handler.UpdateOrganizationCoverImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(UpdateOrganizationLogoImage, m.Chain(handler.UpdateOrganizationLogoImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetOrganizationImage, m.Chain(handler.GetOrganizationImage, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetOrganizationImageWeb, m.Chain(handler.GetOrganizationImageWeb, m.LoggerNoAuth())).Methods("GET") + + r.Handle(UpdateOrgEula, m.Chain(handler.UpdateOrgEula, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(DeleteOrgEula, m.Chain(handler.DeleteOrgEula, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + + r.Handle(AddOrgAdmin, m.Chain(handler.AddOrgAdmin, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetOrgAdmins, m.Chain(handler.GetOrgAdmins, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(DeleteOrgAdmin, m.Chain(handler.DeleteOrgAdmin, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + + r.Handle(AddConsentPurposes, m.Chain(handler.AddConsentPurposes, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetPurposes, m.Chain(handler.GetPurposes, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(DeleteConsentPurposeByID, m.Chain(handler.DeleteConsentPurposeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + r.Handle(UpdatePurposeByID, m.Chain(handler.UpdatePurposeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") + r.Handle(GetPurposeByID, m.Chain(handler.GetPurposeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + + r.Handle(AddConsentTemplates, m.Chain(handler.AddConsentTemplates, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetTemplates, m.Chain(handler.GetTemplates, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(DeleteConsentTemplateByID, m.Chain(handler.DeleteConsentTemplateByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + r.Handle(DeleteConsentTemplatesByID, m.Chain(handler.DeleteConsentTemplatesByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + r.Handle(GetTemplateByID, m.Chain(handler.GetTemplateByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(UpdateTemplateByID, m.Chain(handler.UpdateTemplateByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") + + r.Handle(AddUserToOrganization, m.Chain(handler.AddUserToOrganization, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(DeleteUserFromOrganization, m.Chain(handler.DeleteUserFromOrganization, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + r.Handle(GetOrganizationUsers, m.Chain(handler.GetOrganizationUsers, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetOrganizationUsersCount, m.Chain(handler.GetOrganizationUsersCount, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") // Organization global policy configuration - r.Handle("/v1/organizations/{organizationID}/global-policy-configuration", m.Chain(handler.GetGlobalPolicyConfiguration, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/global-policy-configuration", m.Chain(handler.UpdateGlobalPolicyConfiguration, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetGlobalPolicyConfiguration, m.Chain(handler.GetGlobalPolicyConfiguration, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(UpdateGlobalPolicyConfiguration, m.Chain(handler.UpdateGlobalPolicyConfiguration, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/subscription/enable", m.Chain(handler.EnableOrganizationSubscription, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/subscription/disable", m.Chain(handler.DisableOrganizationSubscription, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/subscribe-method", m.Chain(handler.GetSubscribeMethod, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/subscribe-method", m.Chain(handler.SetSubscribeMethod, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/subscribe-key", m.Chain(handler.GetSubscribeKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{organizationID}/subscribe-key/renew", m.Chain(handler.RenewSubscribeKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/subscription", m.Chain(handler.GetOrganizationSubscriptionStatus, m.Logger(), m.Authenticate())).Methods("GET") + r.Handle(EnableOrganizationSubscription, m.Chain(handler.EnableOrganizationSubscription, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(DisableOrganizationSubscription, m.Chain(handler.DisableOrganizationSubscription, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetSubscribeMethod, m.Chain(handler.GetSubscribeMethod, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(SetSubscribeMethod, m.Chain(handler.SetSubscribeMethod, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetSubscribeKey, m.Chain(handler.GetSubscribeKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(RenewSubscribeKey, m.Chain(handler.RenewSubscribeKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetOrganizationSubscriptionStatus, m.Chain(handler.GetOrganizationSubscriptionStatus, m.Logger(), m.Authenticate())).Methods("GET") // Organisation identity provider related API(s) - r.Handle("/v1/organizations/{organizationID}/idp/open-id", m.Chain(handler.AddIdentityProvider, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{organizationID}/idp/open-id", m.Chain(handler.UpdateIdentityProvider, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") - r.Handle("/v1/organizations/{organizationID}/idp/open-id", m.Chain(handler.DeleteIdentityProvider, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - r.Handle("/v1/organizations/{organizationID}/idp/open-id", m.Chain(handler.GetIdentityProvider, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - - r.Handle("/v1/organizations/{orgID}/users/{userID}/consents", m.Chain(handler.GetConsents, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/users/{userID}/consents/{consentID}", m.Chain(handler.GetConsentByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/users/{userID}/consents/{consentID}/purposes/{purposeID}", m.Chain(handler.GetConsentPurposeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/purposes/{purposeID}/attributes/{attributeID}/consented/users", m.Chain(handler.GetAllUsersConsentedToAttribute, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/users/{userID}/consents/{consentID}/purposes/{purposeID}/status", m.Chain(handler.GetPurposeAllConsentStatus, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/users/{userID}/consents/{consentID}/purposes/{purposeID}/status", m.Chain(handler.UpdatePurposeAllConsentsv2, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{orgID}/users/{userID}/consents/{consentID}/purposes/{purposeID}/attributes/{attributeID}", m.Chain(handler.UpdatePurposeAttribute, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") - r.Handle("/v1/organizations/{orgID}/purposes/{purposeID}/consented/users", m.Chain(handler.GetAllUsersConsentedToPurpose, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - - r.Handle("/v1/organizations/{orgID}/notify-data-breach", m.Chain(handler.NotifyDataBreach, m.Logger(), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{orgID}/notify-events", m.Chain(handler.NotifyEvents, m.Logger(), m.Authenticate())).Methods("POST") - - r.Handle("/v1/organizations/{orgID}/data-requests", m.Chain(handler.GetDataRequests, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/data-requests/{dataReqID}", m.Chain(handler.GetDataRequest, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/data-requests/{dataReqID}", m.Chain(handler.UpdateDataRequests, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") + r.Handle(AddIdentityProvider, m.Chain(handler.AddIdentityProvider, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(UpdateIdentityProvider, m.Chain(handler.UpdateIdentityProvider, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") + r.Handle(DeleteIdentityProvider, m.Chain(handler.DeleteIdentityProvider, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + r.Handle(GetIdentityProvider, m.Chain(handler.GetIdentityProvider, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + + r.Handle(GetConsents, m.Chain(handler.GetConsents, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetConsentByID, m.Chain(handler.GetConsentByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetConsentPurposeByID, m.Chain(handler.GetConsentPurposeByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetAllUsersConsentedToAttribute, m.Chain(handler.GetAllUsersConsentedToAttribute, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetPurposeAllConsentStatus, m.Chain(handler.GetPurposeAllConsentStatus, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(UpdatePurposeAllConsentsv2, m.Chain(handler.UpdatePurposeAllConsentsv2, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(UpdatePurposeAttribute, m.Chain(handler.UpdatePurposeAttribute, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") + r.Handle(GetAllUsersConsentedToPurpose, m.Chain(handler.GetAllUsersConsentedToPurpose, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + + r.Handle(NotifyDataBreach, m.Chain(handler.NotifyDataBreach, m.Logger(), m.Authenticate())).Methods("POST") + r.Handle(NotifyEvents, m.Chain(handler.NotifyEvents, m.Logger(), m.Authenticate())).Methods("POST") + + r.Handle(GetDataRequests, m.Chain(handler.GetDataRequests, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetDataRequest, m.Chain(handler.GetDataRequest, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(UpdateDataRequests, m.Chain(handler.UpdateDataRequests, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") // Organisation webhooks related api(s) - r.Handle("/v1/organizations/webhooks/payload/content-types", m.Chain(handler.GetWebhookPayloadContentTypes, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/webhooks", m.Chain(handler.CreateWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{orgID}/webhooks", m.Chain(handler.GetAllWebhooks, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/webhooks/{webhookID}", m.Chain(handler.GetWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/webhooks/{webhookID}", m.Chain(handler.DeleteWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - r.Handle("/v1/organizations/{orgID}/webhooks/{webhookID}", m.Chain(handler.UpdateWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") - r.Handle("/v1/organizations/{orgID}/webhooks/{webhookID}/ping", m.Chain(handler.PingWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/organizations/{orgID}/webhooks/{webhookID}/delivery", m.Chain(handler.GetRecentWebhookDeliveries, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/webhooks/{webhookID}/delivery/{deliveryID}", m.Chain(handler.GetWebhookDeliveryByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/organizations/{orgID}/webhooks/{webhookID}/delivery/{deliveryID}/redeliver", m.Chain(handler.ReDeliverWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetWebhookPayloadContentTypes, m.Chain(handler.GetWebhookPayloadContentTypes, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(CreateWebhook, m.Chain(handler.CreateWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetAllWebhooks, m.Chain(handler.GetAllWebhooks, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetWebhook, m.Chain(handler.GetWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(DeleteWebhook, m.Chain(handler.DeleteWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + r.Handle(UpdateWebhook, m.Chain(handler.UpdateWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") + r.Handle(PingWebhook, m.Chain(handler.PingWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetRecentWebhookDeliveries, m.Chain(handler.GetRecentWebhookDeliveries, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetWebhookDeliveryByID, m.Chain(handler.GetWebhookDeliveryByID, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(ReDeliverWebhook, m.Chain(handler.ReDeliverWebhook, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") // organization action logs - r.Handle("/v1/organizations/{orgID}/logs", m.Chain(handler.GetOrgLogs, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetOrgLogs, m.Chain(handler.GetOrgLogs, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") //Login - r.Handle("/v1/users/register", m.Chain(handler.RegisterUser, m.LoggerNoAuth())).Methods("POST") - r.Handle("/v1/users/login", m.Chain(handler.LoginUser, m.LoggerNoAuth())).Methods("POST") - r.Handle("/v1.1/users/login", m.Chain(handler.LoginUserV11, m.LoggerNoAuth())).Methods("POST") - r.Handle("/v1/users/validate/email", m.Chain(handler.ValidateUserEmail, m.LoggerNoAuth())).Methods("POST") - r.Handle("/v1/users/validate/phone", m.Chain(handler.ValidatePhoneNumber, m.LoggerNoAuth())).Methods("POST") - r.Handle("/v1/users/verify/phone", m.Chain(handler.VerifyPhoneNumber, m.LoggerNoAuth())).Methods("POST") - r.Handle("/v1/users/verify/otp", m.Chain(handler.VerifyOtp, m.LoggerNoAuth())).Methods("POST") + r.Handle(RegisterUser, m.Chain(handler.RegisterUser, m.LoggerNoAuth())).Methods("POST") + r.Handle(LoginUser, m.Chain(handler.LoginUser, m.LoggerNoAuth())).Methods("POST") + r.Handle(LoginUserV11, m.Chain(handler.LoginUserV11, m.LoggerNoAuth())).Methods("POST") + r.Handle(ValidateUserEmail, m.Chain(handler.ValidateUserEmail, m.LoggerNoAuth())).Methods("POST") + r.Handle(ValidatePhoneNumber, m.Chain(handler.ValidatePhoneNumber, m.LoggerNoAuth())).Methods("POST") + r.Handle(VerifyPhoneNumber, m.Chain(handler.VerifyPhoneNumber, m.LoggerNoAuth())).Methods("POST") + r.Handle(VerifyOtp, m.Chain(handler.VerifyOtp, m.LoggerNoAuth())).Methods("POST") // Admin login - r.Handle("/v1/users/admin/login", m.Chain(handler.LoginAdminUser, m.LoggerNoAuth())).Methods("POST") - r.Handle("/v1/users/token", http.HandlerFunc(handler.GetToken)).Methods("POST") - r.Handle("/v1/user/password/reset", m.Chain(handler.ResetPassword, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") - r.Handle("/v1/user/password/forgot", m.Chain(handler.ForgotPassword, m.LoggerNoAuth())).Methods("PUT") - r.Handle("/v1/users/logout", m.Chain(handler.LogoutUser, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/users/unregister", m.Chain(handler.UnregisterUser, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(LoginAdminUser, m.Chain(handler.LoginAdminUser, m.LoggerNoAuth())).Methods("POST") + r.Handle(GetToken, http.HandlerFunc(handler.GetToken)).Methods("POST") + r.Handle(ResetPassword, m.Chain(handler.ResetPassword, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PUT") + r.Handle(ForgotPassword, m.Chain(handler.ForgotPassword, m.LoggerNoAuth())).Methods("PUT") + r.Handle(LogoutUser, m.Chain(handler.LogoutUser, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(UnregisterUser, m.Chain(handler.UnregisterUser, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") //user - r.Handle("/v1/user", m.Chain(handler.GetCurrentUser, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/user", m.Chain(handler.UpdateCurrentUser, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") - r.Handle("/v1/user/register/ios", m.Chain(handler.UserClientRegister, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/user/register/android", m.Chain(handler.UserClientRegister, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetCurrentUser, m.Chain(handler.GetCurrentUser, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(UpdateCurrentUser, m.Chain(handler.UpdateCurrentUser, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("PATCH") + r.Handle(UserClientRegisterIOS, m.Chain(handler.UserClientRegister, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(UserClientRegisterAndroid, m.Chain(handler.UserClientRegister, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/user/apikey", m.Chain(handler.CreateAPIKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/user/apikey/revoke", m.Chain(handler.DeleteAPIKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") - r.Handle("/v1/user/apikey", m.Chain(handler.GetAPIKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(CreateAPIKey, m.Chain(handler.CreateAPIKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(DeleteAPIKey, m.Chain(handler.DeleteAPIKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("DELETE") + r.Handle(GetAPIKey, m.Chain(handler.GetAPIKey, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") //Consent History - r.Handle("/v1/users/{userID}/consenthistory", m.Chain(handler.GetUserConsentHistory, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetUserConsentHistory, m.Chain(handler.GetUserConsentHistory, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/user/organizations/{organizationID}/data-status", m.Chain(handler.GetMyOrgDataRequestStatus, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetMyOrgDataRequestStatus, m.Chain(handler.GetMyOrgDataRequestStatus, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/user/organizations/{orgID}/data-delete", m.Chain(handler.GetDeleteMyData, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/user/organizations/{orgID}/data-delete", m.Chain(handler.DeleteMyData, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/user/organizations/{orgID}/data-delete/status", m.Chain(handler.GetDeleteMyDataStatus, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/user/organizations/{orgID}/data-delete/{dataReqID}/cancel", m.Chain(handler.CancelMyDataRequest, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetDeleteMyData, m.Chain(handler.GetDeleteMyData, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(DeleteMyData, m.Chain(handler.DeleteMyData, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetDeleteMyDataStatus, m.Chain(handler.GetDeleteMyDataStatus, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(DataDeleteCancelMyDataRequest, m.Chain(handler.CancelMyDataRequest, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/user/organizations/{orgID}/data-download", m.Chain(handler.GetDownloadMyData, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/user/organizations/{orgID}/data-download", m.Chain(handler.DownloadMyData, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/user/organizations/{orgID}/data-download/status", m.Chain(handler.GetDownloadMyDataStatus, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") - r.Handle("/v1/user/organizations/{orgID}/data-download/{dataReqID}/cancel", m.Chain(handler.CancelMyDataRequest, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") - r.Handle("/v1/GetUserOrgsAndConsents", m.Chain(handler.GetUserOrgsAndConsents, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(GetDownloadMyData, m.Chain(handler.GetDownloadMyData, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(DownloadMyData, m.Chain(handler.DownloadMyData, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetDownloadMyDataStatus, m.Chain(handler.GetDownloadMyDataStatus, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") + r.Handle(DataDownloadCancelMyDataRequest, m.Chain(handler.CancelMyDataRequest, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("POST") + r.Handle(GetUserOrgsAndConsents, m.Chain(handler.GetUserOrgsAndConsents, m.Logger(), m.Authorize(e), m.Authenticate())).Methods("GET") } diff --git a/src/main/service_paths.go b/src/main/service_paths.go new file mode 100644 index 0000000..be9977f --- /dev/null +++ b/src/main/service_paths.go @@ -0,0 +1,19 @@ +package main + +const GetUserConsentHistory = "/v1/users/{userID}/consenthistory" +const GetConsentPurposeByID = "/v1/organizations/{orgID}/users/{userID}/consents/{consentID}/purposes/{purposeID}" +const GetConsentByID = "/v1/organizations/{orgID}/users/{userID}/consents/{consentID}" +const GetConsents = "/v1/organizations/{orgID}/users/{userID}/consents" +const GetPurposeAllConsentStatus = "/v1/organizations/{orgID}/users/{userID}/consents/{consentID}/purposes/{purposeID}/status" +const UpdatePurposeAllConsentsv2 = "/v1/organizations/{orgID}/users/{userID}/consents/{consentID}/purposes/{purposeID}/status" +const UpdatePurposeAttribute = "/v1/organizations/{orgID}/users/{userID}/consents/{consentID}/purposes/{purposeID}/attributes/{attributeID}" +const GetMyOrgDataRequestStatus = "/v1/user/organizations/{organizationID}/data-status" +const GetDeleteMyData = "/v1/user/organizations/{orgID}/data-delete" +const DeleteMyData = "/v1/user/organizations/{orgID}/data-delete" +const GetDeleteMyDataStatus = "/v1/user/organizations/{orgID}/data-delete/status" +const DataDeleteCancelMyDataRequest = "/v1/user/organizations/{orgID}/data-delete/{dataReqID}/cancel" +const GetDownloadMyData = "/v1/user/organizations/{orgID}/data-download" +const DownloadMyData = "/v1/user/organizations/{orgID}/data-download" +const GetDownloadMyDataStatus = "/v1/user/organizations/{orgID}/data-download/status" +const DataDownloadCancelMyDataRequest = "/v1/user/organizations/{orgID}/data-download/{dataReqID}/cancel" +const GetUserOrgsAndConsents = "/v1/GetUserOrgsAndConsents"