Если вы просто проверяете наличие файла cookie, почему бы и нет ...
if (isset ($ _ COOKIE ['mycookie'])) {сделайте что-нибудь здесь}
В .net framework вы можете настроить OpenID Connect, используя библиотеку Microsoft.Owin.Security.OpenIdConnect
в файле Startup.Auth.cs
, например:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = Authority,
PostLogoutRedirectUri = redirectUri,
RedirectUri = redirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
//
// If there is a code in the OpenID Connect response, redeem it for an access token and refresh token, and store those away.
//
AuthenticationFailed = OnAuthenticationFailed
}
});
}
private Task OnAuthenticationFailed(AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> context)
{
context.HandleResponse();
context.Response.Redirect("/Home/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
}
Спасибо за ответы! Я бы сказал, что @Nan Yu, вероятно, получил ответ, который оказался ближе всего к решению, которое я придумал, но я решил, что поделюсь тем, что в итоге получилось, в методе Configure () моего файла Startup.cs .
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
...
var openidOptions = new OpenIdConnectOptions(authenticationScheme)
{
ClientSecret = secret,
AutomaticAuthenticate = true,
SignInScheme = "Identity.External",
Authority = identityServerAddress,
ClientId = clientId,
RequireHttpsMetadata = true,
ResponseType = OpenIdConnectResponseType.CodeIdToken,
AutomaticChallenge= true,
GetClaimsFromUserInfoEndpoint = true,
SaveTokens = true,
Events = new OpenIdConnectEvents
{
OnRemoteSignOut = async remoteSignOutContext =>
{
remoteSignOutContext.HttpContext.Session.Clear();
},
},
};
openidOptions.Scope.Clear();
openidOptions.Scope.Add("openid");
app.UseOpenIdConnectAuthentication(openidOptions);
Добавление этого к моему клиенту .NET Framework 4.6 позволило мне успешно установить связь с моим .NET Core 2.0 Identity Server! Я ценю всех, кто пытался помочь :)