Rick
Rick

Reputation: 1913

Redirect to external authentication provider without button click using OWIN

BACKGROUND: My company recently set up an Identity Provider (IdP). I am using the Kentor AuthServices library, OWIN, and ASP.NET Identity to allow users to log into a web site through this IdP. This works.

Right now a user requests a page on our site, and they are redirected to the login page where there is a button to log in through our IdP. They click it, log in, and are redirected back. This is like a standard VS2015 ASP.NET Web Application project with external (e.g., Twitter, Facebook) authentication providers - just with some custom code in /App_Start/Startup.Auth.cs for my company's IdP.

Since we only offer one login provider, and the entire site requires login (except the login page), I'd like to simply redirect users to our IdP without the intermediate login page and manual button click. Is there a method I can call or a POST/redirect I can make programmatically to mimic what happens when a user clicks the login button?

Unfortunately I am new to OWIN and ASP.NET Identity.

Upvotes: 0

Views: 1213

Answers (1)

Tratcher
Tratcher

Reputation: 6074

It should be as simple as replacing your login controller that would show your login button with a hardcoded HttpContext.GetOwinContext().Authentication.Challenge("MyIdp‌​AuthType");

Upvotes: 1

Related Questions