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: 4ff437267879f30b1fdf073964e93eaf6be5c580a8baefa2fd308b1b7d38de1f
4
- data.tar.gz: 6ffcf161a6bd74b41f3ca07ae7ce78e41e8e9fa68f1ff1c5350a1bab5193c9d0
3
+ metadata.gz: 9484c550eb1523766573047c009f2081526636c4918aeb29609fbc40885990b1
4
+ data.tar.gz: cd3266a10c9238189d327e7f92928c7c734094ae23d8dca999beb12342a13c75
5
5
  SHA512:
6
- metadata.gz: a2133b1c9680cb1cfb78b26335d449a86b04871fac6357f2a1741dc57434398c40156af1613a691485b168d0cfb62ee41f0c8299829b5594ba6eebfe218499c4
7
- data.tar.gz: 65a355dd57bdaf6deffcdffbb567247b6d28a6ac1dd7100631205e4d1337cf123c110aeeb517372ade19f13f166c85c9ee837d25c7441a692942d988cd946b8e
6
+ metadata.gz: 6858541887aae952fad81721253a4b51cf64d2a880dd8cc311d4afc1b672ae7938331fbd9e1d2bbcd77d8d860db2bb4dbf2e438271db4b8ce0843b7b5206ca55
7
+ data.tar.gz: 9bf817a23784db18f4c60df38087c3a4409c938ee49d4634270a5aaaed0b50be0182a60ad03ddcba904e6964d65580b6d5ef4fe3c52de4698fdc85ac2297f511
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/lca.svg)](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
- copy_file "config.yml.tt", "config/lca.yml"
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"
@@ -8,7 +8,8 @@ LCA_OPTIONS ||= begin
8
8
  create_postgrest_roles: true,
9
9
  jwt_secret: "supersecret",
10
10
  jwt_encryption: "HS256",
11
- destroy_partition_on_owner_destroy: true
11
+ destroy_partition_on_owner_destroy: true,
12
+ owner_role_suffix: "changeme"
12
13
  }
13
14
  end
14
15
  end.merge({
@@ -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 lca_owner_#{id}"
46
+ lca_sql "drop role if exists #{ lca_role }"
47
47
 
48
48
  # create role
49
- lca_sql "create role lca_owner_#{id}"
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 lca_owner_#{id}"
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 lca_owner_#{id}"
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 lca_owner_#{id}"
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 lca_owner_#{id}"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lca
4
- VERSION = "0.2"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lca
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick @ Earthster