何らかの理由により、ユーザーはほとんど10/20分ごとにlogin.microsoftonline.comにリダイレクトされます。以下のコードは、CMSのユーザーにログインするために使用されるため、これは非常に面倒です。ユーザーは10〜20分ごとにログアウトします(クレーム認証)
誰でも次のコードで何が間違っているのか、なぜユーザーがログアウトするか/ login.microsoftonline.comにリダイレクトされるのでしょうか?セッションの有効期間は60分に設定されているため、認証自体のものでなければなりません。
WsFederationAuthenticationDefaults.AuthenticationType、CookieAuthenticationDefaults.AuthenticationTypeまたはDefaultAuthenticationTypes.ApplicationCookieを使用する必要がありますか?
我々は、ユーザーがフォーム(/アカウント/ inloggen)を使用するか(外部ログインです)「AzureのSSO」と呼ばれるボタンを使用してサインインすることができるようにしたい
public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context and user manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.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/inloggen"),
Provider = new CookieAuthenticationProvider
{
OnResponseSignIn = ctx =>
{
ctx.Identity = TransformClaims(ctx.Identity);
ctx.Properties.ExpiresUtc = DateTimeOffset.UtcNow.AddDays(7.0);
},
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ExpireTimeSpan = TimeSpan.FromDays(7.0),
SlidingExpiration = true
});
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ExpireTimeSpan = TimeSpan.FromDays(7.0),
SlidingExpiration = true
});
app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
{
MetadataAddress = "https://login.microsoftonline.com/xxxxxxxxxxxxxx/federationmetadata.xml",
Wtrealm = "https://portal.domain.com",
Caption = "Azure SSO",
SignInAsAuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
UseTokenLifetime = false,
AuthenticationMode = AuthenticationMode.Passive
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
}
ときに、なぜ私たちが使用する必要がありますこの?
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
あなたはこのすべてにかなり新しいことに気付いたかもしれません。私はスタックのオーバーフローやグーグルのサンプルを閲覧しましたが、異なる認証タイプ、そのプロパティ、およびそれらの使い方を説明する明確な答え/チュートリアルはありません。
ありがとうございます。しかし、それは30分に設定され、現在のユーザーは10〜20分ごとにログアウトされ、SlidingExpirationはTrueに設定されます。 SlidingExpirationが有効になっていてもユーザーはどのようにログアウトしますか? regenerateIdentity関数は新しい有効なIDを生成しませんか?私は何も考えない。 – Robin