Search code examples
gitsvngitlabgit-svnsvn2git

Migrating from SVN to GIT Requested Authentication type(s) are not supported


I'm migrating our organizations svn repo to a gitlab repository. I've looked around at lots of different sources on stack overflow which I tried to link but I got a warning that my question appears to be spam. Here are a couple links I tried: tutorial one as well as the read me for svn2git and haven't found the answer. I'm on Windows 10. I've installed ruby, svn2git, svn2gitnet (svn2git but claims to allow you to enter password), TortoiseSVN, and TortoiseGit. I try to run the command:

svn2git http://*******-****/******* -v --username ********

and

svn2gitnet http://*******-****/******* -v --username ******** --password *******

which both return

Running command: git svn init --prefix=svn/ --username='********' --no-metadata --trunk='trunk' --tags='tags' --branches='branches' http://*******-****/*******
Initialized empty git repository in C:/Users/********/Desktop/.git/
Can't create session: Unable to connect to a repository at URL 'http://*******-****/*******': Error running context: The requested authentication type(s) are not supported at C:/Program Files/Git/mingw64/share/perl5/Git/SVN.pm line 310.

command failed:
git svn init --prefix=svn/ --username='********' --no-metadata --trunk='trunk' --tags='tags' --branches='branches' http://*******-****/*******

the surrounding module of line 310 in SVN.pm is:

sub init_remote_config {
    my ($self, $url, $no_write) = @_;
    $url = canonicalize_url($url);
    my $r = read_all_remotes();
    my $existing = find_existing_remote($url, $r);
    if ($existing) {
        unless ($no_write) {
            print STDERR "Using existing ",
                     "[svn-remote \"$existing\"]\n";
        }
        $self->{repo_id} = $existing;
    } elsif ($_minimize_url) {
        my $min_url = Git::SVN::Ra->new($url)->minimize_url;//line 310
        $existing = find_existing_remote($min_url, $r);
        if ($existing) {
            unless ($no_write) {
                print STDERR "Using existing ",
                         "[svn-remote \"$existing\"]\n";
            }
            $self->{repo_id} = $existing;
        }
        if ($min_url ne $url) {
            unless ($no_write) {
                print STDERR "Using higher level of URL: ",
                         "$url => $min_url\n";
            }
            my $old_path = $self->path;
            $url =~ s!^\Q$min_url\E(/|$)!!;
            $url = join_paths($url, $old_path);
            $self->path($url);
            $url = $min_url;
        }
    }
    my $orig_url;
    if (!$existing) {
        # verify that we aren't overwriting anything:
        $orig_url = eval {
            command_oneline('config', '--get',
                    "svn-remote.$self->{repo_id}.url")
        };
        if ($orig_url && ($orig_url ne $url)) {
            die "svn-remote.$self->{repo_id}.url already set: ",
                "$orig_url\nwanted to set to: $url\n";
        }
    }
    my ($xrepo_id, $xpath) = find_ref($self->refname);
    if (!$no_write && defined $xpath) {
        die "svn-remote.$xrepo_id.fetch already set to track ",
            "$xpath:", $self->refname, "\n";
    }
    unless ($no_write) {
        command_noisy('config',
                  "svn-remote.$self->{repo_id}.url", $url);
        my $path = $self->path;
        $path =~ s{^/}{};
        $path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;
        $self->path($path);
        command_noisy('config', '--add',
                  "svn-remote.$self->{repo_id}.fetch",
                  $self->path.":".$self->refname);
    }
    $self->url($url);
}

What next steps should I take?

EDIT: The line of code below turns out to be calling Subversion remote access function new. This function fills in some default parameters including the authentication scheme. Therefore it's likely the issue was that the default authentication scheme it's using is probably not NTLM. Which was the authentication our server was using. It's also possible that SVN did receive the right authentication from the url passed in but no longer supports NTLM.

my $min_url = Git::SVN::Ra->new($url)->minimize_url;//line 310


Solution

  • Solution

    • First, you have to get the authors file so you can get the commit history. I used this command in powershell in the directory of the svn repo on the client machine to print out the names of everyone whose committed:
    svn.exe log --quiet | ? { $_ -notlike '-*' } | % { "{0} = {0} <{0}>" -f ($_ -split ' \| ')[1] } | Select-Object -Unique
    
    • It should print out something like this:
         ***\**** = ***\**** <***\****>>     
         ***\**** = ***\**** <***\****>
         ******** = ******** <********>
         ******** = ******** <********>
    
    • Copy that into a text file and remember the location. Modify the format so each entry has their original svn name assigned to a first name, last name, and :
        ***\**** = *** **** <***@example.com>
        ***\**** = *** **** <***@example.com>
        ******** = **** **** <****@example.com>
        ******** = *** ***** <***@example.com>
    
    • Then I got remote access to the server and I modified the httpd.conf file located in D:\apachesvn\conf to remove anything trying to set up authentication. You can add the authentication back in after migration if necessary. For example this section:
    <Location /phoneme>
    DAV svn
    SVNPath "d:/svn/phoneme/"
    
        AuthName "Subversion Phoneme repositories"
        AuthType SSPI
        NTLMAuth On
        NTLMAuthoritative On
        <RequireAll>
            <RequireAny>
                Require valid-user
                #require sspi-user EMEA\group_name
            </RequireAny>
            <RequireNone>
                Require user "ANONYMOUS LOGON"
                Require user "NT-AUTORITÄT\ANONYMOUS-ANMELDUNG"
            </RequireNone>
        </RequireAll>
        # use this to add the authenticated username to you header
        # so any backend system can fetch the current user
        # rewrite_module needs to be loaded then
        #RewriteEngine On
        #RewriteCond %{LA-U:REMOTE_USER} (.+)
        #RewriteRule . - [E=RU:%1]
        #RequestHeader set X_ISRW_PROXY_AUTH_USER %{RU}e
    </Location>
    
    • Was changed to this:
    <Location /phoneme>
    DAV svn
    SVNPath "d:/svn/phoneme/"
    </Location>
    
    • Finally, I restarted the Apache 2.4 service on the server using task manager and went back to the client machine and used this command format to finally migrate the svn repo to git.
    git svn clone "http://repo-url/root" "C:\path\to\new\git\repo" -stdlayout -A "C:/path/to/authors/file/authors.txt"