Skip to content

Veracity Claims

CodeGx edited this page Apr 2, 2018 · 1 revision

Claims contain several useful values for your app/service. The following code can be used to obtain relevant claim data conveniently.

MyDNVGL is a part of Veracity and plays the role of services portal and authentication management. Therefore, we would like to call user id as MyDNVGL id.

public static class MyDnvglExtension
    {
        public static string Name(this ClaimsPrincipal user)
        {
            return user.FindFirst("name")?.Value;
        }

        public static string MyDnvglId(this ClaimsPrincipal user)
        {
            return user.FindFirst("userId")?.Value;
        }

        public static string DnvglAccountName(this ClaimsPrincipal user)
        {
            return user.FindFirst("dnvglAccountName")?.Value;
        }

        public static string Email(this ClaimsPrincipal user)
        {
            return user.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress")?.Value;
        }
    }
Clone this wiki locally