Skip to content

Commit

Permalink
Add #248 Integrate IDP endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa committed Oct 19, 2023
1 parent b68de14 commit 5146fde
Show file tree
Hide file tree
Showing 44 changed files with 1,089 additions and 977 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ require (
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/Nerzal/gocloak/v13 v13.8.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/coreos/go-oidc/v3 v3.6.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/confluentinc/confluent-kafka-go v1.4.2 h1:13EK9RTujF7lVkvHQ5Hbu6bM+Yfrq8L0MkJNnjHSd4Q=
github.com/confluentinc/confluent-kafka-go v1.4.2/go.mod h1:u2zNLny2xq+5rWeTQjFHbDzzNuba4P1vo31r9r4uAdg=
github.com/coreos/go-oidc/v3 v3.6.0 h1:AKVxfYw1Gmkn/w96z0DbT/B/xFnzTd3MkZvWLjF4n/o=
github.com/coreos/go-oidc/v3 v3.6.0/go.mod h1:ZpHUsHBucTUj6WOkrP4E20UPynbLZzhTQ1XKCXkxyPc=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -57,6 +59,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo=
github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8=
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
Expand Down Expand Up @@ -180,6 +184,7 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
Expand Down
1 change: 1 addition & 0 deletions src/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
DataAgreementRecordId = "dataAgreementRecordId"
IndividualId = "individualId"
DeliveryId = "deliveryId"
IdpId = "idpId"
)

// Schemas
Expand Down
5 changes: 5 additions & 0 deletions src/database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ func Init(config *config.Configuration) error {
return err
}

err = initCollection("identityProviders", []string{"id"}, true)
if err != nil {
return err
}

return nil
}

Expand Down
11 changes: 7 additions & 4 deletions src/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"github.com/bb-consent/api/src/token"
v1Handlers "github.com/bb-consent/api/src/v1/handler"
v1HttpPaths "github.com/bb-consent/api/src/v1/http_path"
v2Handlers "github.com/bb-consent/api/src/v2/handler"
individualHandler "github.com/bb-consent/api/src/v2/handler/individual"
v2HttpPaths "github.com/bb-consent/api/src/v2/http_path"
"github.com/bb-consent/api/src/v2/iam"
"github.com/bb-consent/api/src/v2/twilio"
"github.com/bb-consent/api/src/webhooks"
"github.com/casbin/casbin/v2"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -51,10 +51,13 @@ func startAPICmdHandlerfunc(cmd *cobra.Command, args []string) {

// IAM
v1Handlers.IamInit(loadedConfig)
v2Handlers.IamInit(loadedConfig)
individualHandler.IamInit(loadedConfig)
iam.Init(loadedConfig)
log.Println("Iam initialized")

// Twilio
twilio.Init(loadedConfig)
log.Println("Twilio initialized")

// Email
email.Init(loadedConfig)
log.Println("Email initialized")
Expand Down
29 changes: 29 additions & 0 deletions src/v2/error_handler/error_handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package error_handler

import (
"encoding/json"
"net/http"
)

type HttpError struct {
Status int `json:"errorCode"`
Message string `json:"errorDescription"`
}

func HandleExit(w http.ResponseWriter) {
r := recover()
if r != nil {
if he, ok := r.(HttpError); ok {
response, _ := json.Marshal(he)
w.WriteHeader(he.Status)
w.Header().Set("Content-Type", "application/json")
w.Write(response)
} else {
panic(r)
}
}
}

func Exit(status int, message string) {
panic(HttpError{Status: status, Message: message})
}
Loading

0 comments on commit 5146fde

Please sign in to comment.