Forum Discussion
Yozzer
Nimbostratus
Oct 14, 2011Username and IP restricted login
Hi
I want to restrict access to a website login page so that it can only be accessed by certain usernames (e.g User1-Ops, User2-Ops, etc) and only if they access from a list of allowed IP addresses.
Does anyone have any examples of what im looking for?
thanks
5 Replies
- George_Watkins_Historic F5 AccountHi Youzzer,
I wrote a Tech Tip on an HTTP basic access authentication iRule a while back. You can add a second datagroup for username/IP address pretty easily. Here's the Tech Tip:
http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/1086387/HTTP-Basic-Access-Authentication-iRule-Style.aspx
-George - Yozzer
Nimbostratus
would this work?
when HTTP_REQUEST {
if {([HTTP::method] eq "POST") && ([HTTP::uri] eq "/login.aspx") && (![matchclass [IP::client_addr] equals $::trustedAddresses])} {
HTTP::collect [HTTP::header "Content-Length"]
}
}
when HTTP_REQUEST_DATA {
set sema "no"
switch -glob [URI::decode [URI::query "?[HTTP::payload]" username]] {
"*-Ops*" {
set sema "yes"
}
}
if { $sema == "yes"} {
HTTP::respond 200 content {
HTML page settings to show the following text:
You can’t login from your current location.
}
}
} - Yozzer
Nimbostratus
This works fine although i want to prevent case problems with the username. How can i use [string tolower] with the above example for the username?
Any ideas?
Thanks - John_Alam_45640Historic F5 Accountswitch -glob [string tolower [URI::decode [URI::query "?[HTTP::payload]" username]]] {
- Yozzer
Nimbostratus
Thanks John, that worked.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
