posgra 0.1.0 → 0.1.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 +4 -4
- data/README.md +34 -1
- data/lib/posgra.rb +1 -0
- data/lib/posgra/driver.rb +3 -2
- data/lib/posgra/dsl/grants/role/schema.rb +10 -1
- data/lib/posgra/version.rb +1 -1
- data/posgra.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9ee6f48faa2e876c6077d8fa8470ea2c923cb15
|
4
|
+
data.tar.gz: d178b484899df16095545fbacabd944807c4472b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47e4b6b06a85789e5144b42bd977c28f7cca36876c6b56c384ed46e317705b70557dac3461d0393cd0a5cd01e0142f7274858b3f93965420257b19164a7983a8
|
7
|
+
data.tar.gz: 91f3f70b90c9c449d3be4b2eeff6a98c51a70a73d44027ab0588d6d75459b0d6beb5f722d9484695ab5205f4cce50ef5bab9580df8bb3afabd920fb7f402f89d
|
data/README.md
CHANGED
@@ -87,7 +87,7 @@ role "bob" do
|
|
87
87
|
grant "TRUNCATE"
|
88
88
|
grant "UPDATE"
|
89
89
|
end
|
90
|
-
on "microposts_id_seq" do
|
90
|
+
on "microposts_id_seq", expired: '2014/10/07' do
|
91
91
|
grant "SELECT"
|
92
92
|
grant "UPDATE"
|
93
93
|
end
|
@@ -97,3 +97,36 @@ role "bob" do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
```
|
100
|
+
|
101
|
+
### Template
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
template "all grants" do
|
105
|
+
on context.object do
|
106
|
+
grant "DELETE", grantable: true
|
107
|
+
grant "INSERT"
|
108
|
+
grant "REFERENCES"
|
109
|
+
grant "SELECT"
|
110
|
+
grant "TRIGGER"
|
111
|
+
grant "TRUNCATE"
|
112
|
+
grant "UPDATE"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
template "grant select" do
|
117
|
+
grant "SELECT"
|
118
|
+
end
|
119
|
+
|
120
|
+
role "bob" do
|
121
|
+
schema "main" do
|
122
|
+
include_template "all grants", object: "microposts"
|
123
|
+
on "microposts_id_seq", expired: '2014/10/07' do
|
124
|
+
grant "SELECT"
|
125
|
+
grant "UPDATE"
|
126
|
+
end
|
127
|
+
on /^user/ do
|
128
|
+
include_template "grant select"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
```
|
data/lib/posgra.rb
CHANGED
data/lib/posgra/driver.rb
CHANGED
@@ -12,6 +12,7 @@ class Posgra::Driver
|
|
12
12
|
'D' => 'TRUNCATE',
|
13
13
|
'x' => 'REFERENCES',
|
14
14
|
't' => 'TRIGGER',
|
15
|
+
'U' => 'USAGE',
|
15
16
|
}
|
16
17
|
|
17
18
|
def initialize(client, options = {})
|
@@ -335,12 +336,12 @@ class Posgra::Driver
|
|
335
336
|
|
336
337
|
def expand_privileges(privileges)
|
337
338
|
options_by_privilege = {}
|
338
|
-
|
339
|
+
p
|
339
340
|
privileges.scan(/([a-z])(\*)?/i).each do |privilege_type_char,is_grantable|
|
340
341
|
privilege_type = PRIVILEGE_TYPES[privilege_type_char]
|
341
342
|
|
342
343
|
unless privilege_type
|
343
|
-
log(:warn, "
|
344
|
+
log(:warn, "Unknown privilege type: #{privilege_type_char}", :color => :yellow)
|
344
345
|
next
|
345
346
|
end
|
346
347
|
|
@@ -12,11 +12,20 @@ class Posgra::DSL::Grants::Role::Schema
|
|
12
12
|
instance_eval(&block)
|
13
13
|
end
|
14
14
|
|
15
|
-
def on(name, &block)
|
15
|
+
def on(name, options = {}, &block)
|
16
16
|
unless name.is_a?(Regexp)
|
17
17
|
name = name.to_s
|
18
18
|
end
|
19
19
|
|
20
|
+
if options[:expired]
|
21
|
+
expired = Time.parse(options[:expired])
|
22
|
+
|
23
|
+
if Time.new >= expired
|
24
|
+
log(:warn, "Privilege for `#{name}` has expired", :color => :yellow)
|
25
|
+
return
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
20
29
|
@result[name] = Posgra::DSL::Grants::Role::Schema::On.new(@context, name, @options, &block).result
|
21
30
|
end
|
22
31
|
end
|
data/lib/posgra/version.rb
CHANGED
data/posgra.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: posgra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: timecop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
description: Posgra is a tool to manage PostgreSQL roles/permissions.
|
140
154
|
email:
|
141
155
|
- sgwr_dts@yahoo.co.jp
|