deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [10/11] git commit: CIMI: Client LazyAuth should provide driver and provider informations
Date Mon, 27 Feb 2012 16:44:47 GMT
CIMI: Client LazyAuth should provide driver and provider informations

This patch will make LazyAuth able to store and report driver
and provider in addition to user and password.
Also LazyAuth will try to read username and password from session
then fallback to Basic HTTP Auth.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/728f1cd2
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/728f1cd2
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/728f1cd2

Branch: refs/heads/master
Commit: 728f1cd2cc11f333fe1899281970f73a1c946692
Parents: 7aa3b4a
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Feb 23 14:49:37 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Fri Feb 24 16:40:02 2012 +0100

----------------------------------------------------------------------
 clients/cimi/lib/lazy_auth.rb |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/728f1cd2/clients/cimi/lib/lazy_auth.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/lazy_auth.rb b/clients/cimi/lib/lazy_auth.rb
index 528f95c..1d4bf14 100644
--- a/clients/cimi/lib/lazy_auth.rb
+++ b/clients/cimi/lib/lazy_auth.rb
@@ -36,10 +36,20 @@ module Sinatra
         @password
       end
 
+      def provider
+        credentials!
+        @provider
+      end
+
       def provided?
         @provided
       end
 
+      def driver
+        credentials!
+        @driver
+      end
+
       def credentials!
         if ENV["API_USER"] && ENV["API_PASSWORD"]
           @user = ENV["API_USER"]
@@ -51,8 +61,10 @@ module Sinatra
           unless auth.provided? && auth.basic? && auth.credentials
             @app.authorize!
           end
-          @user = auth.credentials[0]
-          @password = auth.credentials[1]
+          @user = @app.session[:username] || auth.credentials[0]
+          @password = @app.session[:password] || auth.credentials[1]
+          @provider = @app.session[:provider]
+          @driver = @app.session[:driver]
           @provided = true
         end
       end


Mime
View raw message