summaryrefslogtreecommitdiff
path: root/lib/api/api_guard.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add latest changes from gitlab-org/gitlab@13-0-stable-eeGitLab Bot2020-05-201-2/+7
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2020-04-011-0/+4
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2020-03-021-19/+9
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2019-12-111-2/+4
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2019-12-101-1/+3
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2019-09-261-0/+24
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2019-09-131-0/+1
|
* Add config to disable impersonationImre Farkas2018-11-291-0/+6
| | | | | | | | Adds gitlab.impersonation_enabled config option defaulting to true to keep the current default behaviour. Only the act of impersonation is modified, impersonation token management is not affected.
* Enable frozen string in lib/api and lib/backupgfyoung2018-09-291-0/+2
| | | | | | | | | | Partially addresses #47424. Had to make changes to spec files because stubbing methods on frozen objects is a mess in RSpec and leads to failures: https://github.com/rspec/rspec-mocks/issues/1190
* Updates code using class_methods over module ClassMethodsJacopo2018-08-291-1/+1
|
* Block access to API & git when terms are enforcedBob Van Landuyt2018-05-101-1/+11
| | | | | | When terms are enforced, but the user has not accepted the terms access to the API & git is rejected with a message directing the user to the web app to accept the terms.
* Make find_user_from_sources extensible for EELin Jen-Shin2018-02-051-1/+5
|
* Changes after rebaseFrancisco Lopez2017-11-171-20/+1
|
* Moved Exceptions to Gitlab::AuthFrancisco Lopez2017-11-171-10/+10
|
* Moving exceptions to UserAuthFindersFrancisco Lopez2017-11-171-25/+10
|
* Added some more commentsFrancisco Lopez2017-11-171-7/+8
|
* Homogenising the type of the request handled by UserAuthFinder. Also tests fixedFrancisco Lopez2017-11-171-3/+0
|
* Applied some code review commentsFrancisco Lopez2017-11-171-5/+0
|
* Removing private tokenFrancisco Lopez2017-11-171-6/+1
|
* Some fixes after rebaseFrancisco Lopez2017-11-171-24/+7
|
* Updated refactor and pushing to see if test failsFrancisco Lopez2017-11-171-2/+0
|
* First refactorFrancisco Lopez2017-11-171-39/+19
|
* Add Gitlab::Utils::StrongMemoizeLin Jen-Shin (godfat)2017-11-131-3/+5
|
* Add sudo API scopeDouwe Maan2017-11-021-66/+38
|
* Remove authentication using user.private_tokenDouwe Maan2017-11-021-16/+6
|
* Move all API authentication code to APIGuardDouwe Maan2017-10-121-41/+92
|
* Make sure API responds with 401 when invalid authentication info is provideddm-api-unauthorizedDouwe Maan2017-09-281-6/+18
|
* Whitelist or fix additional `Gitlab/PublicSend` cop violationsrs-more-public-send-whitelistsRobert Speicher2017-08-141-1/+1
| | | | | An upcoming update to rubocop-gitlab-security added additional violations.
* Extract a `Gitlab::Scope` class.Timothy Andrew2017-06-291-1/+1
| | | | | - To represent an authorization scope, such as `api` or `read_user` - This is a better abstraction than the hash we were previously using.
* Implement review comments from @DouweM for !12300.Timothy Andrew2017-06-281-1/+1
| | | | | | | - Use a struct for scopes, so we can call `scope.if` instead of `scope[:if]` - Refactor the "remove scopes whose :if condition returns false" logic to use a `select` rather than a `reject`.
* Implement review comments from @dbalexandre for !12300.Timothy Andrew2017-06-281-7/+5
|
* Fix remaining spec failures for !12300.Timothy Andrew2017-06-281-2/+2
| | | | | | | | | | | | | | 1. Get the spec for `lib/gitlab/auth.rb` passing. - Make the `request` argument to `AccessTokenValidationService` optional - `auth.rb` doesn't need to pass in a request. - Pass in scopes in the format `[{ name: 'api' }]` rather than `['api']`, which is what `AccessTokenValidationService` now expects. 2. Get the spec for `API::V3::Users` passing 2. Get the spec for `AccessTokenValidationService` passing
* When verifying scopes, manually include scopes from `API::API`.Timothy Andrew2017-06-281-6/+4
| | | | | | | | - They are not included automatically since `API::Users` does not inherit from `API::API`, as I initially assumed. - Scopes declared in `API::API` are considered global (to the API), and need to be included in all cases.
* Allow API scope declarations to be applied conditionally.Timothy Andrew2017-06-281-2/+2
| | | | | | | | | | | - Scope declarations of the form: allow_access_with_scope :read_user, if: -> (request) { request.get? } will only apply for `GET` requests - Add a negative test to a `POST` endpoint in the `users` API to test this. Also test for this case in the `AccessTokenValidationService` unit tests.
* Initial attempt at refactoring API scope declarations.Timothy Andrew2017-06-281-12/+21
| | | | | | | | | | - Declaring an endpoint's scopes in a `before` block has proved to be unreliable. For example, if we're accessing the `API::Users` endpoint - code in a `before` block in `API::API` wouldn't be able to see the scopes set in `API::Users` since the `API::API` `before` block runs first. - This commit moves these declarations to the class level, since they don't need to change once set.
* Enable Style/Proc cop for rubocopmhasbini2017-04-021-1/+1
|
* Enable and autocorrect the CustomErrorClass copSean McGivern2017-03-011-7/+4
|
* Fix code for copsDouwe Maan2017-02-231-1/+1
|
* Enable Style/SpaceInsideBracketsDouwe Maan2017-02-231-1/+1
|
* Enable Style/MutableConstantDouwe Maan2017-02-231-1/+1
|
* Convert AccessTokenValidationService into a class.Timothy Andrew2016-12-161-2/+2
| | | | | | | | | | - Previously, AccessTokenValidationService was a module, and all its public methods accepted a token. It makes sense to convert it to a class which accepts a token during initialization. - Also rename the `sufficient_scope?` method to `include_any_scope?` - Based on feedback from @rymai
* Implement minor changes from @dbalexandre's review.Timothy Andrew2016-12-161-11/+15
| | | | | | | | | | | - Mainly whitespace changes. - Require the migration adding the `scope` column to the `personal_access_tokens` table to have downtime, since API calls will fail if the new code is in place, but the migration hasn't run. - Minor refactoring - load `@scopes` in a `before_action`, since we're doing it in three different places.
* Calls to the API are checked for scope.Timothy Andrew2016-12-161-17/+45
| | | | | | | | | | | | | | - Move the `Oauth2::AccessTokenValidationService` class to `AccessTokenValidationService`, since it is now being used for personal access token validation as well. - Each API endpoint declares the scopes it accepts (if any). Currently, the top level API module declares the `api` scope, and the `Users` API module declares the `read_user` scope (for GET requests). - Move the `find_user_by_private_token` from the API `Helpers` module to the `APIGuard` module, to avoid littering `Helpers` with more auth-related methods to support `find_user_by_private_token`
* Remove some dead code from the Grape APINick Thomas2016-09-191-43/+13
| | | | | | The `guard_all!` method is never called, and `guard!` is not implemented. The `doorkeeper_guard!` method is also never called, and is mostly the same as its non-bang counterpart.
* Fix a few places where autoloading would failRémy Coutable2016-05-101-133/+137
| | | | | | | | | | | - Fix naming of API::CommitStatuses - Ensure we use require_dependency instead of require - Ensure the namespace is right in lib/api/api.rb, otherwise, we might require Grape::API::Helpers which defines the `#params` method. This is to avoid requiring a file multiple times and getting an "Already initialized constant" error. Signed-off-by: Rémy Coutable <remy@rymai.me>
* Rubocop: Style/CaseIndentation enabledDmitriy Zaporozhets2015-02-021-5/+2
|
* Avoid using {...} for multi-line blocksDmitriy Zaporozhets2015-02-021-2/+2
|
* Rubocop enabled for: Use spaces inside hash literal bracesDmitriy Zaporozhets2015-02-021-1/+1
|
* Convert hashes to ruby 1.9 styleDmitriy Zaporozhets2015-02-021-2/+2
|
* Doorkeeper integrationValery Sizov2014-12-241-0/+175