Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sandermvanvliet/net-owin-utils
Sample to show middleware to handle X-Forwarded-Proto scenarios
https://github.com/sandermvanvliet/net-owin-utils
Last synced: about 10 hours ago
JSON representation
Sample to show middleware to handle X-Forwarded-Proto scenarios
- Host: GitHub
- URL: https://github.com/sandermvanvliet/net-owin-utils
- Owner: sandermvanvliet
- Created: 2016-10-13T16:27:52.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-13T16:47:13.000Z (about 8 years ago)
- Last Synced: 2024-12-17T12:16:59.572Z (6 days ago)
- Language: C#
- Size: 510 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cookie authentication behind a load balancer
This repo contains an approach to handle cookie auth where the application is behind a load balancer and only listens on HTTP:[ Client ] --- HTTPS --> [ Load Balancer ] --- HTTP ---> [ Web app ]
In this scenario when authentication takes place in the web app the client is redirected to the login page. Unfortunately because the web app doesn't know that it is exposed over HTTPS the client gets redirected to the wrong URL.
Fortunately HAProxy (the load balancer) uses the X-Forwarded-Proto header to indicate the externally used URI scheme (HTTP or HTTPS). We can use this to tell ASP.Net how to build the redirect URL.
In the project `src/net-owin-utils` project there are two classes that implement a middleware component to set the `Scheme` property of the `HttpRequest` so that the cookie authentication handler can correctly build the URL.
The project `src/net-owin-utils-sample` contains a demonstration of usage. See the `Startup.cs` file.
Tests for `net-owin-utils` can be found in `test/net-owin-utils.Tests`