u-authorization 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/authorization.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec8f1983839a46911cc985c1d3a27fd56ac71d53135aec13025071ccde2af5a
|
4
|
+
data.tar.gz: cf196505dea37701820b8a0a85d46b34c3091d556a622de4899f605ad8d30c22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a872b99a0300a3742e383895bbefe4bb51d7d94599280ea2a8c0670d89bcab7e5a8c9ebb8b537a4e5b5c58795103f7a82289c6cc8160273f65ada32dfd14029f
|
7
|
+
data.tar.gz: 5819bc7367619be3a9032540848592aac4c2dd283f918df538fabd061986c0b89534916159d09a7edcd38a65a01ae9cf147fb66f8792d841440560b439d9cecd
|
data/authorization.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Authorization
|
4
|
-
VERSION = '1.2.
|
4
|
+
VERSION = '1.2.1'
|
5
5
|
|
6
6
|
MapValuesAsDowncasedStrings = -> (values) do
|
7
7
|
Array(values).map { |value| String(value).downcase }
|
@@ -23,17 +23,17 @@ module Authorization
|
|
23
23
|
if !(any = role_permission['any']).nil?
|
24
24
|
any
|
25
25
|
elsif only = role_permission['only']
|
26
|
-
check_feature_permission(only
|
26
|
+
check_feature_permission(only, context)
|
27
27
|
elsif except = role_permission['except']
|
28
|
-
check_feature_permission(except
|
28
|
+
!check_feature_permission(except, context)
|
29
29
|
else
|
30
30
|
raise NotImplementedError
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def check_feature_permission(context_values)
|
34
|
+
def check_feature_permission(context_values, context)
|
35
35
|
MapValuesAsDowncasedStrings.(context_values).any? do |context_value|
|
36
|
-
|
36
|
+
Array(context_value.split('.')).all? { |permission| context.include?(permission) }
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: u-authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Serradura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Simple authorization library and role managment for Ruby.
|
14
14
|
email: rodrigo.serradura@gmail.com
|