|
| 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 | +} |
0 commit comments