Esempio n. 1
0
        /// <summary>
        /// Use a unverified credential to build a new user instance.
        /// </summary>
        /// <returns> user builder</returns>
        /// <param name="credential">Credential.</param>
        /// <param name="resource">Resource.</param>
        public UserBuilder FromUnverifiedCredential(ICredential credential, string resource)
        {
            NonNull(credential, "credential");
            var             accessToken = NonNull(credential.AccessToken, "credential.AccessToken");
            KeycloakProfile kcProfile   = new JwtBuilder()
                                          .DoNotVerifySignature()
                                          .Decode <KeycloakProfile>(accessToken);

            this.AccessToken   = credential.AccessToken;
            this.IdentityToken = credential.IdentityToken;
            this.RefreshToken  = credential.RefreshToken;
            this.Email         = kcProfile.Email;
            this.Username      = kcProfile.UserName;
            this.Firstname     = kcProfile.FirstName;
            this.Lastname      = kcProfile.LastName;
            this.Roles         = kcProfile.GetUserRoles(resource);
            return(this);
        }