summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrautenberg <rautenberg@in-silico.ch>2012-03-28 12:54:05 +0200
committerrautenberg <rautenberg@in-silico.ch>2012-03-28 12:54:05 +0200
commita8fa38376624cdc5212e63e74b308ba1af32ae53 (patch)
treeaf79481eb4f6dfdf1d816307ebc1babdab1d63a1 /lib
parent0071cbd5f91cd3456a6e46b27155e8e408b384c1 (diff)
aa to new config
Diffstat (limited to 'lib')
-rw-r--r--lib/authorization.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/authorization.rb b/lib/authorization.rb
index 470ecd8..33fa0a4 100644
--- a/lib/authorization.rb
+++ b/lib/authorization.rb
@@ -1,6 +1,6 @@
module OpenTox
-
- AA ||= "https://opensso.in-silico.ch" #if not set in .opentox/conf/[environment].yaml
+ AA = $aa[:uri] if defined? $aa
+ AA ||= "https://opensso.in-silico.ch" #if not set in .opentox/conf/[application]/[test].rb
#Module for Authorization and Authentication
#@example Authentication
# require "opentox-client"
@@ -310,13 +310,13 @@ module OpenTox
# @param [String] subjectid
# @return [Boolean] true if access granted, else otherwise
def self.authorized?(uri, request_method, subjectid)
- if CONFIG[:authorization][:free_request].include?(request_method)
+ if $aa[:free_request].include?(request_method)
#$logger.debug "authorized? >>true<< (request is free), method: #{request_method}, URI: #{uri}, subjectid: #{subjectid}"
true
elsif OpenTox::Authorization.free_uri?(uri, request_method)
#$logger.debug "authorized? >>true<< (uris is free_uri), method: #{request_method}, URI: #{uri}, subjectid: #{subjectid}"
true
- elsif CONFIG[:authorization][:authenticate_request].include?(request_method)
+ elsif $aa[:authenticate_request].include?(request_method)
ret = OpenTox::Authorization.is_token_valid(subjectid)
$logger.debug "authorized? >>#{ret}<< (token is in/valid), method: #{request_method}, URI: #{uri}, subjectid: #{subjectid}" unless ret
ret
@@ -324,7 +324,7 @@ module OpenTox
ret = OpenTox::Authorization.is_token_valid(subjectid)
$logger.debug "authorized? >>#{ret}<< (uris is authorize exception, token is in/valid), method: #{request_method}, URI: #{uri}, subjectid: #{subjectid}" unless ret
ret
- elsif CONFIG[:authorization][:authorize_request].include?(request_method)
+ elsif $aa[:authorize_request].include?(request_method)
ret = OpenTox::Authorization.authorize(uri, request_method, subjectid)
$logger.debug "authorized? >>#{ret}<< (uri (not) authorized), method: #{request_method}, URI: #{uri}, subjectid: #{subjectid}" unless ret
ret
@@ -336,9 +336,9 @@ module OpenTox
private
def self.free_uri?(uri, request_method)
- if CONFIG[:authorization][:free_uris]
- CONFIG[:authorization][:free_uris].each do |request_methods,uris|
- if request_methods and uris and request_methods.include?(request_method.to_sym)
+ if $aa[:free_uris]
+ $aa[:free_uris].each do |request_methods,uris|
+ if request_methods and uris and request_methods.include?(request_method.to_s)
uris.each do |u|
return true if u.match uri
end
@@ -349,8 +349,8 @@ module OpenTox
end
def self.authorize_exception?(uri, request_method)
- if CONFIG[:authorization][:authorize_exceptions]
- CONFIG[:authorization][:authorize_exceptions].each do |request_methods,uris|
+ if $aa[:authorize_exceptions]
+ $aa[:authorize_exceptions].each do |request_methods,uris|
if request_methods and uris and request_methods.include?(request_method.to_sym)
uris.each do |u|
return true if u.match uri