change default configs for auth and admin

This commit is contained in:
ykomissarov committed 2019-05-08 16:43:53 +03:00
1 parent 87f2c360c5
commit 77b18a0382
1 file changed
+102 -39
@@ -5,54 +5,117 @@ set migration.db_dbname = 'isp-test';
set migration.db_user = 'isp-test';
set migration.db_pass = '123321';
set migration.redis_host = 'isp-redis';
set migration.redis_port = '6379';
set migration.admin_token_secret = 'secret';
-- auth
INSERT INTO configs VALUES (1, 1, NULL, 't', NULL, NULL, ('{"redis": {' ||
'"ip": "' || current_setting('migration.redis_host') || '", ' ||
'"port": ' || current_setting('migration.redis_port') ||
'}, "header": {"token": {"user": "X-USER-TOKEN", "device": "X-DEVICE-TOKEN", "application": "X-APPLICATION-TOKEN"}, "identity": {"user": "X-USER-IDENTITY", "device": "X-DEVICE-IDENTITY", "domain": "X-DOMAIN-IDENTITY", "system": "X-SYSTEM-IDENTITY", "service": "X-SERVICE-IDENTITY", "application": "X-APPLICATION-IDENTITY"}}, "unauthorized.html": "<HTML><BODY><H1>401 Unauthorized BAD CREDENTIALS</H1></BODY></HTML>"}')::jsonb);
INSERT INTO configs VALUES (1, 1, NULL, 't', NULL, NULL, (format('{
"jwt": {
"secret": "%s"
},
"redis": {
"ip": "%s",
"port": %s
},
"header": {
"token": {
"user": "X-USER-TOKEN",
"admin": "X-AUTH-ADMIN",
"device": "X-DEVICE-TOKEN",
"application": "X-APPLICATION-TOKEN"
},
"identity": {
"device": "X-DEVICE-IDENTITY",
"domain": "X-DOMAIN-IDENTITY",
"system": "X-SYSTEM-IDENTITY",
"service": "X-SERVICE-IDENTITY",
"application": "X-APPLICATION-IDENTITY",
"user": "X-USER-IDENTITY"
}
},
"unauthorized.html": "<HTML><BODY><H1>401 Unauthorized BAD CREDENTIALS</H1></BODY></HTML>"
}',
current_setting('migration.admin_token_secret'),
current_setting('migration.redis_host'),
current_setting('migration.redis_port'),
))::jsonb);
-- converter
INSERT INTO configs VALUES (2, 2, NULL, 't', NULL, NULL, ('{"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9553"}}}')::jsonb);
-- router
INSERT INTO configs VALUES (3, 3, NULL, 't', NULL, NULL, ('{"database": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "admin_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9554"}}' ||
'}')::jsonb);
INSERT INTO configs VALUES (3, 3, NULL, 't', NULL, NULL, ('{
"metrics": {
"gc": true,
"memory": true,
"address": {
"port": "9554",
"ip": "0.0.0.0",
"path": "/metrics"
}
}
}')::jsonb);
-- system
INSERT INTO configs VALUES (4, 4, NULL, 't', NULL, NULL, ('{"dB": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "system_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, "redisAddress": {' ||
'"ip": "' || current_setting('migration.redis_host') || '", ' ||
'"port": "' || current_setting('migration.redis_port') || '"' ||
'}, ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9555"}}' ||
'}')::jsonb);
INSERT INTO configs VALUES (4, 4, NULL, 't', NULL, NULL, (format('{
"dB": {
"password": "%s",
"username": "%s",
"createSchema": true,
"port": "%s",
"schema": "system_service",
"address": "%s",
"database": "%s"
},
"metrics": {
"address": {
"ip": "0.0.0.0",
"path": "/metrics",
"port": "9555"
},
"gc": true,
"memory": true
},
"redisAddress": {
"ip": "%s",
"port": "%s"
}
}', current_setting('migration.db_pass'),
current_setting('migration.db_user'),
current_setting('migration.db_port'),
current_setting('migration.db_host'),
current_setting('migration.db_dbname'),
current_setting('migration.redis_host'),
current_setting('migration.redis_port')
))::jsonb);
-- admin
INSERT INTO configs VALUES (5, 5, NULL, 't', NULL, NULL, ('{"database": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "admin_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9557"}}' ||
'}')::jsonb);
INSERT INTO configs VALUES (5, 5, NULL, 't', NULL, NULL, (format('{
"metrics": {
"gc": true,
"memory": true,
"address": {
"path": "/metrics",
"port": "9557",
"ip": "0.0.0.0"
}
},
"database": {
"password": "%s",
"username": "%s",
"createSchema": true,
"port": "%s",
"schema": "admin_service",
"address": "%s",
"database": "%s"
},
"secretKey": "%s"
}',
current_setting('migration.db_pass'),
current_setting('migration.db_user'),
current_setting('migration.db_port'),
current_setting('migration.db_host'),
current_setting('migration.db_dbname'),
current_setting('migration.admin_token_secret')
))::jsonb);
SELECT setval(pg_get_serial_sequence('configs', 'id'), 6, FALSE);
-- +goose Down
DELETE FROM configs WHERE id IN (1,2,3,4,5)