/// <summary>GetClaims</summary> /// <param name="userName">string</param> /// <param name="roles">string</param> /// <param name="scopes">string</param> /// <param name="ipAddress">string</param> public static void GetClaims(out string userName, out string roles, out string scopes, out string ipAddress) { // MyHttpContext.Current.User.Identity側ではなく、Identities側に入っている。 // Identityは認証ミドルウェアを使用する必要がある?(coreでjwtをどう処理するのか?) IEnumerable <Claim> claims = MyBaseAsyncApiController.GetRawClaims(); if (claims == null) { // claims == null userName = "******"; roles = ""; scopes = ""; ipAddress = ""; } else { // claims != null Claim claim = null; claim = claims.FirstOrDefault(c => c.Type == ClaimTypes.Name); if (claim == null) { userName = "******"; } else { userName = claim.Value; } claim = claims.FirstOrDefault(c => c.Type == ClaimTypes.Role); if (claim == null) { roles = ""; } else { roles = claim.Value; } claim = claims.FirstOrDefault(c => c.Type == OAuth2AndOIDCConst.UrnScopesClaim); if (claim == null) { scopes = ""; } else { scopes = claim.Value; } claim = claims.FirstOrDefault(c => c.Type == "IpAddress"); if (claim == null) { ipAddress = ""; } else { ipAddress = claim.Value; } } }
/// <summary>GetClaims</summary> /// <param name="userName">string</param> /// <param name="roles">string</param> /// <param name="scopes">string</param> /// <param name="ipAddress">string</param> public static void GetClaims(out string userName, out string roles, out string scopes, out string ipAddress) { IEnumerable <Claim> claims = MyBaseAsyncApiController.GetRawClaims(); if (claims == null) { // claims == null userName = "******"; roles = ""; scopes = ""; ipAddress = ""; } else { // claims != null Claim claim = null; claim = claims.FirstOrDefault(c => c.Type == ClaimTypes.Name); if (claim == null) { userName = "******"; } else { userName = claim.Value; } claim = claims.FirstOrDefault(c => c.Type == ClaimTypes.Role); if (claim == null) { roles = ""; } else { roles = claim.Value; } claim = claims.FirstOrDefault(c => c.Type == OAuth2AndOIDCConst.UrnScopesClaim); if (claim == null) { scopes = ""; } else { scopes = claim.Value; } claim = claims.FirstOrDefault(c => c.Type == "IpAddress"); if (claim == null) { ipAddress = ""; } else { ipAddress = claim.Value; } } }
/// <summary>GetClaims</summary> /// <param name="userName">string</param> /// <param name="roles">string</param> /// <param name="scopes">string</param> /// <param name="ipAddress">string</param> public static void GetClaims(out string userName, out string roles, out string scopes, out string ipAddress) { IEnumerable <Claim> claims = MyBaseAsyncApiController.GetRawClaims(); userName = claims.FirstOrDefault(c => c.Type == ClaimTypes.Name).Value; roles = claims.FirstOrDefault(c => c.Type == ClaimTypes.Role).Value; scopes = claims.FirstOrDefault(c => c.Type == OAuth2AndOIDCConst.UrnScopesClaim).Value; ipAddress = claims.FirstOrDefault(c => c.Type == "IpAddress").Value; }
/// <summary>GetClaims</summary> /// <param name="userName">string</param> /// <param name="roles">string</param> /// <param name="scopes">string</param> /// <param name="ipAddress">string</param> public static void GetClaims(out string userName, out string roles, out string scopes, out string ipAddress) { // MyHttpContext.Current.User.Identity側ではなく、Identities側に入っている。 // Identityは認証ミドルウェアを使用する必要がある?(coreでjwtをどう処理するのか?) IEnumerable <Claim> claims = MyBaseAsyncApiController.GetRawClaims(); userName = claims.FirstOrDefault(c => c.Type == ClaimTypes.Name).Value; roles = claims.FirstOrDefault(c => c.Type == ClaimTypes.Role).Value; scopes = claims.FirstOrDefault(c => c.Type == OAuth2AndOIDCConst.UrnScopesClaim).Value; ipAddress = claims.FirstOrDefault(c => c.Type == "IpAddress").Value; }