summaryrefslogtreecommitdiff
path: root/app/services/access_token_validation_service.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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 apps/uploaders/*.rbgfyoung2018-07-161-0/+2
| | | | Partially addresses #47424.
* Add sudo API scopeDouwe Maan2017-11-021-5/+2
|
* `AccessTokenValidationService` accepts `String` or `API::Scope` scopes.Timothy Andrew2017-06-301-1/+8
| | | | | - There's no need to use `API::Scope` for scopes that don't have `if` conditions, such as in `lib/gitlab/auth.rb`.
* Extract a `Gitlab::Scope` class.Timothy Andrew2017-06-291-9/+8
| | | | | - 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-2/+2
| | | | | | | - 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`.
* Fix remaining spec failures for !12300.Timothy Andrew2017-06-281-1/+1
| | | | | | | | | | | | | | 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
* Allow API scope declarations to be applied conditionally.Timothy Andrew2017-06-281-6/+9
| | | | | | | | | | | - 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-1/+4
| | | | | | | | | | - 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.
* Don't declare constants in Struct28808-fix-top-level-constant-referencedRémy Coutable2017-02-281-1/+7
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Convert AccessTokenValidationService into a class.Timothy Andrew2016-12-161-20/+18
| | | | | | | | | | - 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
* Calls to the API are checked for scope.Timothy Andrew2016-12-161-0/+34
- 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`