Skip to content

Commit be4a74c

Browse files
authored
Merge pull request #817 from tidepool-org/BACK-3392-abbott-sector-identifier
[BACK-3392] Add OpenID sector for Abbott OAuth
2 parents 9c6d9cd + a9d3173 commit be4a74c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

data/service/api/v1/partners.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package v1
2+
3+
import (
4+
"net/http"
5+
"os"
6+
7+
dataService "github.com/tidepool-org/platform/data/service"
8+
"github.com/tidepool-org/platform/request"
9+
)
10+
11+
// TODO: https://tidepool.atlassian.net/browse/BACK-3394 - This implementation is a
12+
// temporary placeholder to allow bootstrapping of the Abbott OAuth client workflow.
13+
// Will need to migrate this to environment variables and add minimal authorization.
14+
// For now, though, this is acceptable since it isn't revealing anything that is not
15+
// already available in other locations (i.e. other public repos).
16+
17+
func PartnersSector(dataServiceContext dataService.Context) {
18+
res := dataServiceContext.Response()
19+
req := dataServiceContext.Request()
20+
responder := request.MustNewResponder(res, req)
21+
22+
if partnerSectorIdentifers, ok := namespacePartnerSectorIdentifers[os.Getenv("POD_NAMESPACE")]; ok {
23+
if sectorIdentifier, ok := partnerSectorIdentifers[req.PathParam("partner")]; ok {
24+
responder.Data(http.StatusOK, sectorIdentifier)
25+
return
26+
}
27+
}
28+
29+
responder.Data(http.StatusOK, []string{})
30+
}
31+
32+
var namespacePartnerSectorIdentifers = map[string]map[string][]string{
33+
"external": {
34+
"abbott": {
35+
"https://external.integration.tidepool.org/v1/oauth/abbott/redirect",
36+
"https://external.integration.tidepool.org/v1/oauth/abbott-private-1/redirect",
37+
"https://external.integration.tidepool.org/v1/oauth/abbott-private-2/redirect",
38+
"https://qa1.development.tidepool.org/v1/oauth/abbott/redirect",
39+
"https://qa2.development.tidepool.org/v1/oauth/abbott/redirect",
40+
"https://qa3.development.tidepool.org/v1/oauth/abbott/redirect",
41+
"https://qa4.development.tidepool.org/v1/oauth/abbott/redirect",
42+
"https://qa5.development.tidepool.org/v1/oauth/abbott/redirect",
43+
"https://dev1.dev.tidepool.org/v1/oauth/abbott/redirect",
44+
},
45+
},
46+
}

data/service/api/v1/v1.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ func Routes() []service.Route {
2020
service.Put("/v1/data_sets/:dataSetId", DataSetsUpdate, api.RequireAuth),
2121
service.Get("/v1/time", TimeGet),
2222
service.Post("/v1/users/:userId/data_sets", UsersDataSetsCreate, api.RequireAuth),
23+
24+
service.Get("/v1/partners/:partner/sector", PartnersSector),
2325
}
2426

2527
routes = append(routes, DataSetsRoutes()...)

0 commit comments

Comments
 (0)