Commit Graph

31 Commits

Author SHA1 Message Date
GitLab Bot 7d8cc770b1 Add latest changes from gitlab-org/gitlab@master 2023-03-29 03:12:19 +00:00
GitLab Bot f1284938ed Add latest changes from gitlab-org/gitlab@master 2022-05-30 12:08:23 +00:00
GitLab Bot c17eb7c970 Add latest changes from gitlab-org/gitlab@master 2022-01-20 15:11:58 +00:00
GitLab Bot 418a39f6c2 Add latest changes from gitlab-org/gitlab@master 2021-04-07 00:09:26 +00:00
GitLab Bot 93b0b77287 Add latest changes from gitlab-org/gitlab@master 2021-03-24 03:09:04 +00:00
GitLab Bot 4d16568658 Add latest changes from gitlab-org/gitlab@master 2021-03-18 06:11:52 +00:00
GitLab Bot a662b146ac Add latest changes from gitlab-org/gitlab@master 2020-11-05 12:09:05 +00:00
GitLab Bot 038366a093 Add latest changes from gitlab-org/gitlab@master 2020-10-30 15:08:59 +00:00
GitLab Bot 5ec2d1e947 Add latest changes from gitlab-org/gitlab@master 2020-10-15 03:08:35 +00:00
GitLab Bot bdca097916 Add latest changes from gitlab-org/gitlab@master 2020-08-11 03:11:00 +00:00
GitLab Bot c59765a50a Add latest changes from gitlab-org/gitlab@master 2020-06-24 18:09:03 +00:00
GitLab Bot 4279f24a19 Add latest changes from gitlab-org/gitlab@master 2020-05-06 12:09:36 +00:00
GitLab Bot 784fae4b9d Add latest changes from gitlab-org/gitlab@master 2019-12-12 12:07:33 +00:00
GitLab Bot 26121e3bcd Add latest changes from gitlab-org/gitlab@master 2019-11-24 12:06:34 +00:00
Brett Walker ec2b4bb65d Upgrade graphql gem to 1.9.10
- `edge_nodes` needs to get called on the object
- added `include GlobalID::Identification` in a couple places
- renamed `object` to `item` in spec due to conflict
2019-09-04 21:57:37 +00:00
Brett Walker aa7b1cfc5b Upgrade GraphQL gem to 1.8.17
- Due to https://github.com/exAspArk/batch-loader/pull/32,
we  changed BatchLoader.for into BatchLoader::GraphQL.for
- since our results are wrapped in a BatchLoader::GraphQL,
calling `sync` during authorization is required to get real object
- `graphql` now has it's own authorization system.  Our
`authorized?` method conflicted and required renaming
2019-09-04 17:42:48 +00:00
Brett Walker bdd5b5b695 Replace echo function with a resolver
The `GraphQL::Function` has been deprecated in
favor of resolvers.
2019-08-26 17:43:38 +00:00
Marin Jankovski c20c9e2940
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce 2019-07-03 11:55:56 +02:00
Marin Jankovski 7eae0e9b52 Merge branch 'security-bvl-enforce-graphql-type-authorization' into 'master'
Fix type authorizations in GraphQL

See merge request gitlab/gitlabhq!3170
2019-07-02 06:22:09 +00:00
Luke Duncalfe 4b9b2a43d0 GraphQL mutations for add, remove and toggle emoji
Adding new `AddAwardEmoji`, `RemoveAwardEmoji` and `ToggleAwardEmoji`
GraphQL mutations.

Adding new `#authorized_find_with_pre_checks!` and (unused, but for
completeness `#authorized_find_with_post_checks!`) authorization
methods. These allow us to perform an authorized find, and run our own
additional checks before or after the authorization runs.

https://gitlab.com/gitlab-org/gitlab-ce/issues/62826
2019-06-28 12:03:33 +12:00
Luke Duncalfe bbdcbd98ae Remove unused authorized_find method
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/29921#note_184713939
2019-06-26 10:15:14 +12:00
Luke Duncalfe b2a615c3c6 Sanity check for GraphQL authorized?
Raise an exception if a developer calls any of the GraphQL authorization
methods and a `authorize :permission` is missing from a mutation class.

Previously `authorized?` would return `true` in this situation, which
although technically is accurate is not what a developer is intending.
2019-06-26 10:12:35 +12:00
Bob Van Landuyt 967cbd0834 Enforce authorizations for non-nullable fields
This makes sure we also enforce authorizations for non-nullable
fields.

We are defining our authorizations on the unwrapped
types (Repository). But when a type like that is presented in a
non-nullable field, it's type is different (Repository!). The
non-nullable type would not have the authorization metadata.

This makes sure we check the metadata on the unwrapped type for
finding authorizations.
2019-06-21 13:00:50 +02:00
Brett Walker eff42d59bd Check for all scalar types 2019-04-22 18:57:45 -05:00
Bob Van Landuyt eca8e6f09b Only check abilities on rendered GraphQL nodes
With this we only check abilities on the rendered edges of a GraphQL
connection instead of all the nodes in it.
2019-04-18 16:17:29 +02:00
Brett Walker 6643b92b88 Use parent object when authorizing scalar types 2019-04-04 09:03:21 -05:00
Luke Duncalfe 8207f7877f GraphQL Type authorization
Enables authorizations to be defined on GraphQL Types.

    module Types
      class ProjectType < BaseObject
        authorize :read_project
      end
    end

If a field has authorizations defined on it, and the return type of the
field also has authorizations defined on it. then all of the combined
permissions in the authorizations will be checked and must pass.

Connection fields are checked by "digging" to find the type class of the
"node" field in the expected location of edges->node.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/54417
2019-04-03 14:36:33 +13:00
Luke Duncalfe ccb4edbca1 Improve GraphQL Authorization DSL
Previously GraphQL field authorization happened like this:

    class ProjectType
      field :my_field, MyFieldType do
        authorize :permission
      end
    end

This change allowed us to authorize like this instead:

    class ProjectType
      field :my_field, MyFieldType, authorize: :permission
    end

A new initializer registers the `authorize` metadata keyword on GraphQL
Schema Objects and Fields, and we can collect this data within the
context of Instrumentation like this:

    field.metadata[:authorize]

The previous functionality of authorize is still being used for
mutations, as the #authorize method here is called at during the code
that executes during the mutation, rather than when a field resolves.

https://gitlab.com/gitlab-org/gitlab-ce/issues/57828
2019-02-26 10:22:12 +13:00
Lin Jen-Shin 50491d3241 Instead of returning all or nothing, return whichever passed
And add tests
2019-02-14 15:52:17 +08:00
Lin Jen-Shin 564b86a314 Allow authorize on array of objects for GraphQL
And add tests
2019-02-14 15:52:17 +08:00
Bob Van Landuyt 3bcb04f100 Add mutation toggling WIP state of merge requests
This is mainly the setup of mutations for GraphQL. Including
authorization and basic return type-structure.
2018-07-25 18:37:12 +02:00