Skip to content

Commit

Permalink
Fix #527 Service: READ - Read an IDP
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa authored and georgepadayatti committed Nov 13, 2023
1 parent c81c219 commit 5e2dcb7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
26 changes: 19 additions & 7 deletions internal/handler/v2/service/service_read_idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion internal/http_path/v2/service_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion internal/rbac/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 5e2dcb7

Please sign in to comment.