本文整理汇总了C#中IAppBuilder.UseKentorAuthServicesAuthentication方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseKentorAuthServicesAuthentication方法的具体用法?C# IAppBuilder.UseKentorAuthServicesAuthentication怎么用?C# IAppBuilder.UseKentorAuthServicesAuthentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppBuilder
的用法示例。
在下文中一共展示了IAppBuilder.UseKentorAuthServicesAuthentication方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureAuth
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context, user manager and signin manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
// Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseKentorAuthServicesAuthentication(CreateAuthServicesOptions());
}
示例2: ConfigureAuth
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
var authServicesOptions = new KentorAuthServicesAuthenticationOptions(false)
{
SPOptions = CreateSPOptions()
//SPOptions = new SPOptions
//{
// EntityId = new EntityId(localMetaUri),
// ReturnUrl = returnUrl,
// WantAssertionsSigned = true
//},
//AuthenticationType = adfsType,
//Caption = adfsType,
};
Uri metadataURI = new Uri(metaUri);
var idp = new IdentityProvider(new EntityId(entityId), authServicesOptions.SPOptions)
{
AllowUnsolicitedAuthnResponse = true,
Binding = Saml2BindingType.HttpRedirect,
MetadataLocation = metadataURI.ToString(),
LoadMetadata = true
};
//idp.SigningKeys.AddConfiguredKey(
// new X509Certificate2(
// HostingEnvironment.MapPath(
// "~/App_Data/AzureApp_signing.cer")));
authServicesOptions.IdentityProviders.Add(idp);
app.UseKentorAuthServicesAuthentication(authServicesOptions);
}
示例3: Configuration
public void Configuration(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider()
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseKentorAuthServicesAuthentication(CreateAuthServicesOptions());
}
示例4: Configuration
public void Configuration(IAppBuilder app)
{
var authServicesOptions = new KentorAuthServicesAuthenticationOptions(false)
{
SPOptions = new SPOptions
{
EntityId = new EntityId("http://sp.example.com")
},
SignInAsAuthenticationType = "External",
AuthenticationType = "saml2p",
Caption = "SAML2p"
};
authServicesOptions.IdentityProviders.Add(new IdentityProvider(new EntityId("http://stubidp.kentor.se/Metadata"), authServicesOptions.SPOptions)
{
LoadMetadata = true
});
var cors = new InMemoryCorsPolicyService(Clients.Get());
var factory = new IdentityServerServiceFactory()
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(Scopes.Get())
.UseInMemoryUsers(Users.Get());
factory.CorsPolicyService = new Registration<ICorsPolicyService>(cors);
var options = new IdentityServerOptions
{
Factory = factory,
AuthenticationOptions = new AuthenticationOptions()
{
IdentityProviders = (appBuilder, signInAsType) =>
{
Kentor.AuthServices.Configuration.Options.GlobalEnableSha256XmlSignatures();
app.UseKentorAuthServicesAuthentication(authServicesOptions);
}
},
LoggingOptions = new LoggingOptions()
{
EnableHttpLogging = true,
EnableKatanaLogging = true,
EnableWebApiDiagnostics = true
}
};
app.UseIdentityServer(options);
}
示例5: ConfigureIdentityProviders
private void ConfigureIdentityProviders(IAppBuilder app, string signInAsType)
{
var authServicesOptions = new KentorAuthServicesAuthenticationOptions(false)
{
SPOptions = new SPOptions
{
EntityId = new EntityId("https://localhost:44300/identity/AuthServices")
},
SignInAsAuthenticationType = signInAsType,
AuthenticationType = "okta",
Caption = "Okta"
};
authServicesOptions.IdentityProviders.Add(new IdentityProvider(
new EntityId("http://www.okta.com/exk5dcmpavv9xKCZC0h7"), authServicesOptions.SPOptions)
{
LoadMetadata = true,
MetadataUrl = new Uri("https://dev-169318.oktapreview.com/app/exk5dcmpavv9xKCZC0h7/sso/saml/metadata"),
AllowUnsolicitedAuthnResponse = true
});
app.UseKentorAuthServicesAuthentication(authServicesOptions);
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
{
AuthenticationType = "Google",
Caption = "Sign-in with Google",
SignInAsAuthenticationType = signInAsType,
ClientId = "297503349559-dmgmcoqfpkr7kr93e3kh0kj4gfrigbgf.apps.googleusercontent.com",
ClientSecret = "hllqf-f_5xvozZnG9YRvOfo1"
});
}
示例6: ConfigureSaml2
private void ConfigureSaml2(IAppBuilder app, string signInAsType)
{
var options = new KentorAuthServicesAuthenticationOptions(false)
{
SPOptions = new SPOptions
{
EntityId = new EntityId("http://localhost:4589/IdSrv3/AuthServices"),
},
SignInAsAuthenticationType = signInAsType,
Caption = "SAML2p"
};
UseIdSrv3LogoutOnFederatedLogout(app, options);
options.SPOptions.SystemIdentityModelIdentityConfiguration.AudienceRestriction.AudienceMode
= AudienceUriMode.Never;
options.SPOptions.ServiceCertificates.Add(new X509Certificate2(
AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "/App_Data/Kentor.AuthServices.Tests.pfx"));
options.IdentityProviders.Add(new IdentityProvider(
new EntityId("http://localhost:52071/Metadata"),
options.SPOptions)
{
LoadMetadata = true
});
app.UseKentorAuthServicesAuthentication(options);
}