look for assistance with the url rewrite module in IIS - url-rewriting

I'm trying to set up a reverse proxy for single sign on to an application. the URL to reach my app and the defined authentication method is "http://servername.domain/app/main?authsource=sso_rp"
My current config just sends me to the application login prompt. I've tested my authentication source and confirmed its working. My question is, does my URL rewrite config look like it should? there are no conditions or variables defined. i know I'm missing something simple but this isn't documented on the vendor end so seeking your help.

Related

Request.ServerVariables() for Shibboleth in .NET 6

I am trying to use Shibboleth on a site that uses .NET 6. The Shibboleth documentation uses Request.ServerVariables() but when I add that, I get the error "HttpRequest does not contain a definition for 'ServerVariables'".
I instantiated an IServerVariablesFeature object and I can get the SERVER_NAME variable from there, but I can't find any Shibboleth variables like Shib-Application-ID. Is my IServerVariablesFeature the right place to look for the Shibboleth variables or do I need to get Request.ServerVariables() to work?
By visiting https://domain/Shibboleth.sso/Session I can see the session information, so I know that the authentication is working correctly, I'm just trying to access the user information from an application.
Thanks in advance for any help.
IServerVariablesFeature serverVariables = HttpContext.Features.Get<IServerVariablesFeature>(); works, as does HttpContext.GetServerVariable("VARIABLE_NAME");. What I was missing is that these variables are only available to pages that are protected by Shibboleth. I added the path for my page to the shibboleth2.xml file and I could see the variables.

How to set the application domain in Heroku env var

Given an application URL on Heroru like app-123.herokuapp.com, how can I set this value into an environment variable?
I need to set an email template, with the correct links to the app, so there is no HTTP request information available, but I want to have the links with the correct URL.
I'm using Ruby on Rails and using an environment variable, but once I create review apps, with dynamic URL's I cannot rely on this.
Disclaimer: This works only for the review apps, as they are my concern when posting the question.
We can make use of the injected environment variables, as described in the documentation: https://devcenter.heroku.com/articles/github-integration-review-apps#injected-environment-variables
So, given that every application domain will be herokuapp.com we can guess the application address but concatenation of protocal, app and domain:
"https://#{HEROKU_APP_NAME}.herokuapp.com"

REST API URL with Directory and File name as Path Variables

I have a requirement to send the folder details in the URL for POST method, some thing like this
http:///{directory}/{filename}
I am using Spring API to create the service. Using #PathVariables to two variables in the URI.
Problem : Directory can have "/" slashes in it.
Now how can I create my API, please help me.
POST http://example.com/api/files/path/to/my/file/filename
Stick a controller on /api/files. Scrape the URL starting after /files. Use that to locate the file.
P.S. This has the potential to be a Very Bad Idea. Make sure you secure the controller to only expose those parts of your filesystem you don't mind random internet strangers to be able to operate on.

Apigee - modify target path when using targetserver

I have an API proxy that needs to be able to modify the path component of the eventual Target URL. This appears fairly straightforward in cases where there's a defined Target Endpoint URL for the entire proxy but we are using TargetServers and VirtualHosts which apparently are assigned after the TargetEndpoint PreFlow
I have a JS function in the Target Endpoint PreFlow and get unspecified JS errors when I attempt to modify context.targetRequest.path. Attempts to modify the path part of the incoming proxy during Proxy PreFlow also failed.
Dumping the values of targetRequest gives:
host=empty
path=/v2/cat1/cat2/?param=......
url=Identical to path!
The only variable that I've been able to "successfully" modify is targetRequest.url to achieve my aim but to do that I must assign the whole thing, including the protocol and host which aren't known to me!
Anyone know how to do this? I essentially want to modify the path replacing "/?" with just "?"
Thanks
You can also set it up at the target endpoint by leveraging the Path element along with TargetServer:
<TargetEndpoint>
...
<HTTPTargetConnection>
<LoadBalancer>
<Server name="TargetServerABC"/>
</LoadBalancer>
<Path>/v1/YourPathHere/json.ws?{flow.company.queryparams}</Path>
</HTTPTargetConnection>
</TargetEndpoint>
Note TargetServerABC needs to be a TargetServer created using the following these steps.
There seems to be an issue with manipulating target.path (there is a bug report open in Apigee for this).
The current workaround is to rewrite the entire URI either in the AssignMessage policy using the AssignVariable block:
<AssignVariable>
<Name>target.url</Name>
<Value>http://example.com/mypath?param=value&variable={apigee.variable}</Value>
<Ref/>
</AssignVariable>
or you can do it in Javascript with the context.setVariable function:
context.setVariable("target.url", mycompleteurl);

mod_rewrite and server environment variables

The setup I have is as follows:
I have one Apache server acting as a URL rewriting engine (SERVER1).
I have a second server (Apache too) which runs a web application (SERVER2). First tries to authenticate users. Part of the authentication protocol involves a lot of redirection between that application server and the authentication server.
My problem is that once the authencation is successfull, the authentication server needs to redirect the user back to the application server, which is only visible from SERVER1. Effectively, SERVER2 needs to be able to reconstruct a URL based on SERVER1's parameters.
Most of the environement variable are helpful i.e. I know the host name, script name, page called etcc but I can 't figure out wether the call was made through HTTP or HTTPS: that information is wiped in the rewrite process by SERVER1...
Anybody knows if/how I can get that information through environement variables? I am limited in that I can't use query string parameters...
Thanks all !
This may sound strange, but I have found part of the answer to my question.
The rewrite engine (at least in Apache 2, I haven't looked anywhere else) allows for writting extra request header.
The rule should look something like that.
RewriteRule .* -
[E=INFO_PATH_INFO:%{PATH_INFO},NE]
Put simple, it creates a new header called INFO_PATH_INFO and sets the value to PATH_INFO.
( For more info check out http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html )
Then it can be retrieved in any languages.
For info I am using Oracle's OWA which adds an extra layer of complication due to the fact that the default environment variables are limited to a few and additional variables need to be specified in thr dads.conf
Hope this will help anyone !

Resources