Skip to content
Snippets Groups Projects
Commit fb812012 authored by Maksim Gorelik's avatar Maksim Gorelik
Browse files

credential filtering is runnable

parent f818e967
No related branches found
No related tags found
No related merge requests found
Pipeline #40060 failed with stages
PROJECT_NAME=storage-service
NATS_URL=nats://127.0.0.1:4222
CASSANDRA_HOSTS="localhost:9042"
CASSANDRA_USER= "cassandra"
CASSANDRA_PASSWORD="CHANGE ME"
PORT=8080
STORAGESERVICE_NATS_URL=nats://127.0.0.1:4222
STORAGESERVICE_CASSANDRA_HOST="cassandra:9042"
STORAGESERVICE_CASSANDRA_USER= "cassandra"
STORAGESERVICE_CASSANDRA_PASSWORD=""
STORAGESERVICE_PORT=8080
STORAGESERVICE_PROFILE="DEBUG"
COUNTRY ="DE"
REGION ="EU"
CRYPTO_NAMESPACE=transit
CRYPTO_SIGN_KEY=test
MODE = "DIRECT"
STORAGESERVICE_COUNTRY ="DE"
STORAGESERVICE_REGION ="EU"
STORAGESERVICE_CRYPTO_NAMESPACE=transit
STORAGESERVICE_CRYPTO_SIGNKEY=test
STORAGESERVICE_MODE = "DIRECT"
pluginRepoUrl = "https://gitlab.eclipse.org/eclipse/xfsc/libraries/crypto/engine/plugins/hashicorp-vault-provider.git"
UNIT_TEST_MODE_ON=false
STORAGESERVICE_UNITTESTMODEON=false
VAULT_ADRESS = "http://host.docker.internal:8200"
VAULT_TOKEN = "CHANGE ME"
\ No newline at end of file
......@@ -23,5 +23,6 @@ FROM debian
COPY --from=pluginBuild /plugin /etc/plugins
COPY --from=coreBuild /microservice /
COPY --from=coreBuild /app/.env .env
COPY --from=coreBuild /app/config.yaml config.yaml
CMD ./microservice
......@@ -48,7 +48,7 @@ services:
CQLSH_PORT: 9042
CQLVERSION: 3.4.6
volumes:
- "../../cql/initialize.cql:/cql/initialize.cql"
- "../../scripts/cql/initialize.cql:/cql/initialize.cql"
insert:
container_name: $PROJECT_NAME-insert
......@@ -63,4 +63,4 @@ services:
CQLSH_PORT: 9042
CQLVERSION: 3.4.6
volumes:
- "../../cql/insert.cql:/cql/insert.cql"
- "../../scripts/cql/insert.cql:/cql/insert.cql"
......@@ -2,14 +2,16 @@ package handlers
import (
"errors"
"gitlab.eclipse.org/eclipse/xfsc/organisational-credential-manager-w-stack/storage-service/internal/common"
"github.com/gin-gonic/gin"
)
func ErrorResponse(c *gin.Context, err string, exception error) error {
log.Error(nil, err)
env := common.GetEnvironment()
env.GetLogger().Error(nil, err)
if exception != nil {
log.Error(exception, "Detailed Error: ")
env.GetLogger().Error(exception, "Detailed Error: ")
}
c.JSON(400, gin.H{
"message": err,
......@@ -18,9 +20,10 @@ func ErrorResponse(c *gin.Context, err string, exception error) error {
}
func InternalErrorResponse(c *gin.Context, err string, exception error) error {
log.Error(nil, err)
env := common.GetEnvironment()
env.GetLogger().Error(nil, err)
if exception != nil {
log.Error(exception, "Detailed Error: ")
env.GetLogger().Error(exception, "Detailed Error: ")
}
c.JSON(500, gin.H{
......
package handlers
import (
"encoding/json"
"errors"
"gitlab.eclipse.org/eclipse/xfsc/organisational-credential-manager-w-stack/storage-service/internal/common"
......@@ -64,10 +63,8 @@ func Add(c *gin.Context, env *common.Environment, presentation bool) {
}
if contentType == common.NormalContentType {
var msg map[string]interface{}
err = json.Unmarshal(body, &msg)
if err == nil {
_, err := services.StoreMessage(ctx, id, body, authModel, env, presentation)
_, err = services.StoreMessage(ctx, id, body, authModel, env, presentation)
if err != nil {
_ = handlers.ErrorResponse(c, handlers.StoreMessageFailed, err)
return
......
......@@ -145,24 +145,9 @@ func getCredentials(ctx context.Context, authModel model.AuthModel, env *common.
}
foundCredentials := make(map[string]interface{}, 0)
for k, v := range credentials {
cipher, err := b64.RawStdEncoding.DecodeString(v)
msg, err := b64.RawStdEncoding.DecodeString(v)
if err == nil {
msg, err := crypto.DecryptMessage(authModel.Account, cipher, env.GetCryptoNamespace(), common.StorageCryptoContext, ctx, env.GetCryptoProvider())
if err != nil {
logger.Error(err, "")
continue
}
m := make(map[string]interface{})
err = json.Unmarshal(msg, &m)
if err != nil {
logger.Error(err, "")
continue
}
foundCredentials[k] = m
foundCredentials[k] = string(msg)
}
}
......
......@@ -61,7 +61,7 @@ func executeStoring(id string, ctx context.Context, msg []byte, session connecti
accountPartition=? AND
region=? AND
country=? AND
account=?;`, object, authModel.TenantId)
account=?;`, authModel.TenantId, object)
return session.Query(queryString,
id,
......
......@@ -10,3 +10,8 @@ docker-compose-run:
docker compose -f deployment/docker/docker-compose.yml --env-file=.env rm --force --stop
docker-compose -f deployment/docker/docker-compose.yml --env-file=.env --env-file=.env.credentials build --no-cache
docker compose -f deployment/docker/docker-compose.yml --env-file=.env --env-file=.env.credentials up --detach
restart:
docker compose -f deployment/docker/docker-compose.yml --env-file=.env rm --force --stop server
docker-compose -f deployment/docker/docker-compose.yml --env-file=.env --env-file=.env.credentials build --no-cache server
docker compose -f deployment/docker/docker-compose.yml --env-file=.env --env-file=.env.credentials up --detach server
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment