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

31 task prepare for deployment in openshift #32

Open
wants to merge 5 commits into
base: develop
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
27 changes: 12 additions & 15 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
Expand Down Expand Up @@ -109,6 +105,12 @@
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
},
{
"path": "detect_secrets.filters.regex.should_exclude_file",
"pattern": [
"go.sum"
]
}
],
"results": {
Expand All @@ -118,8 +120,7 @@
"filename": "README.md",
"hashed_secret": "112bb791304791ddcf692e29fd5cf149b35fea37",
"is_verified": false,
"line_number": 24,
"is_secret": false
"line_number": 24
}
],
"driven/notifications/adapter.go": [
Expand All @@ -128,8 +129,7 @@
"filename": "driven/notifications/adapter.go",
"hashed_secret": "03c74f71c365269b295b37da03c660ca800e1b24",
"is_verified": false,
"line_number": 32,
"is_secret": false
"line_number": 32
}
],
"driver/web/auth.go": [
Expand All @@ -138,16 +138,14 @@
"filename": "driver/web/auth.go",
"hashed_secret": "69fea84f27efff0bdf299bab3d77871a5d49c99e",
"is_verified": false,
"line_number": 167,
"is_secret": false
"line_number": 167
},
{
"type": "Secret Keyword",
"filename": "driver/web/auth.go",
"hashed_secret": "d8e8bbab2645e80215848443c09ca41ac5caa4e1",
"is_verified": false,
"line_number": 175,
"is_secret": false
"line_number": 175
}
],
"main.go": [
Expand All @@ -156,10 +154,9 @@
"filename": "main.go",
"hashed_secret": "a23be006fadbd85ce60d87580e3f127c58a824ce",
"is_verified": false,
"line_number": 139,
"is_secret": false
"line_number": 150
}
]
},
"generated_at": "2023-03-02T12:03:59Z"
"generated_at": "2023-07-06T16:17:26Z"
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Prepare for deployment in OpenShift [#31](https://github.com/rokwire/wellness-building-block/issues/31)
## [1.3.0] - 2023-04-26
### Changed
- Updated Docker file (use alpine:3.17)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ WELLNESS_HOST | < url > | yes | URL where this application is being hosted
WELLNESS_CORE_BB_HOST | < url > | yes | Core BB host URL
WELLNESS_SERVICE_URL | < url > | yes | URL where this application is being hosted
INTERNAL_API_KEY | < string > | yes | Internal API key for invocation by other BBs
WELLNESS_PRIV_KEY | < string > | yes | PEM encoded private key for Wellness BB
NOTIFICATIONS_BASE_URL | < url > | yes | Notifications BB host URL
WELLNESS_SERVICE_ACCOUNT_ID | < string > | yes | ID of Service Account for Wellness BB

### Run Application

Expand Down
19 changes: 19 additions & 0 deletions app-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"app_secret": {
"WELLNESS_MONGO_AUTH": "<mongo auth url>",
"INTERNAL_API_KEY": "<internal api key>",
"WELLNESS_PRIV_KEY": "<service account priv key>"
},
"app_config":{
"PORT": "5000",
"WELLNESS_MONGO_DATABASE": "<mongo database>",
"WELLNESS_MONGO_TIMEOUT": "",
"WELLNESS_MULTI_TENANCY_APP_ID": "<multi tenancy app id>",
"WELLNESS_MULTI_TENANCY_ORG_ID": "<multi tenancy org id>",
"NOTIFICATIONS_BASE_URL": "<notifications base url>",
"WELLNESS_SERVICE_ACCOUNT_ID": "<service account id>",
"WELLNESS_HOST": "<host>",
"WELLNESS_CORE_BB_HOST": "<core bb host>",
"WELLNESS_SERVICE_URL": "<service url>"
}
}
4 changes: 2 additions & 2 deletions driven/storage/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options"

"github.com/rokwire/logging-library-go/errors"
"github.com/rokwire/logging-library-go/logutils"
"github.com/rokwire/logging-library-go/v2/errors"
"github.com/rokwire/logging-library-go/v2/logutils"
"go.mongodb.org/mongo-driver/mongo"
)

Expand Down
2 changes: 1 addition & 1 deletion driven/storage/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"time"

"github.com/rokwire/logging-library-go/logs"
"github.com/rokwire/logging-library-go/v2/logs"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
Expand Down
21 changes: 14 additions & 7 deletions driver/web/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"wellness/core"
"wellness/core/model"
"wellness/driver/web/rest"
"wellness/utils"

