Created
March 29, 2019 17:42
-
-
Save sitefinitysteve/b4f895d4d195542dea938827b6d9e813 to your computer and use it in GitHub Desktop.
Get the logged in users IDP\IdentityProvider
This file contains 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
public static class Util | |
{ | |
public static string GetIdentityProvider() | |
{ | |
var identity = ClaimsManager.GetCurrentIdentity(); | |
var idToken = identity.Claims.FirstOrDefault(c => c.Type == "id_token"); | |
if (idToken != null) | |
{ | |
var handler = new JwtSecurityTokenHandler(); | |
var jwtToken = handler.ReadToken(idToken.Value) as JwtSecurityToken; | |
if (jwtToken != null) | |
{ | |
var idpClaim = jwtToken.Claims.FirstOrDefault(c => c.Type == "idp"); | |
if (idpClaim != null) | |
{ | |
return idpClaim.Value; | |
} | |
} | |
} | |
return "Unknown"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment