509 Commits
Author SHA1 Message Date
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 ad0ca0499a Merge branch 'master' into fix-restricted-visibility
Conflicts:
	db/schema.rb
2015-03-14 10:49:11 -06:00
Vinnie Okada 9623b71a39 More restricted visibility changes
Bug fixes and new tests for the restricted visibility changes.
2015-03-10 18:36:43 -06:00
Vinnie Okada 928fc94c3d Enforce restricted visibilities for snippets
Add new service classes to create and update project and personal
snippets.  These classes are responsible for enforcing restricted
visibility settings for non-admin users.
2015-03-08 17:57:08 -06:00
Vinnie Okada 285c534185 Allow admins to override restricted visibility
Allow admins to use restricted visibility levels when creating or
updating projects.
2015-03-08 16:10:05 -06:00
Jörg Thalheim 9f089ac48c use constant-time string compare for internal api authentication
Ruby str_equal uses memcmp internally to compare String.
Memcmp is vunerable to timing attacks because it returns early
on mismatch (on most x32 platforms memcmp uses a bytewise comparision).
Devise.secure_compare implements a constant time comparision instead.
2015-03-06 20:06:26 +01:00
Dmitriy Zaporozhets 8c47a72a4e Merge branch 'project-existence-leak' into 'master'
Don't leak information about private project existence via Git-over-SSH/HTTP.

Fixes #2040 and https://gitlab.com/gitlab-org/gitlab-ce/issues/343.

Both `Grack::Auth` (used by Git-over-HTTP) and `Api::Internal /allowed` (used by gitlab-shell/Git-over-SSH) now return a generic "Not Found" error when the project exists but the user doesn't have access to it.

See merge request !1578
2015-03-03 20:05:12 +00:00
Dmitriy Zaporozhets 8348e1a9b5 Enable ParenthesesAsGroupedExpression rule 2015-03-02 18:45:28 -08:00
Douwe Maan dd37a10df4 Don't leak information about private project existence via Git-over-SSH/HTTP. 2015-03-02 17:52:48 +01:00
Jeroen van Baarsen 93bacb03e5 Merge pull request #8890 from sue445/feature/project_api_avatar_url
Expose avatar_url in projects API
2015-03-01 10:54:42 +01:00
sue445 51abeaa1bc Expose avatar_url in projects API
* Impl Project#avatar_url
* Refactor ApplicationHelper: Use Project#avatar_url
* Update changelog
2015-03-01 10:13:01 +09:00
Dmitriy Zaporozhets 0d22b75b03 Merge branch 'master' into mmonaco/gitlab-ce-api-user-noconfirm
Conflicts:
	lib/api/users.rb