"github.com/rokwire/core-auth-library-go/v2/authservice"
"github.com/rokwire/logging-library-go/v2/logs"

"github.com/gorilla/mux"
"github.com/rokwire/core-auth-library-go/v2/tokenauth"
Expand All @@ -41,6 +41,8 @@ type Adapter struct {
internalApisHandler rest.InternalApisHandler

app *core.Application

logger *logs.Logger
}

// @title Rokwire Wellness Building Block API
Expand Down Expand Up @@ -129,33 +131,37 @@ func (we Adapter) serveDocUI() http.Handler {

func (we Adapter) wrapFunc(handler http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
utils.LogRequest(req)

logObj := we.logger.NewRequestLog(req)
logObj.RequestReceived()
handler(w, req)
logObj.RequestComplete()
}
}

type coreAuthFunc = func(*tokenauth.Claims, http.ResponseWriter, *http.Request)

func (we Adapter) coreAuthWrapFunc(handler coreAuthFunc, authorization Authorization) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
utils.LogRequest(req)

logObj := we.logger.NewRequestLog(req)
logObj.RequestReceived()
responseStatus, claims, err := authorization.check(req)
if err != nil {
log.Printf("error authorization check - %s", err)
http.Error(w, http.StatusText(responseStatus), responseStatus)
return
}
handler(claims, w, req)
logObj.RequestComplete()
}
}

type internalAuthFunc = func(http.ResponseWriter, *http.Request)

func (we Adapter) internalAuthWrapFunc(handler internalAuthFunc) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
utils.LogRequest(req)
logObj := we.logger.NewRequestLog(req)
logObj.RequestReceived()

status, err := we.auth.internalAuth.check(req)
if err != nil {
Expand All @@ -165,18 +171,19 @@ func (we Adapter) internalAuthWrapFunc(handler internalAuthFunc) http.HandlerFun
}

handler(w, req)
logObj.RequestComplete()
}
}

// NewWebAdapter creates new WebAdapter instance
func NewWebAdapter(host string, port string, app *core.Application, config model.Config, serviceRegManager *authservice.ServiceRegManager) Adapter {
func NewWebAdapter(host string, port string, app *core.Application, config model.Config, serviceRegManager *authservice.ServiceRegManager, logger *logs.Logger) Adapter {
auth := NewAuth(app, config, serviceRegManager)

apisHandler := rest.NewApisHandler(app)
adminApisHandler := rest.NewAdminApisHandler(app)
internalApisHandler := rest.NewInternalApisHandler(app)
return Adapter{host: host, port: port, auth: auth, apisHandler: apisHandler, adminApisHandler: adminApisHandler,
internalApisHandler: internalApisHandler, app: app}
internalApisHandler: internalApisHandler, app: app, logger: logger}
}

// AppListener implements core.ApplicationListener interface
Expand Down
4 changes: 2 additions & 2 deletions driver/web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/rokwire/core-auth-library-go/authorization"
"github.com/rokwire/core-auth-library-go/v2/authservice"
"github.com/rokwire/core-auth-library-go/v2/tokenauth"
"github.com/rokwire/logging-library-go/errors"
"github.com/rokwire/logging-library-go/logutils"
"github.com/rokwire/logging-library-go/v2/errors"
"github.com/rokwire/logging-library-go/v2/logutils"
)

// Authorization is an interface for auth types
Expand Down
58 changes: 29 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@ require (
github.com/gorilla/mux v1.8.0
github.com/rokwire/core-auth-library-go v1.0.9
github.com/rokwire/core-auth-library-go/v2 v2.2.0
github.com/rokwire/logging-library-go v1.0.3
github.com/swaggo/http-swagger v1.3.3
github.com/swaggo/swag v1.8.10
go.mongodb.org/mongo-driver v1.11.2
github.com/rokwire/logging-library-go/v2 v2.2.0
github.com/swaggo/http-swagger v1.3.4
github.com/swaggo/swag v1.16.1
go.mongodb.org/mongo-driver v1.12.0
)

require (
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/casbin/casbin/v2 v2.57.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/casbin/casbin/v2 v2.71.1 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rokwire/logging-library-go/v2 v2.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/swaggo/files v1.0.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.1.12 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/tools v0.11.0 // indirect
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading