Restricting Access by IP

108 views
Skip to first unread message

Marc Smith

unread,
Jul 5, 2016, 12:09:34 PM7/5/16
to web2py-users
Hi,

I have a web2py app that is hosted on PythonAnywhere. I'd like to
restrict access to the "admin" application and the "appadmin" page of
my app by IP address. Ideally, I'd like to return a 404 to anyone that
doesn't match one or more IP addresses.

Is this possible using the global routes.py? Or is there a better way
to do it from inside the "admin" app, and the "appadmin" controller?
Looked briefly for an example, but didn't see anything that got me
close enough.

Any tips or advice/ideas would be greatly appreciated.


--Marc

hafte agebash

unread,
Jul 5, 2016, 12:14:11 PM7/5/16
to web...@googlegroups.com
tank you!!
but i need to do with augmented traffic control simulation tool,and it needs some requirements django1.7 and python,so couldn't install django and atc tool



--Marc

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marc Smith

unread,
Jul 7, 2016, 11:23:08 AM7/7/16
to web2py-users
hafte: I think you posted to the wrong thread...

A friendly bump to the others: Is there a way to restrict access by IP
address in web2py's main/core routes.py?

Right now I'm doing it in appname/controllers/appadmin.py with this:
--snip--
if request.client not in ['x.x.x.x']:
raise HTTP(404)
--snip--

And the same for admin/models/access.py:
--snip--
if request.client not in ['x.x.x.x']:
raise HTTP(404)
--snip--

This does work and accomplish what I need, but it would be nice to do
it centrally from routes.py.


Thanks,

Marc

hafte agebash

unread,
Jul 27, 2016, 7:22:59 AM7/27/16
to web...@googlegroups.com
ok,tank you!
Reply all
Reply to author
Forward
0 new messages