Skip to content
Snippets Groups Projects
  1. Oct 12, 2017
  2. Sep 28, 2017
  3. Aug 14, 2017
  4. Jun 29, 2017
  5. Jun 28, 2017
    • Timothy Andrew's avatar
      Implement review comments from @DouweM for !12300. · c1fcd730
      Timothy Andrew authored
      - 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`.
      c1fcd730
    • Timothy Andrew's avatar
    • Timothy Andrew's avatar
      Fix remaining spec failures for !12300. · 1b8223dd
      Timothy Andrew authored
      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
      1b8223dd
    • Timothy Andrew's avatar
      When verifying scopes, manually include scopes from `API::API`. · d774825f
      Timothy Andrew authored
      - 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.
      d774825f
    • Timothy Andrew's avatar
      Allow API scope declarations to be applied conditionally. · 80c1ebaa
      Timothy Andrew authored
      - 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.
      80c1ebaa
    • Timothy Andrew's avatar
      Initial attempt at refactoring API scope declarations. · 6f192250
      Timothy Andrew authored
      - 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.
      6f192250
  6. Apr 02, 2017
  7. Mar 01, 2017
  8. Feb 23, 2017
  9. Dec 16, 2016
    • Timothy Andrew's avatar
      Convert AccessTokenValidationService into a class. · b303948f
      Timothy Andrew authored
      - 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
      b303948f
    • Timothy Andrew's avatar
      Implement minor changes from @dbalexandre's review. · 4d6da770
      Timothy Andrew authored
      - 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.
      4d6da770
    • Timothy Andrew's avatar
      Calls to the API are checked for scope. · 7fa06ed5
      Timothy Andrew authored
      - 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`
      7fa06ed5
  10. Sep 19, 2016
    • Nick Thomas's avatar
      Remove some dead code from the Grape API · 5db3bc64
      Nick Thomas authored
      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.
      5db3bc64
  11. Jun 03, 2016
  12. May 10, 2016
    • Rémy Coutable's avatar
      Fix a few places where autoloading would fail · 5589dcf8
      Rémy Coutable authored
      
      - 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: default avatarRémy Coutable <remy@rymai.me>
      5589dcf8
  13. May 09, 2016
  14. Apr 29, 2016
  15. Apr 18, 2016
  16. Feb 03, 2015
  17. Dec 24, 2014
Loading