How to check if svn command requires authentication

Is there any possible way to check if an SVN update is required for authentication or not?

Scenario: I wrote a ruby โ€‹โ€‹graphical application that updates SVN repositories (from a static path) in the planned order. This runs as a Windows service. Turtles are also installed.

In ruby โ€‹โ€‹when I perform

svn update local_path_to_repository --username user --password password in my script, then it works fine when I pass the username and password using the update command.

But tortoisesvn saves the password (by caching the password using standard Windows cryptography services to encrypt the password on the disk) when I first look at the repository, so I donโ€™t have to pass the username and password every time, So I just svn update local_path_to_repository in my script.

Problem: This works fine until I change my LDAP password. After changing my LDAP password, all repositories do not receive updates because they request a new password, but there is no user interface for sending a new password.

I need to create a user interface and password only when svn updates need these credentials, but not always. How do I achieve this?

Update: reading from the SVN book . I realized that:

  • The client checks to see if the user has specified any credentials as command line parameters (--username and / or --password). If not, or if these parameters did not authenticate successfully, then
  • The client looks at the server host name, port, and realm in runtime / realm to see if the user already has the appropriate credentials in the cache. If not, or if the cached credentials are not authenticated, then
  • Finally, the client resorts to the user's prompt (unless specified that this is not necessary with the --non-interactive option or its client-specific equivalents).

But I did not find a way to check if authentication is required.

Can anybody help me!

+7
windows ruby svn tortoisesvn
source share
1 answer

So, I finally found work by doing:

 output = `svn update "#{repo_path}" --non-interactive 2>&1` check_authentication = output.include?("Authentication failed") 

if check_authentication returns true , which means that authentication failed, I create a GUI to enter a new password and send it to the user.

+3
source share

All Articles