Esempio n. 1
0
        /// <summary>
        /// Saves the specified application role.  Creating it if it does not exist, and updating otherwise.  Returns a new version of the passed in appRole object or Null if it encountered an issue.
        /// </summary>
        /// <param name="appRole">The Name the Application Role should be saved under or updated as.</param>
        /// <returns>AppRole object as read from the Vault instance.  It will contain the RoleID token value also.</returns>
        public async Task <AppRole> SaveRoleAndReturnRoleObject(AppRole appRole)
        {
            if (await SaveRole(appRole))
            {
                // Now Re-Read it:
                AppRole updatedRole = await ReadRole(appRole.Name, true);

                return(updatedRole);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Saves the specified application role.  Creating it if it does not exist, and updating otherwise.  This only returns True or False upon saving.
        /// </summary>
        /// <param name="appRole" >The AppRole Object that you wish to be created or updated in Vault.</param>
        /// <returns>True if successful.</returns>
        /// <see cref="AppRole"/>
        public async Task <bool> SaveRole(AppRole appRole)
        {
            string path = MountPointPath + "role/" + appRole.Name;
            string json = JsonConvert.SerializeObject(appRole);


            VaultDataResponseObjectB vdro = await ParentVault._httpConnector.PostAsync_B(path, "AppRoleAuthEngine: SaveRole", json);

            if (vdro.Success)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Reads the AppRole with the given name.  Returns an AppRole object or Null if the AppRole does not exist.
        /// </summary>
        /// <param name="appRoleName">String name of the app role to retrieve.</param>
        /// <param name="readRoleID">If True, the method, will perform a second Read operation to get the Role ID.  By Default Vault does
        /// not return the RoleID.  So, if you do not need the RoleID, then leaving this false is faster and more efficient</param>
        /// <returns>AppRole object.</returns>
        public async Task <AppRole> ReadRole(string appRoleName, bool readRoleID = false)
        {
            string path = MountPointPath + "role/" + appRoleName;

            VaultDataResponseObjectB vdro = await ParentVault._httpConnector.GetAsync_B(path, "ReadRole");

            if (vdro.Success)
            {
                AppRole appRole = await vdro.GetDotNetObject <AppRole> ("data");

                appRole.Name = appRoleName;

                // Read the roleID if requested to:
                if (readRoleID)
                {
                    appRole.RoleID = await ReadRoleID(appRole.Name);
                }

                return(appRole);
            }

            return(null);
        }
Esempio n. 4
0
 /// <summary>
 /// Deletes the App Role from the vault.  Returns True if deleted OR did not exist.  False otherwise.
 /// </summary>
 /// <param name="appRole">AppRole object to be deleted</param>
 /// <returns>Bool:  True if deleted.  False otherwise</returns>
 public async Task <bool> DeleteRole(AppRole appRole)
 {
     return(await DeleteRole(appRole.Name));
 }