Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACK-3392] Add OpenID sector for Abbott OAuth #817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions data/service/api/v1/partners.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package v1

import (
"net/http"
"os"

dataService "github.com/tidepool-org/platform/data/service"
"github.com/tidepool-org/platform/request"
)

// TODO: https://tidepool.atlassian.net/browse/BACK-3394 - This implementation is a
// temporary placeholder to allow bootstrapping of the Abbott OAuth client workflow.
// Will need to migrate this to environment variables and add minimal authorization.
// For now, though, this is acceptable since it isn't revealing anything that is not
// already available in other locations (i.e. other public repos).

func PartnersSector(dataServiceContext dataService.Context) {
res := dataServiceContext.Response()
req := dataServiceContext.Request()
responder := request.MustNewResponder(res, req)

if partnerSectorIdentifers, ok := namespacePartnerSectorIdentifers[os.Getenv("POD_NAMESPACE")]; ok {
if sectorIdentifier, ok := partnerSectorIdentifers[req.PathParam("partner")]; ok {
responder.Data(http.StatusOK, sectorIdentifier)
return
}
}

responder.Data(http.StatusOK, []string{})
}

var namespacePartnerSectorIdentifers = map[string]map[string][]string{
"external": {
"abbott": {
"https://external.integration.tidepool.org/v1/oauth/abbott/redirect",
"https://external.integration.tidepool.org/v1/oauth/abbott-private-1/redirect",
"https://external.integration.tidepool.org/v1/oauth/abbott-private-2/redirect",
"https://qa1.development.tidepool.org/v1/oauth/abbott/redirect",
"https://qa2.development.tidepool.org/v1/oauth/abbott/redirect",
"https://qa3.development.tidepool.org/v1/oauth/abbott/redirect",
"https://qa4.development.tidepool.org/v1/oauth/abbott/redirect",
"https://qa5.development.tidepool.org/v1/oauth/abbott/redirect",
"https://dev1.dev.tidepool.org/v1/oauth/abbott/redirect",
},
},
}
2 changes: 2 additions & 0 deletions data/service/api/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func Routes() []service.Route {
service.Put("/v1/data_sets/:dataSetId", DataSetsUpdate, api.RequireAuth),
service.Get("/v1/time", TimeGet),
service.Post("/v1/users/:userId/data_sets", UsersDataSetsCreate, api.RequireAuth),

service.Get("/v1/partners/:partner/sector", PartnersSector),
}

routes = append(routes, DataSetsRoutes()...)
Expand Down