2015-02-27 13:01:57 -08:00
Vinnie Okada 5f232b5687 Improve error messages when file editing fails
Give more specific errors in API responses and web UI flash messages
when a file update fails.
2015-02-22 16:01:49 -07:00
Dmitriy Zaporozhets 558dd81197 Improve broadcast message API 2015-02-18 14:58:20 -08:00
Dmitriy Zaporozhets 833d4dddf2 Dont send 404 if no broadcast messages now because it flood gitlab-shell logs with 404 errors :( 2015-02-18 14:34:05 -08:00
Dmitriy Zaporozhets 24d939afb9 Remove Group#owner_id from API since it is not used any more 2015-02-17 16:23:44 -08:00
Vinnie Okada b0dacc8eb0 Edit group members via API
Add an API endpoint to update the access level of an existing group
member.
2015-02-11 18:53:07 -07:00
Douwe Maan 42422dcc6a Add internal broadcast message API. 2015-02-07 16:41:30 +01:00
Dmitriy Zaporozhets bdfb349ff7 Refactor and improve sorting objects in API for projects, issues and merge requests 2015-02-05 22:00:54 -08:00
Dmitriy Zaporozhets 62ed1c537e Explicitly define ordering in models using default_scope 2015-02-05 14:20:55 -08:00
Dmitriy Zaporozhets fc13ea7137 Merge pull request #8712 from jvanbaarsen/add-merge-request-files-endpoint
Added a way to retrieve MR files
2015-02-04 14:46:54 -08:00
Jeroen van Baarsen b60d06eb2c Added a way to retrieve MR files
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-04 10:24:25 +01:00
Dmitriy Zaporozhets dc9bf32420 Merge pull request #8723 from jubianchi/api-groups-path
Access groups using path
2015-02-03 10:57:27 -08:00
jubianchi 4e97f26649 Acces groups with their path in API 2015-02-03 13:42:38 +01:00
Dmitriy Zaporozhets 368e9a0862 Rubocop: Style/CaseIndentation enabled 2015-02-02 21:26:40 -08:00
Dmitriy Zaporozhets da884aabc7 Avoid using {...} for multi-line blocks 2015-02-02 21:22:57 -08:00
Dmitriy Zaporozhets e890582681 Rubocop enabled for: Use spaces inside hash literal braces 2015-02-02 20:36:54 -08:00
Dmitriy Zaporozhets 4f1d1fc51b Convert hashes to ruby 1.9 style 2015-02-02 19:30:09 -08:00
Dmitriy Zaporozhets 7155507af5 Merge pull request #8609 from jubianchi/issues/6289-api-handle-error-project-repo
Handle errors on API when a project does not have a repository
2015-01-27 12:51:18 -08:00
Dmitriy Zaporozhets e49b636497 Merge branch 'feature_api_project_edit' into 'master'
API: Implement edit via API for projects

I've picked up https://github.com/gitlabhq/gitlabhq/pull/8055 fixed the few hound warnings and replaced all double quotes in the spec file where possible.

# From the original PR:

Implements edit via API for projects. Edit was part of missing features in feature request Full CRUD operations via API for projects.
http://feedback.gitlab.com/forums/176466-general/suggestions/3904506-full-crud-operations-via-api-for-projects

Feature is implemented using existing UpdateService for projects. Permission to change visibility level and name are checked in addition to check for permission to administer project.

Doesn't allow updating project namespace id, because there was existing API-method for transferring project to a group.

Documentation added to doc/api/projects.md. Uses API request PUT /projects/:id .

Tests included for:
1. Success for changing path
2. Success for changing name
3. Success for changing visibility level
4. Success for changing all other attributes
5. Success for changing name & path to existing name & path but in different namespace
6. Failure if not authenticated
7. Failure if path exists in project's namespace
8. Failure if name exists in project's namespace
9. Failure if not sufficient permission to change name
10. Failure if not sufficient permission to change visibility level
11. Failure if not sufficient permission to change other attributes

Allows updating following parameters:

* name
* path
* visibility_level
* public
* default_branch
* issues_enabled
* wiki_enabled
* snippets_enabled
* merge_requests_enabled
* description

See merge request !310
2015-01-22 23:02:50 +00:00
Mika MäenpääandHannes Rosenögger 7dd5656a5b Implement edit via API for projects 2015-01-22 16:58:01 +01:00
Hannes Rosenögger e03f1af00a Fix the test and add documentation for the "per-milestone issues API call" 2015-01-22 12:14:53 +01:00
Justin WhearandHannes Rosenögger 9d271538a8 Add per-milestone issues API call 2015-01-22 12:08:45 +01:00
Valery Sizov ab7a79bf3b developer can push to protected branches 2015-01-20 17:34:23 -08:00
jubianchi 39e54e21cb Handle errors on API when a project does not have a repository (Closes #6289) 2015-01-19 14:13:30 +01:00
Dmitriy Zaporozhets 0533ae7eec Merge pull request #8464 from dserodio/group-api-description
Add description attribute to group API (GET and POST)
2015-01-18 10:35:25 -08:00
Jeroen van Baarsen ec29ce4b02 Merge pull request #8307 from cirosantilli/project-api-comment-typo
Typo in project API events comment
2015-01-18 19:05:02 +01:00
Daniel Serodio 6ac8bb0f7c Add description attribute to group API (GET and POST) 2015-01-16 16:52:48 -02:00
Dmitriy Zaporozhets c5ba87a2fb Merge pull request #8096 from cirosantilli/regex-to-string
Replace regex methods by string ones since faster and more readable
2015-01-15 14:37:11 -08:00
Marin Jankovski 8689ce1efe Add search filter option on project api for authorized projects. 2015-01-12 11:08:53 +01:00
Marin Jankovski 8dd672776e Fix failing tests due to updates on the return messages. 2015-01-07 11:39:20 +01:00
Marin Jankovski cd0aed3d54 Add a message when unable to save an object through api. 2015-01-07 10:46:00 +01:00
Marin Jankovski 7240150c89 Forward the messages in api response. 2014-12-30 15:17:46 +01:00
Marin Jankovski ed464edabe Message for api files and groups. 2014-12-30 14:29:55 +01:00
Marin Jankovski d4b613ded7 Clearer message if adding comment to commit via api fails. 2014-12-30 14:00:07 +01:00
Marin Jankovski 7fa80b5bd0 Update branch api not found messages to 'Branch not found'. 2014-12-30 13:37:14 +01:00
Dmitriy Zaporozhets 2660e83c97 Add group filtering by name for API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-30 11:46:47 +02:00
Dmitriy Zaporozhets a9cf84e5ac Merge pull request #7675 from yglukhov/patch_notes_api
Implemented notes (body) patching in API.
2014-12-29 21:06:49 +02:00