deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 5/7] CIMI: Client LazyAuth should provide driver and provider informations
Date Thu, 23 Feb 2012 13:56:01 GMT
From: Michal Fojtik <mfojtik@redhat.com>

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.

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 clients/cimi/lib/lazy_auth.rb |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

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
-- 
1.7.9.1


Mime
View raw message