Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Consider adding SignInResult/SignOutResult and SignIn/SignOut #4258

Closed
@kevinchalet

Description

@kevinchalet

MVC 6 has really cool authentication-specific ActionResults and helpers for Forbid and Challenge, but nothing for SignIn and SignOut.

It would really make this kind of actions much clearer:

[HttpPost("~/connect/logout"), ValidateAntiForgeryToken]
public async Task<IActionResult> Logout() {
    var response = HttpContext.GetOpenIdConnectResponse();
    if (response != null) {
        return View("Error", response);
    }

    // ...

    // Ask the cookies middleware to delete the local cookie created
    // when the user agent is redirected from the external identity provider
    // after a successful authentication flow (e.g Google or Facebook).
    await HttpContext.Authentication.SignOutAsync("ServerCookie");

    // Redirect the user agent to the post_logout_redirect_uri specified by the client application.
    await HttpContext.Authentication.SignOutAsync(OpenIdConnectServerDefaults.AuthenticationScheme);

    return new EmptyResult();
}

->

[HttpPost("~/connect/logout"), ValidateAntiForgeryToken]
public async Task<IActionResult> Logout() {
    var response = HttpContext.GetOpenIdConnectResponse();
    if (response != null) {
        return View("Error", response);
    }

    // ...

    return SignOut("ServerCookie", OpenIdConnectServerDefaults.AuthenticationScheme);
}

I'm fine submitting a PR if you like the general idea 👏

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions