Created
October 26, 2016 09:42
-
-
Save lurumad/53c47088f5c726bf5439cc1958630422 to your computer and use it in GitHub Desktop.
Using ADFS Tokens in WebApi 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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