diff --git a/src/Logto.AspNetCore.Authentication/LogtoOptions.cs b/src/Logto.AspNetCore.Authentication/LogtoOptions.cs index 079b770..42df1a3 100644 --- a/src/Logto.AspNetCore.Authentication/LogtoOptions.cs +++ b/src/Logto.AspNetCore.Authentication/LogtoOptions.cs @@ -63,6 +63,10 @@ public class LogtoOptions /// set this value to `true` since they are not included in the ID token. /// public bool GetClaimsFromUserInfoEndpoint { get; set; } = false; + /// + /// The domain to associate the cookie with. Allows multiple applications to share the cookie such as on sub-domains. + /// + public string? CookieDomain { get; set; } = null; } /// @@ -78,4 +82,5 @@ public static class PromptMode /// The user will be prompted for sign-in again anyway. Note there will be no refresh token returned in this case. /// public const string Login = "login"; + } diff --git a/src/Logto.AspNetCore.Authentication/extensions/AuthenticationBuilderExtensions.cs b/src/Logto.AspNetCore.Authentication/extensions/AuthenticationBuilderExtensions.cs index cc3f76e..46b2086 100644 --- a/src/Logto.AspNetCore.Authentication/extensions/AuthenticationBuilderExtensions.cs +++ b/src/Logto.AspNetCore.Authentication/extensions/AuthenticationBuilderExtensions.cs @@ -73,6 +73,7 @@ private static void ConfigureCookieOptions(string authenticationScheme, CookieAu { options.Cookie.Name = $"Logto.Cookie.{logtoOptions.AppId}"; options.SlidingExpiration = true; + options.Cookie.Domain = logtoOptions.CookieDomain; options.Events = new CookieAuthenticationEvents { OnValidatePrincipal = context => new LogtoCookieContextManager(authenticationScheme, context).Handle()