Forum Discussion
ukstin
Nimbostratus
Jan 29, 2009encrypt/decrypt URI
Hi,
I´m trying to do an Irule to encrypt and decrypt the URI with a cookie value as key. But it´s not working as expected, somebody as any opinion about these irule?
when HTTP_R...
ukstin
Nimbostratus
Jan 30, 2009thanks hoolio, your suggestions are pretty valuable, now the rule is almost working as expected, the only problem is that the decrypted variable is always returning empty, there is no error message or something like that, it just return empty when I decrypt, decode e b64decode.
when RULE_INIT {
set ::prefix "enc_"
set ::sessao "JSESSIONID"
}
when HTTP_REQUEST {
if { ([HTTP::uri] starts_with "/$::prefix") and ([HTTP::cookie exists $::sessao]) }{
set decrypted [AES::decrypt [HTTP::cookie value $::sessao] [b64decode [URI::decode [string range [HTTP::uri] [expr {[string length $::prefix] + 1} ] end]]]]
log local0. "uri [HTTP::uri] decrypted: $decrypted"
HTTP::uri $decrypted
set uri $decrypted
} else { set uri [HTTP::uri] }
if { [string tolower $uri] contains "abc" } {
pool pool_abc
} elseif { [string tolower $uri] contains "def" } {
pool pool_def
}
}
when HTTP_RESPONSE {
if { [HTTP::header value Content-Type] starts_with "text" } {
set encrypted "/$::prefix[URI::encode [b64encode [AES::encrypt [HTTP::cookie value $::sessao] $uri]]]"
log local0. "uri: $uri encrypted: $encrypted"
HTTP::header replace Location "$encrypted"
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
