Module: ElsBootstrap
- Defined in:
- lib/els_bootstrap.rb,
lib/els_bootstrap/engine.rb,
lib/els_bootstrap/version.rb
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- VERSION =
"0.0.3.5"
Instance Method Summary collapse
-
#cdid ⇒ Object
will set a @cdid instance variable determined by the REMOTE_USER or RPA_USERNAME headers.
-
#els_identity ⇒ Object
the els_identity is backed by the ELS SSO system.
Instance Method Details
#cdid ⇒ Object
will set a @cdid instance variable determined by the REMOTE_USER or RPA_USERNAME headers. cdid doesn’t change often so it’s gets stashed in the session
9 10 11 12 13 14 |
# File 'lib/els_bootstrap.rb', line 9 def cdid @cdid ||= session[:cdid] ||= request.headers["REMOTE_USER"] ||= request.headers["RPA_USERNAME"] end |
#els_identity ⇒ Object
the els_identity is backed by the ELS SSO system. It will try to get a full identity object and then store that in a memcache as raw retrieval currently hits performance. Whilst SSO is brilliant, it can be a bit of a drag working around it during development.
This method will allow an end user to circumvent the domain specific ELS login by authenticating directly with the ELS system or, if a cookie is already resent, use that to retrieve an identity. As an additional development bonus, it’s possible to fake the identity - setting it to whatever username is desired.
It’s up to the implementer to test the validity of that username in their own application. Likewise once you have an ElsIdentity object you may want to call your own usermodel based on some value. ‘cdid’ and ‘employee_number’ are common ones.
One of the best things about the ElsIdentity is that it contains Group information :) So, rather than implementing yet-another-role system in your app, let the identity be managed centrally. Once you have the ElsIdentity you can ask it whether it belongs to some role:
@els_identity.has_role? "some group"
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/els_bootstrap.rb', line 41 def els_identity # Avoid caching failures when running in dev ElsSessionController ElsToken ElsToken::ElsIdentity if session[:els_token] @els_identity = Rails.cache.fetch(session[:els_token], :namespace => "els_identity") end unless @els_identity Rails.logger.debug("no identity in cache. Redirecting") session[:redirect_to] = "#{request.env["PATH_INFO"]}" unless request.env["QUERY_STRING"].empty? session[:redirect_to] += "?#{request.env["QUERY_STRING"]}" end logger.debug("user will be returned to #{session[:redirect_to]}") redirect_to els_session_new_path end end |