Closed TLA020 closed 3 years ago
Odd, I just tested it and it worked. Are you testing with our sample code?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Questions are community supported only and the authors/maintainers may or may not have time to reply. If you or your company would like commercial support, please see here for more information.
Because we do not use "AddOpenIdConnect()
" but AddMicrosoft()
I guess this doesn't implement the -> ISecureDataFormat<AuthenticationProperties>
So i add a custom implementation:
ConfigureMicrosoftOptions.cs
internal class ConfigureMicrosoftOptions : IPostConfigureOptions<MicrosoftAccountOptions>
{
private readonly string[] _schemes;
private readonly IHttpContextAccessor _httpContextAccessor;
public ConfigureMicrosoftOptions(string[] schemes, IHttpContextAccessor httpContextAccessor)
{
_schemes = schemes ?? throw new ArgumentNullException(nameof(schemes));
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
}
public void PostConfigure(string name, MicrosoftAccountOptions options)
{
// no schemes means configure them all
if (_schemes.Length == 0 || _schemes.Contains(name))
{
options.StateDataFormat = new DistributedCacheStateDataFormatter(_httpContextAccessor, name);
}
}
}
part of StartupHelpers.cs
public static IServiceCollection AddMicrosoftStateDataFormatterCache(this IServiceCollection services, params string[] schemes)
{
services.AddSingleton<IPostConfigureOptions<MicrosoftAccountOptions>>(
svcs => new ConfigureMicrosoftOptions(
schemes,
svcs.GetRequiredService<IHttpContextAccessor>()));
return services;
}
ConfigureServices @ Startup.cs
// configures the OpenIdConnect handlers to persist the state parameter into the server-side IDistributedCache.
services.AddOidcStateDataFormatterCache();
services.AddMicrosoftStateDataFormatterCache();
This fixed the issue ! @brockallen
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Questions are community supported only and the authors/maintainers may or may not have time to reply. If you or your company would like commercial support, please see here for more information.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Dear,
When i login using a microsoft-workAccount there are no issues. When i login with a microsoft-personalAccount the state seems to exceed the max string limit of Microsoft.
To reduce the length of the URL i call the AddOidcStateDataFormatterCache extension method:
AddOidcStateDataFormatterCache()
As suggested in the docs
This did not reduce the length, did nothing at all... anything i could've missed? The docs say "simply call the AddOidcStateDataFormatterCache extension method"
Some context: