summaryrefslogtreecommitdiff
path: root/lib/authorization.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2013-07-10 14:36:39 +0200
committerChristoph Helma <helma@in-silico.ch>2013-07-10 14:36:39 +0200
commitddb83b4302e8628b333402d24e3e05fc90b3faef (patch)
tree39c8645d09f6e1ecee1d97ae4faa21e399e17ad4 /lib/authorization.rb
parent3262e3cf2ed1ce896dcd11d9c1bde5222ea720ce (diff)
subjectids partially removed
Diffstat (limited to 'lib/authorization.rb')
-rw-r--r--lib/authorization.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/authorization.rb b/lib/authorization.rb
index 4b63cef..4a193ae 100644
--- a/lib/authorization.rb
+++ b/lib/authorization.rb
@@ -1,12 +1,11 @@
module OpenTox
+
if defined?($aa) and $aa[:uri]
AA = $aa[:uri]
- SUBJECTID = OpenTox::Authorization.authenticate($aa[:user],$aa[:password])
- unauthorized_error "Failed to authenticate user \"#{$aa[:user]}\"." unless OpenTox::Authorization.is_token_valid(SUBJECTID)
else
AA = "https://opensso.in-silico.ch" #if not set in .opentox/conf/[SERVICE].rb
- SUBJECTID = nil
end
+
#Module for Authorization and Authentication
#@example Authentication
# require "opentox-client"
@@ -70,11 +69,11 @@ module OpenTox
def self.authenticate(user, pw)
return nil if !AA
begin
- out = RestClientWrapper.post("#{AA}/auth/authenticate",{:username=>user, :password => pw}).sub("token.id=","").sub("\n","")
+ out = RestClientWrapper.post("#{AA}/auth/authenticate",{:username=>user, :password => pw},{:subjectid => ""}).sub("token.id=","").sub("\n","")
return out
rescue
- resource_not_found_error "#{out.inspect}"
- return nil
+ bad_request_error "Authentication failed #{out.inspect}"
+ #return nil # does not return after throwing an error
end
end