Exemplo n.º 1
0
 public ActionResult Tags(String owner, String name)
 {
     using (var git = new GitService(owner, name))
     {
         var model = git.GetTags();
         //if (model == null)
         //    throw new HttpException((int)HttpStatusCode.NotFound, String.Empty);
         model.Owner     = owner;
         model.Name      = name;
         model.CanDelete = Token != null && Token.IsAdmin ||
                           RepositoryService.CanWriteRepository(owner, name, Token == null ? null : Token.Username);
         return(View(model));
     }
 }
Exemplo n.º 2
0
 public ActionResult Tags(string name)
 {
     using (var git = new GitService(name))
     {
         var model = git.GetTags();
         if (model == null)
         {
             throw new HttpException((int)HttpStatusCode.NotFound, string.Empty);
         }
         model.RepositoryName = name;
         model.CanDelete      = Token != null && Token.IsSystemAdministrator ||
                                RepositoryService.CanWriteRepository(name, Token == null ? null : Token.Username);
         return(View(model));
     }
 }
Exemplo n.º 3
0
        private void CommandOpened(object sender, SessionRequestedArgs e)
        {
            var match   = RegexParseCommand.Match(e.CommandText);
            var command = match.Groups["cmd"].Value;
            var project = match.Groups["proj"].Value;

            if (string.IsNullOrWhiteSpace(command) || string.IsNullOrWhiteSpace(project))
            {
                throw new SshConnectionException("Unexpected command.", DisconnectReason.ByApplication);
            }

            var requireWrite = command == "git-receive-pack";
            var fingerprint  = e.AttachedUserauthArgs.Fingerprint;
            var key          = Convert.ToBase64String(e.AttachedUserauthArgs.Key);
            var allow        = requireWrite
                ? _repositoryService.CanWriteRepository(project, fingerprint, key)
                : _repositoryService.CanReadRepository(project, fingerprint, key);

            if (!allow)
            {
                throw new SshConnectionException("Access denied.", DisconnectReason.ByApplication);
            }

            e.Channel.DataReceived  += DataReceived;
            e.Channel.EofReceived   += EofReceived;
            e.Channel.CloseReceived += CloseReceived;
            _channel = e.Channel;

            StartProcess(command, project);
        }