Skip to content

Instantly share code, notes, and snippets.

@lurumad
Created October 26, 2016 09:42
Show Gist options
  • Save lurumad/53c47088f5c726bf5439cc1958630422 to your computer and use it in GitHub Desktop.
Save lurumad/53c47088f5c726bf5439cc1958630422 to your computer and use it in GitHub Desktop.
Using ADFS Tokens in WebApi 2
public class Startup
{
private static readonly string Realm = ConfigurationManager.AppSettings["ida:Wtrealm"];
private static readonly string AdfsMetadata = ConfigurationManager.AppSettings["ida:ADFSMetadata"];
public void Configuration(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wtrealm = Realm,
MetadataAddress = AdfsMetadata
});
var oAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new OauthSecurityProvider(),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
};
app.UseOAuthBearerTokens(oAuthOptions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment