Commit Graph
120 Commits
Author SHA1 Message Date
Valery Sizov 8b18449125 remove public field from namespace and refactoring 2016-01-04 16:00:29 +02:00
Jason Lee 03a40a7ee1 Avoid allocations in Ability class.
It won't change anything after they are first invoke, so add method cache to avoid allocations and avoid GC.

Benchmarks:

```
Calculating -------------------------------------
project_guest_rules without method cache
                        79.352k i/100ms
project_guest_rules with method cache
                        93.634k i/100ms
-------------------------------------------------
project_guest_rules without method cache
                          2.865M (±32.5%) i/s -     11.982M
project_guest_rules with method cache
                          4.419M (± 7.4%) i/s -     22.004M

Comparison:
project_guest_rules with method cache:  4418908.0 i/s
project_guest_rules without method cache:  2864514.0 i/s - 1.54x slower

Calculating -------------------------------------
project_report_rules without method cache
                        53.126k i/100ms
project_report_rules with method cache
                        97.473k i/100ms
-------------------------------------------------
project_report_rules without method cache
                          1.093M (±36.5%) i/s -      4.675M
project_report_rules with method cache
                          4.420M (± 7.2%) i/s -     22.029M
Comparison:
project_report_rules with method cache:  4420054.3 i/s
project_report_rules without method cache:  1092509.6 i/s - 4.05x slower
```

https://gist.github.com/huacnlee/b04788ae6df42fe769e4
2015-12-16 11:51:37 +08:00
Douglas Barbosa Alexandre 67cc6b0642 Signed in admin should be able to add/remove himself to a project 2015-12-01 20:53:43 -02:00
Douglas Barbosa Alexandre 9ab7bdf773 Signed in admin should be able to add/remove himself to a group 2015-12-01 20:53:43 -02:00
Robert Speicher 56476f1847 Merge branch 'dbalexandre/gitlab-ce-fix-personal-snippet-access-workflow' into 'master'
Improve personal snippet access workflow.

Replaces !1709

Fixes #3258

See merge request !1817
2015-11-19 17:22:20 +00:00
Robert Speicher 08dc38223e Rename not_auth_* ability methods to anonymous_* 2015-11-17 15:00:14 -05:00
Douwe Maan 756d61562b Minor refactoring 2015-11-17 16:24:02 +01:00
Douwe Maan 16438ad205 Merge branch 'master' into dbalexandre/gitlab-ce-fix-personal-snippet-access-workflow 2015-11-17 16:19:16 +01:00
Douwe Maan ecb83afabc Refactor ability changes 2015-11-17 15:49:37 +01:00
Douwe Maan e849b51cae Merge branch 'master' into james11/gitlab-ce-removable-group-owner 2015-11-17 15:40:54 +01:00
Dmitriy Zaporozhets 929ab909c8 Group masters should be able to create/close milestones
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-11-16 16:14:19 +01:00
James Lopez 77dd561796 fixing rubocop indents 2015-11-12 08:43:30 +00:00
James Lopez c6a0f109cd refactored code as projects only have one owner. Kept some refactoring in place (has_owners concern) 2015-11-11 15:42:27 +00:00
Kamil Trzcinski d0e3e823a2 Implement Build Artifacts
- Offloads uploading to GitLab Workhorse
- Use /authorize request for fast uploading
- Added backup recipes for artifacts
- Support download acceleration using X-Sendfile
2015-11-10 12:51:50 +01:00
James Lopez 1b14bc5957 refactored permissions and added update_project_member ability logic. Also refactored owner methods to a concern. 2015-11-03 11:11:56 +00:00
Douglas Barbosa Alexandre 091979bd1b Fix ability name for public or internal personal snippets 2015-11-02 14:04:45 -02:00
Douglas Barbosa Alexandre c8fe421512 Improve personal snippet access workflow. Fixes #3258 2015-10-29 18:42:29 -02:00
Han Loong Liauw 02e8beaa0b Merge branch 'master' into remove-forks-from-projects-settings 2015-10-17 09:32:31 +11:00
Kamil Trzcinski a957eca6f3 Added builds view 2015-10-14 17:28:38 +02:00
Han Loong Liauw df99ddbba1 Adds ability to remove the forked relationship
This was previously possible through the API but can now be done
through the project#edit settings screen if the current user is
the owner of the project.
Update changelog
2015-10-13 21:42:17 +11:00
Kamil Trzcinski 914cfbd2f1 Implement Commit Status API 2015-10-12 11:53:49 +02:00
Valery Sizov 44261a5d9f integration with gitlab auth 2015-09-09 17:36:01 +03:00
Douwe Maan f9bcb9632c Add specific ability for managing group members 2015-07-28 16:32:15 +02:00
Robert Speicher 31dc5e7034 Add admin_merge_request ability to Developer level and up
This was necessary because this permission is checked dynamically by
`app/views/shared/issuable/_context` when on a Merge Request.

Closes #2058
2015-07-24 14:57:38 -04:00
Stan Hu 996ad35bed Merge branch 'fix-disabled-feature-access' into 'master'
Fix (i.e. prevent) access to disabled features for unauthenticated users

Unauthenticated users had access to disabled features of public
projects. The code has been slightly refactored so that feature checks
are done in a separate method and can also be applied for public access.

See merge request !1006
2015-07-20 16:42:07 +00:00
Daniel Gerhardt 4a0e4c857f Fix access to disabled features for unauthenticated users
Unauthenticated users had access to disabled features of public
projects. The code has been slightly refactored so that feature checks
are done in a separate method and can also be applied for public access.
2015-07-20 09:45:24 +02:00
Daniel Gerhardt 69417d36b2 Fix label read access for unauthenticated users
The label page was added to navigation for unauthorized users because
the previously used milestone read permission was still checked. This
has been fixed and read access to labels is now granted (again) for
public projects.

This regression has been introduced in
07efb17e10 (7.12).

See also 9bcd36396b.

Refs !836, !842.
2015-07-19 21:33:21 +02:00
Dmitriy Zaporozhets a5b54f919a Reporter role can manage issue tracker now
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-30 13:33:02 +02:00
Dmitriy Zaporozhets 7ca017b513 Refactor issue, mr, note abilities to include project abilities too
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-26 18:15:36 +02:00
Dmitriy Zaporozhets 083d4604c4 Change dynamic abilities to new format
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-26 17:18:40 +02:00
Dmitriy Zaporozhets 342d553709 Rename abilities to correspond contoller/model action names
write_ was renamed to create_
modify_  was renamed to update_

So now in update action we have next code

def create
  can?(current_user, :create_issue, @issue)
end

def update
  can?(current_user, :update_issue, @issue)
end

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-26 15:55:56 +02:00
Dmitriy Zaporozhets d5947ada44 Simplify set of assignee, milestone and label to admin_issue rule
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-26 15:45:45 +02:00
Dmitriy Zaporozhets d315d1eba4 Dont allow guest to set assigne, milestone and label when create new issue or merge request
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-25 15:38:04 +02:00
Stan Hu e785b9d2e2 Fix Error 500 when one user attempts to access a personal, internal snippet
Closes #1815
2015-06-19 21:23:46 -07:00
Stan Hu 07efb17e10 Fix 403 Access Denied error messages when accessing Labels section in a project that has MRs disabled but issues enabled
Closes #1813
2015-06-18 03:15:05 -07:00
Stan Hu ab88b7da19 Fix project snippets button appearing when it is disabled
Closes #1705
2015-05-27 05:07:44 -07:00
Stan Hu 9bcd36396b Refactor permission checks to use can? instead of issues_enabled and merge_requests_enabled 2015-05-25 16:51:04 -07:00
Stan Hu a7d8a7bd3d Disable "New Issue" and "New Merge Request" buttons when features are disabled in project settings
Closes #1676
2015-05-25 06:16:33 -04:00
Douwe Maan ff3caad4ca Rename manage_group ability to admin_group for consistency with project. 2015-04-14 12:05:49 +02:00
Dmitriy Zaporozhets 648f38cd98 Merge branch 'fix-restricted-visibility' into 'master'
Restricted visibility levels - bug fix and new feature

This allows admin users to override restricted visibility settings when creating and updating projects and snippets, and moves the restricted visibility configuration from gitlab.yml to the web UI.  See #1903.

## Move configuration location

I added a new section to the application settings page for restricted visibility levels.  Each level has a checkbox, styled with Bootstrap to look like a toggle button.  A checked box means that the level is restricted.  I added a glowing text shadow and changed the background color for checked buttons because the default styles made it hard to distinguish between checked and unchecked.  This image shows the new section with the "Public" box checked:

![restricted_visibility_settings](https://dev.gitlab.org/Okada/gitlabhq/uploads/629562e4313f89b795e81c3bb0f95893/restricted_visibility_settings.png)

## Allow admins to override

To allow admin users to override the restricted visibility levels, I had to remove the `visibility_level` validation from the `Project` class.  The model doesn't know about the `current_user`, which should determine whether the restrictions can be overridden.  We could use the creator in the validation, but that wouldn't work correctly for projects where a non-admin user is the creator and an admin tries to change the project to a restricted visibility level.

The `Project::UpdateService` and `Project::CreateService` classes already had code to determine whether the current user is allowed to use a given visibility level; now all visibility level validation is done in those classes.  Currently, when a non-admin tries to create or update a project using a restricted level, these classes silently set the visibility level to the global default (create) or the project's existing value (update).  I changed this behavior to be more like an Active Model validation, where using a restricted level causes the entire request to be rejected.

Project and personal snippets didn't have service classes, and restricted visibility levels weren't being enforced in the model or the controllers.  The UI disabled radio buttons for restricted levels, but that wouldn't be difficult to circumvent.  I created the `CreateSnippetService` and `UpdateSnippetService` classes to do the same restricted visibility check that the project classes do.  And since I was dealing with snippet visibility levels, I updated the API endpoints for project snippets to allow users to set and update the visibility level.

## TODO

* [x] Add more tests for restricted visibility functionality

cc @sytse @dzaporozhets

See merge request !1655
2015-03-16 17:49:46 +00:00
Douwe Maan 31fc73f0a9 Use project_member instead of team_member. 2015-03-15 13:50:38 +01:00
Douwe Maan 99f995755e Use group_member instead of users_group or membership. 2015-03-15 13:49:41 +01:00
Vinnie Okada 5710c1aaf8 Update snippet authorization
Allow authors and admins to update the visibility level of personal and
project snippets.
2015-03-14 10:30:48 -06:00
Ciro Santilli 33c9f05c6b Append in place for strings and arrays 2015-01-01 21:12:00 +01:00
Ciro Santilli b66a152735 Factor abilities methods
in app controller, user model and services.
2014-10-19 11:12:39 +02:00
Ciro Santilli 2e9f5de868 Add parenthesis to function def with arguments. 2014-10-03 09:18:46 +02:00
Dmitriy Zaporozhets c69b8e0459 Huge replace of old users_project and users_group references
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-14 19:32:51 +03:00
Dmitriy Zaporozhets 593df8e69a Improve labels
* allow developers to manage labels
* add ability to remove label

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-07-30 15:15:39 +03:00
Dmitriy Zaporozhets 048a21974e Add create/update to Labels controller
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-07-30 13:12:11 +03:00
Dmitriy Zaporozhets 2099aa38b6 Merge pull request #7131 from skv-headless/per_request_rules_caching
per request project rules caching
2014-07-14 13:58:53 +03:00