Created
February 3, 2017 16:22
-
-
Save johnkors/e1ff331796db337dba0ef8591253f456 to your computer and use it in GitHub Desktop.
/core/discourse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Redirected from Discourse | |
[Route("core/discourse")] | |
[HttpGet] | |
public async Task<ActionResult> Index(string sso, string sig) | |
{ | |
if (!IsValid(sso, sig)) | |
{ | |
throw new SecurityException("sso sig not valid"); | |
} | |
var idsrvClaimsIdentity = await Request.GetOwinContext().Environment.GetIdentityServerFullLoginAsync(); | |
var isAuthenticated = idsrvClaimsIdentity != null; | |
if (isAuthenticated) | |
{ | |
// User authenticated, getting user, generating sso and redirecting back to Discourse | |
var user = Users.GetUserBySub(idsrvClaimsIdentity.FindFirst(c => c.Type == "sub").Value); | |
var redirectUrl = CreateDiscourseRedirectUrl(user, sso); | |
return new RedirectResult(redirectUrl); | |
} | |
// Not authenticated, returning login page | |
TempData["sso"] = sso; | |
return View(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment