lca 0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9484c550eb1523766573047c009f2081526636c4918aeb29609fbc40885990b1
|
4
|
+
data.tar.gz: cd3266a10c9238189d327e7f92928c7c734094ae23d8dca999beb12342a13c75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6858541887aae952fad81721253a4b51cf64d2a880dd8cc311d4afc1b672ae7938331fbd9e1d2bbcd77d8d860db2bb4dbf2e438271db4b8ce0843b7b5206ca55
|
7
|
+
data.tar.gz: 9bf817a23784db18f4c60df38087c3a4409c938ee49d4634270a5aaaed0b50be0182a60ad03ddcba904e6964d65580b6d5ef4fe3c52de4698fdc85ac2297f511
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://badge.fury.io/rb/lca)
|
2
|
+
|
1
3
|
# LCA
|
2
4
|
|
3
5
|
Storing, processing and working with life-cycle assessment data has always been challenging. A multitude of data models and implementations exist already but every one of them makes huge compromises or lacks functionality.
|
@@ -15,7 +15,10 @@ module Lca
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def copy_config
|
18
|
-
|
18
|
+
conf_file = "config/lca.yml"
|
19
|
+
copy_file "config.yml.tt", conf_file
|
20
|
+
contents = File.read( conf_file ).gsub("changeme", ('a'..'z').to_a.shuffle.first(4).join )
|
21
|
+
File.open(conf_file, 'wb') { |file| file.write(contents) }
|
19
22
|
end
|
20
23
|
|
21
24
|
def migration_version
|
@@ -12,3 +12,7 @@ destroy_partition_on_owner_destroy: true
|
|
12
12
|
# jwt secret required for postgrest role switching
|
13
13
|
jwt_secret: "supersecret"
|
14
14
|
jwt_encryption: "HS256"
|
15
|
+
|
16
|
+
# suffix postgres roles with a random string
|
17
|
+
# to avoid collisions between other LCA installations in other apps using same db server
|
18
|
+
owner_role_suffix: "changeme"
|
@@ -18,7 +18,7 @@ module Lca
|
|
18
18
|
|
19
19
|
# instance methods
|
20
20
|
def lca_role
|
21
|
-
"lca_owner_#{id}"
|
21
|
+
"lca_owner_#{id}_#{ LCA_OPTIONS[:owner_role_suffix] }"
|
22
22
|
end # role
|
23
23
|
|
24
24
|
# Generates a JWT token the client (SPA) can pass to PostgREST for privilege escalation
|
@@ -43,13 +43,13 @@ module Lca
|
|
43
43
|
|
44
44
|
if LCA_OPTIONS[:create_postgrest_roles]
|
45
45
|
# drop role if it exists
|
46
|
-
lca_sql "drop role if exists
|
46
|
+
lca_sql "drop role if exists #{ lca_role }"
|
47
47
|
|
48
48
|
# create role
|
49
|
-
lca_sql "create role
|
49
|
+
lca_sql "create role #{ lca_role }"
|
50
50
|
|
51
51
|
# grant privs
|
52
|
-
lca_sql "grant all privileges on #{lca_table_name}_#{id} to
|
52
|
+
lca_sql "grant all privileges on #{lca_table_name}_#{id} to #{ lca_role }"
|
53
53
|
end
|
54
54
|
|
55
55
|
end # create_storage
|
@@ -60,10 +60,10 @@ module Lca
|
|
60
60
|
|
61
61
|
if LCA_OPTIONS[:create_postgrest_roles]
|
62
62
|
# revoke privs
|
63
|
-
lca_sql "REVOKE ALL PRIVILEGES ON #{lca_table_name}_#{id} FROM
|
63
|
+
lca_sql "REVOKE ALL PRIVILEGES ON #{lca_table_name}_#{id} FROM #{ lca_role }"
|
64
64
|
|
65
65
|
# delete role
|
66
|
-
lca_sql "drop role
|
66
|
+
lca_sql "drop role #{ lca_role }"
|
67
67
|
end
|
68
68
|
|
69
69
|
if LCA_OPTIONS[:destroy_partition_on_owner_destroy]
|
@@ -71,7 +71,7 @@ module Lca
|
|
71
71
|
lca_sql "drop table if exists #{lca_table_name}_#{id}"
|
72
72
|
else
|
73
73
|
# detach and forget about it
|
74
|
-
lca_sql "alter table #{lca_table_name} detach partition
|
74
|
+
lca_sql "alter table #{lca_table_name} detach partition #{ lca_role }"
|
75
75
|
end
|
76
76
|
end # delete_storage
|
77
77
|
|
data/lib/lca/version.rb
CHANGED