PSS 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 6238237630ffa5080ae0f7d650a8f8dedd6c61e6
4
- data.tar.gz: 4bbee88b6c9994aa99ef9235a6b404ce21733c0b
3
+ metadata.gz: d1fb1c41393dffec4adb7f3f8abb338e94696076
4
+ data.tar.gz: e36509d769f733b12bbf78f29b7ae8aeebbc43b6
5
5
  SHA512:
6
- metadata.gz: a697be4315ca6b330b7e1e877f3428dbc37c08d140d3faa08aaa97947028e3119b6d4fba47bff2061c93fe62a23ece0005740b6cc7a53807db5aa0a487705578
7
- data.tar.gz: de0e31eeb72ed250318ad7d9c51631a27ae6639dcec600d3e412ab182e4eae99ee845d7446875a1ce308f4adff2c542a450c5357930a20f757a03305c24da8c0
6
+ metadata.gz: 5e8cc70152dbfd1e2d20451368a4723cf8567e7256cc1b846d23f95d7377f603915edce4b24e223359cadc2448ba8dcf2b9a47694af76bfb1d3e9fcd095f92a8
7
+ data.tar.gz: 44db9855986f4db4ab78eda38098d41db88c56676602912b8b888f5ff6fb240ec70b5a37197abee7bd587e3a0ac7081f05c17c7be9218f900141cb66d158fc6f
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Michel Perez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ module Security
2
+ module API
3
+
4
+ #Por ejemplo
5
+ #[
6
+ # {:client_id => 'web_client', :token_password => ''}
7
+ #]
8
+ def validate_client
9
+ if(@env["HTTP_CLIENT_AUTH"])
10
+ client_id, token_password = @env["HTTP_CLIENT_AUTH"].split(':')
11
+ @clients.each do |iter|
12
+ @client = iter if(iter[:client_id] == client_id && iter[:token_password] == token_password)
13
+ end
14
+ unless(@client)
15
+ halt 503
16
+ end
17
+ else
18
+ halt 503
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,40 @@
1
+ module Security
2
+ module AuthRules
3
+
4
+ #Por ejemplo
5
+ #{
6
+ # :escort => {"GET" => ["/escorts/[0-9]+"]}
7
+ # }
8
+ def validate_user
9
+ if(@env["HTTP_USER_AUTH"])
10
+ user_session, user_token = @env["HTTP_USER_AUTH"].split(':')
11
+ yield(user_session, user_token)
12
+ end
13
+ end
14
+
15
+ def validate_rule(roles = [])
16
+ roles.each do |role|
17
+ if(validate_rule_role(role))
18
+ return true
19
+ end
20
+ end
21
+ halt 401
22
+ end
23
+
24
+ def validate_rule_role(role)
25
+ controller = request.route_obj.controller.to_sym || :default
26
+ #puts "controller => #{controller} RULES => #{@rules[role][@env['REQUEST_METHOD']][controller]}"
27
+ if(@rules.has_key?(role) && @rules[role].has_key?(controller) &&
28
+ @rules[role][controller].has_key?(@env['REQUEST_METHOD']))
29
+ rules_exp = @rules[role][controller][@env['REQUEST_METHOD']]
30
+ rules_exp.each do |exp|
31
+ if((@env['PATH_INFO'] =~ /#{exp}/))
32
+ return true
33
+ end
34
+ end
35
+ end
36
+ false
37
+ end
38
+
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: PSS
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Perez
@@ -15,7 +15,10 @@ email: michel.ingesoft@gmail.com
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
- files: []
18
+ files:
19
+ - LICENSE
20
+ - lib/security/api.rb
21
+ - lib/security/auth_rules.rb
19
22
  homepage: https://github.com/mrkaspa/padrino-simple-security-api/
20
23
  licenses:
21
24
  - MIT