Home
Jul 31
Saturday
Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

admin

S-Rscript: Detecting an admin user
Tuesday, 16 March 2010 15:20
The following script demonatrates how to check for an admin user in S-Rscript.

First of all we need to register the admin user:
file: james.reg

[user/james]
"name"="james"
"group"="admin"
"from"="192.168.1."


Then we execute the script to test the user privilege level:
rsf file: r job: p225







file: hub.rb (extract)

def admin?
raw_caller_ip = request.env['HTTP_X_FORWARDED_FOR']
caller_ip = raw_caller_ip.split(',')[0]
addresses = run_projectx('registry', 'get-keys', :path => 'user/*[group="admin"]/from/text()')
r = addresses.detect do |address|
caller_ip[/#{Regexp.escape(address.to_s)}/]
end
r ? true : false
end



Tested observed
------ --------
http://rscript.rorbuilder.info/do/r/p225 admin
http://mowser.com/web/http%3A%2F%2Frscript.rorbuilder.info%2Fdo%2Fr%2Fp225 guest

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/2g2pA2uqNqM/10551

 


Taxonomy by Zaragoza Online
Home