From 5e2dcb7bbf3008a95bb40c4662d6cb1e13f13950 Mon Sep 17 00:00:00 2001 From: Albin Antony Date: Mon, 13 Nov 2023 16:21:56 +0530 Subject: [PATCH] Fix #527 Service: READ - Read an IDP --- .../handler/v2/service/service_read_idp.go | 26 ++++++++++++++----- internal/http_path/v2/service_paths.go | 2 +- internal/rbac/rbac.go | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/internal/handler/v2/service/service_read_idp.go b/internal/handler/v2/service/service_read_idp.go index 23ac2b2..1a40a02 100644 --- a/internal/handler/v2/service/service_read_idp.go +++ b/internal/handler/v2/service/service_read_idp.go @@ -12,9 +12,15 @@ import ( ) type serviceIdp struct { - Id string `json:"id"` - LogoutUrl string `json:"logoutUrl"` - ClientId string `json:"clientId"` + Id string `json:"id" bson:"_id,omitempty"` + IssuerUrl string `json:"issuerUrl"` + AuthorizationURL string `json:"authorisationUrl"` + TokenURL string `json:"tokenUrl"` + LogoutURL string `json:"logoutUrl"` + ClientID string `json:"clientId"` + JWKSURL string `json:"jwksUrl"` + UserInfoURL string `json:"userInfoUrl"` + DefaultScope string `json:"defaultScope"` } type readIdpResp struct { @@ -36,16 +42,22 @@ func ServiceReadIdp(w http.ResponseWriter, r *http.Request) { idpRepo := idp.IdentityProviderRepository{} idpRepo.Init(organisationId) - idp, err := idpRepo.Get(idpId) + idp, err := idpRepo.GetByOrgId() if err != nil { m := fmt.Sprintf("Failed to fetch identity provider: %v", idpId) common.HandleErrorV2(w, http.StatusInternalServerError, m, err) return } idpResp := serviceIdp{ - Id: idp.Id.Hex(), - LogoutUrl: idp.LogoutURL, - ClientId: idp.ClientID, + Id: idp.Id.Hex(), + IssuerUrl: idp.IssuerUrl, + AuthorizationURL: idp.AuthorizationURL, + TokenURL: idp.TokenURL, + LogoutURL: idp.LogoutURL, + ClientID: idp.ClientID, + JWKSURL: idp.JWKSURL, + UserInfoURL: idp.UserInfoURL, + DefaultScope: idp.DefaultScope, } resp := readIdpResp{ diff --git a/internal/http_path/v2/service_paths.go b/internal/http_path/v2/service_paths.go index 2ed63f7..84ed1c0 100644 --- a/internal/http_path/v2/service_paths.go +++ b/internal/http_path/v2/service_paths.go @@ -32,7 +32,7 @@ const ServiceFetchRecordsForDataAgreement = "/v2/service/individual/record/data- const ServiceFetchRecordsHistory = "/v2/service/individual/record/consent-record/history" // Idp -const ServiceReadIdp = "/v2/service/idp/open-id/{idpId}" +const ServiceReadIdp = "/v2/service/idp/open-id" // Organisation const ServiceReadOrganisation = "/v2/service/organisation" diff --git a/internal/rbac/rbac.go b/internal/rbac/rbac.go index 2adbe13..dbd1fb5 100644 --- a/internal/rbac/rbac.go +++ b/internal/rbac/rbac.go @@ -76,7 +76,7 @@ func GetRbacPolicies() [][]string { {"organisation_admin", "/v2/onboard/status", "GET"}, {"user", "/v2/onboard/password/reset", "PUT"}, {"user", "/v2/service/individual/record/consent-record/history", "GET"}, - {"user", "/v2/service/idp/open-id/{idpId}", "GET"}, + {"user", "/v2/service/idp/open-id", "GET"}, {"user", "/v2/service/organisation", "GET"}, {"user", "/v2/service/organisation/coverimage", "GET"}, {"user", "/v2/service/organisation/logoimage", "GET"},