Module: Rmobio::Auth
- Defined in:
- lib/rmobio/auth.rb
Instance Method Summary collapse
-
#authorize ⇒ Object
authorize filter == This filter will get the domain name from the request uri and application name from the environment setting.
- #get_msisdn ⇒ Object
-
#get_user_attributes(user_access_att_url) ⇒ Object
get_user_attributes === To get Access Attribuest === Sample device url: marge.mobiolabs.com/gateway/public/authorizationServices/getAccessAttributes?auth_identity=910000000000&domain=airtel === Sample returned client info: <?xml version=“1.0” encoding=“UTF-8”?> <DomainAccessAttributes xmlns=“mobio.net/ws/platform/schema/UserAccessAttributeService”> <authorizationId>910000000000</authorizationId> <domain>airtel</domain> <attribute>ROLE_USER</attribute> <attribute>Second Attribute</attribute> </DomainAccessAttributes>.
Instance Method Details
#authorize ⇒ Object
authorize filter
This filter will get the domain name from the request uri and application name from the environment setting.
Then construct the application domain pair, like: "cricket-wap-airtel".
The filter then check the session attribute of "shared_session_auth", and compare with the application domain pair.
If the session attribute doesn't match the application domain pair, it will call the getUserAccessAttribute from
gateway. and store into the session. If the new accessAttribute match the app-domain pair, filter the chain.
If no, redirect to auth application.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/rmobio/auth.rb', line 87 def logger.debug('authorize filter:') if params[:burl] burl =params[:burl].gsub(/&/,'&') else burl= '' end #get domain from url #req_url=request.request_uri #token_list = [] #tokenize(req_url) do |token| # token_list << token #end context = request.env['HTTP_MOBIO_CONTEXT'] if context surl='/' + context + request.request_uri else surl = request.request_uri end logger.debug(" surl 0-=== #{surl}") # Retrieve the domain from the request_uri domain = Rmobio::Utils.get_domain(request.request_uri) no_auth_domains =MOBIO_CONFIG['no_auth_domains'] if (no_auth_domains != nil) no_auth_domains.each do |d| if(domain == d) logger.debug("No auth for domain: #{d}") return end end end logger.debug("Here is the interpreted new domain: #{domain}") #get label from env #label=$env['APP_LABEL'] label= MOBIO_CONFIG['app_label'] logger.debug("here is the label #{label}") label_domain=label +'-wap-'+domain if (session[:shared_session_auth]) attributes=session[:shared_session_auth] attributes.each do |attr| logger.debug("attribute #{attr}") if(attr==label_domain) logger.debug('find good') #for debug #session[:shared_session_auth]=nil return end end end logger.debug('get result') user_access_att_url= MOBIO_CONFIG['http_access_attribute_service_url'] + get_msisdn() + '&domain=' + domain result=get_user_attributes(user_access_att_url) logger.debug("result = #{result[0]}") session[:shared_session_auth]=result result.each do |attr| logger.debug("attribute #{attr}") if(attr==label_domain) logger.debug('find good finally') return end end auth_app_url=MOBIO_CONFIG['authorization_app_url'] + '?label=' + label + '&domain=' + domain + '&burl=' + burl + '&surl=' + CGI.escape(surl) redirect_to("#{auth_app_url}") end |
#get_msisdn ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rmobio/auth.rb', line 27 def get_msisdn() logHeaders() msisdn=request.env["HTTP_X_MSISDN"] msisdn=request.env["HTTP_X_NOKIA_MSISDN"] if msisdn ==nil msisdn=request.env["HTTP_MSISDN"] if msisdn ==nil if msisdn != nil logger.debug "msisdn = #{msisdn}" if msisdn.length == 11 msisdn=msisdn[1..-1] end if msisdn.length == 10 msisdn='91' + msisdn end end if(msisdn!=nil) if(msisdn.length == 12) return msisdn end end return '' end |
#get_user_attributes(user_access_att_url) ⇒ Object
get_user_attributes
To get Access Attribuest
Sample device url:
Sample returned client info:
<?xml version=“1.0” encoding=“UTF-8”?>
<DomainAccessAttributes xmlns="http://mobio.net/ws/platform/schema/UserAccessAttributeService">
<authorizationId>910000000000</authorizationId>
<domain>airtel</domain>
<attribute>ROLE_USER</attribute>
<attribute>Second Attribute</attribute>
</DomainAccessAttributes>
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rmobio/auth.rb', line 65 def get_user_attributes(user_access_att_url) temp=Array.new logger.debug("url= #{user_access_att_url}") if user_access_att_url doc = Hpricot(open(user_access_att_url)) doc.search("//attribute").each do |attributeElement| logger.debug "att = #{attributeElement.innerHTML} " temp<<attributeElement.innerHTML end end temp end |