public ForceRenewalCookieAuthenticationMiddleware( OwinMiddleware next, IAppBuilder app, UmbracoBackOfficeCookieAuthOptions options, IUmbracoContextAccessor umbracoContextAccessor) : base(next, app, options) { _umbracoContextAccessor = umbracoContextAccessor; }
/// <summary> /// Create the default umb cookie auth options /// </summary> /// <param name="app"></param> /// <param name="explicitPaths"></param> /// <returns></returns> public static UmbracoBackOfficeCookieAuthOptions CreateUmbracoCookieAuthOptions(this IAppBuilder app, string[] explicitPaths = null) { var authOptions = new UmbracoBackOfficeCookieAuthOptions( explicitPaths, UmbracoConfig.For.UmbracoSettings().Security, GlobalSettings.TimeOutInMinutes, GlobalSettings.UseSSL); return(authOptions); }
/// <summary> /// Ensures that the UmbracoBackOfficeAuthenticationMiddleware is assigned to the pipeline /// </summary> /// <param name="app"></param> /// <param name="appContext"></param> /// <returns></returns> public static IAppBuilder UseUmbracoBackOfficeCookieAuthentication(this IAppBuilder app, ApplicationContext appContext) { if (app == null) { throw new ArgumentNullException("app"); } if (appContext == null) { throw new ArgumentNullException("appContext"); } var authOptions = new UmbracoBackOfficeCookieAuthOptions( UmbracoConfig.For.UmbracoSettings().Security, GlobalSettings.TimeOutInMinutes, GlobalSettings.UseSSL) { Provider = new BackOfficeCookieAuthenticationProvider { // 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 <BackOfficeUserManager, BackOfficeIdentityUser, int>( TimeSpan.FromMinutes(30), (manager, user) => user.GenerateUserIdentityAsync(manager), identity => identity.GetUserId <int>()), } }; app.UseUmbracoBackOfficeCookieAuthentication(authOptions, appContext); //don't apply if app isnot ready if (appContext.IsUpgrading || appContext.IsConfigured) { //This is a custom middleware, we need to return the user's remaining logged in seconds app.Use <GetUserSecondsMiddleWare>( authOptions, UmbracoConfig.For.UmbracoSettings().Security, app.CreateLogger <GetUserSecondsMiddleWare>()); } return(app); }
public GetUserSecondsMiddleWare( OwinMiddleware next, UmbracoBackOfficeCookieAuthOptions authOptions, ISecuritySection security, ILogger logger) : base(next) { if (authOptions == null) { throw new ArgumentNullException("authOptions"); } if (logger == null) { throw new ArgumentNullException("logger"); } _authOptions = authOptions; _security = security; _logger = logger; }
/// <summary> /// Instantiates the middleware with an optional pointer to the next component. /// </summary> /// <param name="next"/> /// <param name="cookieOptions"></param> public PreviewAuthenticationMiddleware(OwinMiddleware next, UmbracoBackOfficeCookieAuthOptions cookieOptions) : base(next) { _cookieOptions = cookieOptions; }