Commit Graph

68 Commits

Author SHA1 Message Date
Vincent Wong b6df93a51f Record and show last used date of SSH Keys
Addresses: Issue #13810

1. Adds a last_used_at attribute to the Key table/model
2. Update a key's last_used_at whenever it gets used
3. Display how long ago an ssh key was last used
2017-01-09 04:15:39 +11:00
Timothy Andrew f82d549d26 Accept environment variables from the `pre-receive` script.
1. Starting version 2.11, git changed the way the pre-receive flow works.

  - Previously, the new potential objects would be added to the main repo. If the
    pre-receive passes, the new objects stay in the repo but are linked up. If
    the pre-receive fails, the new objects stay orphaned in the repo, and are
    cleaned up during the next `git gc`.

  - In 2.11, the new potential objects are added to a temporary "alternate object
    directory", that git creates for this purpose. If the pre-receive passes, the
    objects from the alternate object directory are migrated to the main repo. If
    the pre-receive fails the alternate object directory is simply deleted.

2. In our workflow, the pre-recieve script (in `gitlab-shell) calls the
   `/allowed` endpoint, which calls out directly to git to perform
   various checks. These direct calls to git do _not_ have the necessary
   environment variables set which allow access to the "alternate object
   directory" (explained above). Therefore these calls to git are not able to
   access any of the new potential objects to be added during this push.

3. We fix this by accepting the relevant environment variables
   (GIT_ALTERNATE_OBJECT_DIRECTORIES, GIT_OBJECT_DIRECTORY) on the
   `/allowed` endpoint, and then include these environment variables while
   calling out to git.

4. This commit includes (whitelisted) these environment variables while making
   the "force push" check. A `Gitlab::Git::RevList` module is extracted to
   prevent `ForcePush` from being littered with these checks.
2016-12-16 23:32:25 +05:30
Nick Thomas 1c994dbc05 Fix POST /internal/allowed to cope with gitlab-shell v4.0.0 project paths
gitlab-shell v3.6.6 would give project paths like so:

* namespace/project

gitlab-shell v4.0.0 can give project paths like so:

* /namespace1/namespace2/project
* /namespace/project
* /path/to/repository/storage/namespace1/namespace2/project
* /path/to/repository/storage/namespace/project
2016-11-16 14:30:56 +00:00
Dmitriy Zaporozhets 440604ad1b
Refactor storage path extraction from full repo path
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-28 15:55:55 +03:00
Dmitriy Zaporozhets 3095ac0ca4 Make internal api work with full repo path instead of name
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-27 16:54:48 +03:00
Patricio Cano 2772109ac1 Handle LFS token creation and retrieval in the same method, and in the same Redis connection.
Reset expiry time of token, if token is retrieved again before it expires.
2016-09-28 12:13:48 -05:00
Kamil Trzcinski 3c1bb3432b Revert "Revert all changes introduced by https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6043"
This reverts commit 6d43c95b70.
2016-09-19 16:34:32 +02:00
Kamil Trzcinski 6d43c95b70 Revert all changes introduced by https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6043 2016-09-19 13:45:28 +02:00
Kamil Trzcinski e941365f3b Rename capabilities to authentication_abilities 2016-09-16 11:12:21 +02:00
Kamil Trzcinski 83b643a014 Merge remote-tracking branch 'origin/lfs-support-for-ssh' into per-build-token
# Conflicts:
#	app/controllers/projects/git_http_client_controller.rb
#	app/helpers/lfs_helper.rb
#	lib/gitlab/auth.rb
#	spec/requests/lfs_http_spec.rb
2016-09-15 21:16:38 +02:00
Patricio Cano c144db2935 Better authentication handling, syntax fixes and better actor handling for LFS Tokens 2016-09-15 12:21:00 -05:00
Patricio Cano c25630ee2c Refactored handling of the `LfsToken` and added functionality to it to simplify external code. 2016-09-15 12:21:00 -05:00
Patricio Cano 48f1a61fd5 Refactored LFS auth logic when using SSH to use its own API endpoint `/lfs_authenticate` and added tests. 2016-09-15 12:21:00 -05:00
Patricio Cano cb85cf1f0a Refactor LFS token logic to use a Redis key instead of a DB field, making it a 1 use only token. 2016-09-15 12:21:00 -05:00
Patricio Cano e40e3fdc82 Added LFS support to SSH
- Required on the GitLab Rails side is mostly authentication and API related.
2016-09-15 12:21:00 -05:00
Kamil Trzcinski 9d1ccd2ad3 Fix existing authorization specs 2016-09-15 13:49:11 +02:00
Kamil Trzcinski 11f87700e8 Add access specs 2016-09-15 11:57:09 +02:00
Drew Blessing 8b6154c145 Minor edits to two_factor_recovery_codes API error catching 2016-08-31 19:41:55 -05:00
Drew Blessing bba8577351 Add two factor recovery endpoint to internal API 2016-08-24 17:50:57 -05:00
Scott Le 6109daf480 api for generating new merge request
DRY code + fix rubocop

Add more test cases

Append to changelog

DRY changes list

find_url service for merge_requests

use GET for getting merge request links

remove files

rename to get_url_service

reduce loop

add test case for cross project

refactor tiny thing

update changelog
2016-08-11 23:37:00 +07:00
Alejandro Rodríguez e94d3834c7 Fix a bug where the project's repository path was returned instead of the wiki path 2016-07-15 21:31:26 -04:00
Patricio Cano 7735ef86f0 Only allow Git Access on the allowed protocol 2016-07-05 16:54:22 -05:00
Alejandro Rodríguez 86359ec854 Refactor repository paths handling to allow multiple git mount points 2016-06-29 22:30:31 -04:00
Paco Guzman 11f37a9302 Remove explicit Gitlab::Metrics.action assignments, are already automatic. 2016-06-18 07:33:50 +02:00
Yorick Peterse a257d117a0
Fix setting of "action" for Grape transactions
Merely setting the "action" tag will only result in the transaction
itself containing a value for this tag. To ensure other metrics also
contain this tag we must set the action using Transaction#action=
instead.
2016-04-20 22:42:52 +02:00
Yorick Peterse b9698d2b45
Add "action" tag to /internal/allowed API
This allows us to re-use any other analytics that rely on the "action"
tag having a value set.
2016-04-18 17:44:24 +02:00
James Lopez c401e8338b updated internal.rb and spec based on MR feedback 2016-02-26 10:40:30 +01:00
James Lopez d377948931 fix for projects ending in .wiki 2016-02-24 15:54:36 +01:00
Douwe Maan 1f72c387c9 Improve Git access error messages. 2015-05-13 09:41:55 +02:00
Douwe Maan 4745424bd3 Respond with full GitAccess error if user has project read access. 2015-03-24 14:12:03 +01:00
Douwe Maan 4830b2be5e Refactor GitAccess to use instance variables. 2015-03-24 14:11:48 +01:00
Douwe Maan dd37a10df4 Don't leak information about private project existence via Git-over-SSH/HTTP. 2015-03-02 17:52:48 +01:00
Dmitriy Zaporozhets 558dd81197 Improve broadcast message API 2015-02-18 14:58:20 -08:00
Dmitriy Zaporozhets 833d4dddf2 Dont send 404 if no broadcast messages now because it flood gitlab-shell logs with 404 errors :( 2015-02-18 14:34:05 -08:00
Douwe Maan 42422dcc6a Add internal broadcast message API. 2015-02-07 16:41:30 +01:00
Dmitriy Zaporozhets da884aabc7 Avoid using {...} for multi-line blocks 2015-02-02 21:22:57 -08:00
Ciro Santilli cd688a6011 Replace regex methods by string ones since faster
and more readable.
2014-12-28 23:53:27 +01:00
Dmitriy Zaporozhets 612b8806dd
Fix internal API for missing project or key
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-01 16:55:33 +02:00
Valery Sizov 53bf52f191 Better message for failed pushes because of git hooks
Conflicts:
	lib/gitlab/git_access.rb
	spec/lib/gitlab/git_access_spec.rb
2014-11-18 13:10:07 +02:00
Valery Sizov b5763e91cd add gitlab-shell identification 2014-10-15 20:03:25 +03:00
Dmitriy Zaporozhets 06c91aa20e
Improve wiki path parsing in internal api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-10-07 17:28:55 +03:00
Dmitriy Zaporozhets 0bf99f6557
Developers can push to wiki repo. Protected branches does not affect wiki repo any more
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-10-07 16:05:24 +03:00
Dmitriy Zaporozhets cf53b361b9
Make sure /api/allowed return 200 status code
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-03 13:33:44 +03:00
Dmitriy Zaporozhets 0a7dea29aa
/api/allowed use POST now
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-03 09:06:16 +03:00
Dmitriy Zaporozhets 0306a4e2e4
Rewrite GitAccess for gitlab-shell v2
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-01 19:57:25 +03:00
Dmitriy Zaporozhets ae564c97d4
Dont expose user email via API
To prevent leaking of users info we reduce amount of user information
retrieved via API for normal users.

What user can get via API:

* if not admin: only id, state, name, username and avatar_url
* if admin: all user information
* about himself: all informaion

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-06-13 17:46:48 +03:00
Steven Thonus 8b35b20837 first setup to protect protected branched to force updates 2014-03-25 22:33:14 +01:00
Dmitriy Zaporozhets f18a714f35 Use GitAccess in internal api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-03-20 10:16:17 +02:00
Dmitriy Zaporozhets b1ff8e31b1
Add ldap check in application_controller and internal api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-03-10 17:10:23 +02:00
Jurnell Cockhren e2e900a338 In the case when a user can and has authenticated with ldap, however
ldap is disabled in the gitlab config, this fixes the API still calling
the ldap backend.
2014-01-28 15:10:36 -06:00