Skip to content

Commit

Permalink
token payload plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Kozlov committed May 7, 2023
1 parent 7e05140 commit 9b9f5c2
Show file tree
Hide file tree
Showing 21 changed files with 1,376 additions and 572 deletions.
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export NODE_OPTIONS=--openssl-legacy-provider

run_boltdb:
mkdir -p ./data
go build -o plugins/bin/ github.com/madappgang/identifo/v2/plugins/...
go build -o plugins/bin/ github.com/madappgang/identifo/v2/plugins/...
go run main.go --config=file://./cmd/config-boltdb.yaml
run_mem:
go run main.go --config=file://./cmd/config-mem.yaml
run_mongo:
go build -o plugins/bin/ github.com/madappgang/identifo/v2/plugins/...
go build -o plugins/bin/ github.com/madappgang/identifo/v2/plugins/...
go run main.go --config=file://./cmd/config-mongodb.yaml
run_dynamodb:
AWS_ACCESS_KEY_ID=DUMMYIDEXAMPLE \
Expand All @@ -35,7 +35,7 @@ test.module: ## run tests except integration ones


build:
go build -o plugins/bin/ github.com/madappgang/identifo/v2/plugins/...
go build -o plugins/bin/ github.com/madappgang/identifo/v2/plugins/...
go build -o ./identifo

lint:
Expand All @@ -53,11 +53,25 @@ build_web: build_admin_panel build_login_web_app


run_ui_tests:
go build -o plugins/bin/ github.com/madappgang/identifo/v2/plugins/...
go build -o plugins/bin/ github.com/madappgang/identifo/v2/plugins/...
go run main.go --config=file://./cmd/config-boltdb.yaml &
cd web_apps_src/web-element && npx cypress run
kill $$(ps | grep config-boltdb.yaml | awk '{print $1}')

open_ui_tests:
$$(cd web_apps_src/web-element; npm install; $$(npm bin)/cypress open )


## first install protoc compiler https://grpc.io/docs/protoc-installation/
install_go_protoc:
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]

gen_payload_plugin:
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
user_payload_provider/grps/payload_provider/payload_provider.proto

gen_user_storage_plugin:
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
storage/grpc/proto/user.proto
25 changes: 13 additions & 12 deletions config/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,51 +48,51 @@ func NewServer(config model.ConfigurationStorage, restartChan chan<- bool) (mode
}

// helper function get settings from default or override
dbSettings := func(settings, def model.DatabaseSettings) model.DatabaseSettings {
if settings.Type == model.DBTypeDefault {
return def
dbSettings := func(s model.DatabaseSettings) model.DatabaseSettings {
if s.Type == model.DBTypeDefault {
return settings.Storage.DefaultStorage
}
return settings
return s
}

// Create all storages
app, err := storage.NewAppStorage(dbSettings(settings.Storage.AppStorage, settings.Storage.DefaultStorage))
app, err := storage.NewAppStorage(dbSettings(settings.Storage.AppStorage))
if err != nil {
log.Printf("Error on Create New AppStorage %v", err)
errs = append(errs, fmt.Errorf("error creating app storage: %v", err))
}

user, err := storage.NewUserStorage(dbSettings(settings.Storage.UserStorage, settings.Storage.DefaultStorage))
user, err := storage.NewUserStorage(dbSettings(settings.Storage.UserStorage))
if err != nil {
log.Printf("Error on Create New user storage %v", err)
errs = append(errs, fmt.Errorf("error creating user storage: %v", err))
}

token, err := storage.NewTokenStorage(dbSettings(settings.Storage.TokenStorage, settings.Storage.DefaultStorage))
token, err := storage.NewTokenStorage(dbSettings(settings.Storage.TokenStorage))
if err != nil {
log.Printf("Error on Create New token storage %v", err)
errs = append(errs, fmt.Errorf("error creating token storage: %v", err))
}

tokenBlacklist, err := storage.NewTokenBlacklistStorage(dbSettings(settings.Storage.TokenBlacklist, settings.Storage.DefaultStorage))
tokenBlacklist, err := storage.NewTokenBlacklistStorage(dbSettings(settings.Storage.TokenBlacklist))
if err != nil {
log.Printf("Error on Create New blacklist storage %v", err)
errs = append(errs, fmt.Errorf("error creating blacklist storage: %v", err))
}

verification, err := storage.NewVerificationCodesStorage(dbSettings(settings.Storage.VerificationCodeStorage, settings.Storage.DefaultStorage))
verification, err := storage.NewVerificationCodesStorage(dbSettings(settings.Storage.VerificationCodeStorage))
if err != nil {
log.Printf("Error on Create New verification codes storage %v", err)
errs = append(errs, fmt.Errorf("error creating verification codes storage: %v", err))
}

invite, err := storage.NewInviteStorage(dbSettings(settings.Storage.InviteStorage, settings.Storage.DefaultStorage))
invite, err := storage.NewInviteStorage(dbSettings(settings.Storage.InviteStorage))
if err != nil {
log.Printf("Error on Create New invite storage %v", err)
errs = append(errs, fmt.Errorf("error creating invite storage: %v", err))
}

managementKeys, err := storage.NewManagementKeys(dbSettings(settings.Storage.ManagementKeysStorage, settings.Storage.DefaultStorage))
managementKeys, err := storage.NewManagementKeys(dbSettings(settings.Storage.ManagementKeysStorage))
if err != nil {
log.Printf("Error on Create New management keys storage %v", err)
errs = append(errs, fmt.Errorf("error creating management keys storage: %v", err))
Expand All @@ -112,7 +112,8 @@ func NewServer(config model.ConfigurationStorage, restartChan chan<- bool) (mode

// maybe just not serve login web app if type is none?
lwas := settings.LoginWebApp
if settings.LoginWebApp.Type == model.FileStorageTypeNone || settings.LoginWebApp.Type == model.FileStorageTypeDefault {
if settings.LoginWebApp.Type == model.FileStorageTypeNone ||
settings.LoginWebApp.Type == model.FileStorageTypeDefault {
// if not set, use default value
lwas = defaultLoginWebAppFSSettings
}
Expand Down
5 changes: 4 additions & 1 deletion model/app_storage.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package model

import "encoding/json"
import (
"encoding/json"
)

// AppStorage is an abstract representation of applications data storage.
type AppStorage interface {
Expand Down Expand Up @@ -98,6 +100,7 @@ const (

// TokenPayloadServicePluginSettings settings for token payload service
type TokenPayloadServicePluginSettings struct {
PluginSettings
Name string `json:"name,omitempty" bson:"name,omitempty"`
}

Expand Down
15 changes: 0 additions & 15 deletions storage/grpc/Readme.md

This file was deleted.

Loading

0 comments on commit 9b9f5c2

Please sign in to comment.