Vault, Nant & Integrated Security

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
jaydenm
Posts: 3
Joined: Sat May 23, 2009 2:44 am

Vault, Nant & Integrated Security

Post by jaydenm » Sat May 23, 2009 2:55 am

Is there any way we can get Vault to use Windows Authentication from Nant to create the connection?

The Nant block I am using to initialise the vault connection is :

<target name="InitialiseVaultSettings">
<echo>InitialiseVaultSettings</echo>
<vaultsetloginoptions user="${vault.Username}" password="${vault.Password}" URL="${vault.Host}" repository="${vault.Repository}" />
<vaultsetworkingfolder repositoryFolderPath="${vault.Folder}" diskPath="${vault.WorkingDirectory}" createDiskPath="true" />

As I am working on the project with other developers, hard coding user names and passwords into the Nant build file is not a good idea. Both username and password are required options in the vaultsetloginoptions command.

An alternative would be to call the vault.exe command line tool, if that was able to be called and use integrated security? Is this possible if not within Nant tasks?

Regards

Jayden

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Vault, Nant & Integrated Security

Post by Beth » Tue May 26, 2009 8:12 am

Vault has a way to use Windows logins, but then you still have to enter in the login name and password into your script. If you have room for one more user in your licenses, you might want to consider making a Vault login that has very limited access or maybe read-only.
Beth Kieler
SourceGear Technical Support

jaydenm
Posts: 3
Joined: Sat May 23, 2009 2:44 am

Re: Vault, Nant & Integrated Security

Post by jaydenm » Sun Jun 14, 2009 4:43 pm

Hi

I've solved this problem by building some custom NAnt tasks. See this link with an explanation for anyone else interested :

http://stackoverflow.com/questions/8512 ... 935#993935

jaydenm
Posts: 3
Joined: Sat May 23, 2009 2:44 am

Re: Vault, Nant & Integrated Security

Post by jaydenm » Sun Jun 14, 2009 7:21 pm

UPDATE : the code sample and attachments have been updated since the original post see end of post for details, encryption improved, test stub added and additional comments made in source code ...

The following attachment is a barebones NAnt extension that can be used to provide a UI prompting the user for their Vault UserName and Password. This removes the need to hard code usernames or passwords into your NAnt scripts when using Vault.

Ensure you have the appropriate NAnt tasks installed for Vault. Place the binary file CompassHealth.NAntExtensions.Tasks.dll in the source root directory.

You can then use the following tasks : <VaultLoginGet> , <VaultLoginSave>

You can then use the following functions : ${VaultLoginFunctions::UserName()} , ${VaultLoginFunctions::Password}

Ensure you incluede the <loadtasks assembly="CompassHealth.NAntExtensions.Tasks.dll" /> line to load the extension.

The below is an example of useage :

Code: Select all

  <target name="InitialiseVaultSettings">
    <echo>InitialiseVaultSettings</echo>

    <loadtasks assembly="CompassHealth.NAntExtensions.Tasks.dll" />

    <VaultLoginGet />
    <echo message="UserName = ${VaultLoginFunctions::UserName()}" />

    <vaultsetloginoptions user="${VaultLoginFunctions::UserName()}" password="${VaultLoginFunctions::Password()}" URL="${vault.Host}" repository="${vault.Repository}" />
    
    <vaultsetworkingfolder repositoryFolderPath="${vault.Folder}" diskPath="${vault.WorkingDirectory}" createDiskPath="true" />

    <!-- need to save the login here, as it is cleared once called, this ensures that only correct username and password are stored -->
    <VaultLoginSave />    

  </target>
UPDATE DETAILS
i. need to call VaultLoginSave after vaultsetworkingfolder as vaultsetloginoptions doesn't cause the script to fail immediately until the vaultsetworkingfolder operation begins
ii. Added AES encryption so that user's password is not saved in plaintext in the registry
iii. Fixed some internal logic around clearing the authentication details appropriately after a VaultLoginGet call
Attachments
CompassHealth.NAntExtensions.Tasks_Source.zip
Source files
(238.77 KiB) Downloaded 354 times
CompassHealth.NAntExtensions.Tasks_Binaries.zip
Binaries
(4.5 KiB) Downloaded 252 times
Last edited by jaydenm on Wed Jul 01, 2009 1:13 am, edited 2 times in total.

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Vault, Nant & Integrated Security

Post by Beth » Mon Jun 15, 2009 7:01 am

Thanks for the update. I'm sure other users will find this useful.
Beth Kieler
SourceGear Technical Support

Post Reply