mumukit-auth 3.5.1 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75c9b0fd1c258c727eb548b526c37282bd3b02e3
4
- data.tar.gz: 6830844a86fac1e59678f84b814ace97f7bfb0f9
3
+ metadata.gz: b90f8c34b943bbdf1d0437289ba6d104498defcd
4
+ data.tar.gz: fc136b27740aaf81f7a8bd650464e97f17b62a70
5
5
  SHA512:
6
- metadata.gz: d73b1ca5ff76c981f7e981a40475fe49be8a21a9bc11775a752d5c5d3e494301003bd3f8605ded35bd7db3475bbc7e10532d3c89b6466fb13135452f39d337ca
7
- data.tar.gz: 4904a2cb5e5cf1050582010c62332299946a0adc2c9eec1721344eb52719e06156704231dc450f84a5eef39ad67f3979bd650ec9e706fd8963c3d19fe6d11d67
6
+ metadata.gz: 4a034e8d1af30290a1c6626d81c8bc32316ced3126f850c0ed9f8b364d895bfd207d4c869933f99818957a4b7a274ade3a946448e350144da6d52613e5f8280d
7
+ data.tar.gz: 8f08e07b29237cf34e54e324961d1f5b31c192e0a23f49cfe45b1de90f9cf9146e33afbd244d5808e221cf51103e0d9d8cb4d72293fbea8063f29e216c944096
@@ -0,0 +1,29 @@
1
+ module Mumukit::Auth
2
+ module PermissionsPersistence
3
+ class Daybreak
4
+ def self.from_config
5
+ new Mumukit::Auth.config.daybreak_name
6
+ end
7
+
8
+ def initialize(db_name)
9
+ @db = ::Daybreak::DB.new "#{db_name}.db", default: '{}'
10
+ end
11
+
12
+ def close
13
+ @db.close
14
+ end
15
+
16
+ def set!(key, value)
17
+ @db.update! key.to_sym => value.to_json
18
+ end
19
+
20
+ def get(key)
21
+ Mumukit::Auth::Permissions.load @db[key]
22
+ end
23
+
24
+ def clean_env!
25
+ FileUtils.rm ["#{Mumukit::Auth.config.daybreak_name}.db"], force: true
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,32 +1,33 @@
1
1
  module Mumukit::Auth
2
2
  class Store
3
- def initialize(db_name)
4
- @db = Daybreak::DB.new "#{db_name}.db", default: '{}'
5
- end
6
-
7
- def close
8
- @db.close
3
+ def initialize
4
+ @db = Mumukit::Auth.config.persistence_strategy
9
5
  end
10
6
 
11
7
  def set!(key, value)
12
- @db.update! key.to_sym => value.to_json
8
+ @db.set! key.to_sym, value
13
9
  end
14
10
 
15
11
  def get(key)
16
- Mumukit::Auth::Permissions.load @db[key]
12
+ @db.get key
13
+ end
14
+
15
+ def clean_env!
16
+ @db.clean_env!
17
17
  end
18
18
 
19
19
  class << self
20
- def from_env
21
- new Mumukit::Auth.config.daybreak_name
20
+
21
+ def from_config
22
+ Mumukit::Auth.config.persistence_strategy.class.from_config
22
23
  end
23
24
 
24
25
  def clean_env!
25
- FileUtils.rm ["#{Mumukit::Auth.config.daybreak_name}.db"], force: true
26
+ from_config.clean_env!
26
27
  end
27
28
 
28
29
  def with(&block)
29
- store = from_env
30
+ store = from_config
30
31
  block.call store
31
32
  ensure
32
33
  store.close
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Auth
3
- VERSION = '3.5.1'
3
+ VERSION = '3.6.0'
4
4
  end
5
5
  end
data/lib/mumukit/auth.rb CHANGED
@@ -13,6 +13,7 @@ require_relative './auth/token'
13
13
  require_relative './auth/scope'
14
14
  require_relative './auth/permissions'
15
15
  require_relative './auth/store'
16
+ require_relative './auth/permissions_persistence/daybreak'
16
17
 
17
18
  require 'ostruct'
18
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-27 00:00:00.000000000 Z
11
+ date: 2017-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,7 @@ files:
106
106
  - lib/mumukit/auth/exceptions.rb
107
107
  - lib/mumukit/auth/grant.rb
108
108
  - lib/mumukit/auth/permissions.rb
109
+ - lib/mumukit/auth/permissions_persistence/daybreak.rb
109
110
  - lib/mumukit/auth/role.rb
110
111
  - lib/mumukit/auth/roles.rb
111
112
  - lib/mumukit/auth/scope.rb