Class: OmniAuth::Strategies::RemoteUser
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::RemoteUser
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/remote_user.rb
Instance Method Summary collapse
- #__current_user(env) ⇒ Object
- #__login(env, uid) ⇒ Object
- #__logout(env) ⇒ Object
- #_auth_path(request) ⇒ Object
- #_callback_path(request) ⇒ Object
- #call(env) ⇒ Object
- #redirect_if_not_logging_in(request, url) ⇒ Object
- #request_phase ⇒ Object
Instance Method Details
#__current_user(env) ⇒ Object
32 33 34 35 |
# File 'lib/omniauth/strategies/remote_user.rb', line 32 def __current_user(env) request = Rack::Request.new(env) request..has_key?(.) && request.[.] end |
#__login(env, uid) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/omniauth/strategies/remote_user.rb', line 47 def __login(env, uid) request = Rack::Request.new(env) response = redirect_if_not_logging_in(request,_auth_path(request) ) if response response.(., {value: uid, path: "#{request.script_name}", httponly: true}) response.finish end end |
#__logout(env) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/omniauth/strategies/remote_user.rb', line 37 def __logout(env) request = Rack::Request.new(env) request.session.clear response = redirect_if_not_logging_in(request, request.path ) if response response.(. , path: "#{request.script_name}" ) response.finish end end |
#_auth_path(request) ⇒ Object
93 94 95 |
# File 'lib/omniauth/strategies/remote_user.rb', line 93 def _auth_path(request) "#{request.script_name}#{path_prefix}/RemoteUser" end |
#_callback_path(request) ⇒ Object
89 90 91 |
# File 'lib/omniauth/strategies/remote_user.rb', line 89 def _callback_path(request) "#{_auth_path(request)}/callback" end |
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/omniauth/strategies/remote_user.rb', line 8 def call(env) remote_user = env['HTTP_REMOTE_USER'] session_user = __current_user(env) if remote_user if session_user if remote_user == session_user super(env) else __logout(env) end else __login(env, remote_user) end else if session_user __logout(env) else super(env) end end end |
#redirect_if_not_logging_in(request, url) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/omniauth/strategies/remote_user.rb', line 56 def redirect_if_not_logging_in(request, url) if ! [ _auth_path(request), _callback_path(request) ].include?(request.path_info) response = Rack::Response.new response.redirect url response end end |
#request_phase ⇒ Object
85 86 87 |
# File 'lib/omniauth/strategies/remote_user.rb', line 85 def request_phase redirect _callback_path(request) end |