Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'net/http'
- require 'uri'
- require 'rest_client'
- require 'authentication/make_session'
- class HomeController < ApplicationController
- before_filter :init_variables
- def init_variables
- initialize_variables
- end
- def index
- @accept = 'text/plain'
- @content_type = 'text/plain'
- @authorization = session[:auth]
- #get_response_with_auth("http://55.7.28.210:4321/TSI-Dev/")
- RestClient.log = '/home/aroux/workspace/UPM/UPM-workspace/user-profil-manager/mylog.error'
- @responses = RestClient.get "http://55.7.28.210:4321/TSI-Dev/", :accept => @accept, :authorization => @authorization
- end
- def get_response_with_auth(url)
- url_parsed = URI.parse(url)
- @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http|
- @req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept})
- }
- end
- end
- From Gem authentication :
- def initialize_variables
- if request.env["HTTP_AUTHORIZATION"].nil?
- if APP_CONFIG['routes_login_path'].nil?
- redirect_to login_path
- else
- redirect_to APP_CONFIG['routes_login_path']
- end
- else
- if !request.env['REMOTE_USER'].nil?
- session[:user]=request.env['REMOTE_USER']
- session[:auth]=request.env["HTTP_AUTHORIZATION"]
- end
- end
- end
- In the application controller i use :
- def is_logged?
- if request.env["HTTP_AUTHORIZATION"].nil? && session[:auth].nil?
- if APP_CONFIG['routes_login_path'].nil?
- redirect_to login_path
- else
- redirect_to APP_CONFIG['routes_login_path']
- end
- end
- end
- To verify if i'm logged (in all of my applications)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement