Commit Graph

505 Commits

Author SHA1 Message Date
James Lopez 782badd0a2
Fix content caching for non auth users 2018-10-23 16:22:12 +02:00
Jan Provaznik c6a4c9231e Use InvalidUTF8ErrorHandler only for rails 4
In Rails 5 catches invalid UTF8 characters in querystring in a
params middleware, errors are handled by a params middleware and
raises a BadRequest exception. This means that these UTF8 errors
are not raised deeper in application stack and these can't also
be handled on application level.

If we would want to have custom handler for these errors, we would
have to create a new middleware and insert it before actionpack's
params middleware and rescue BadRequest exceptions there. But there
is no need to do this currently (see discussion on
https://gitlab.com/gitlab-org/gitlab-ce/issues/51908)
2018-10-13 19:45:27 +02:00
Zeger-Jan van de Weg 30b4ce940d
Remove Git circuit breaker
Was introduced in the time that GitLab still used NFS, which is not
required anymore in most cases. By removing this, the API it calls will
return empty responses. This interface has to be removed in the next
major release, expected to be 12.0.
2018-10-10 09:08:18 +02:00
Stan Hu 7fa3180883 Remove duplicate Sentry logging for GRPC messages
Raven.capture_exception is already called by log_exception.
2018-10-07 23:30:29 -07:00
David fea4efe42f Add custom header for error responses 2018-10-01 17:43:40 +00:00
Rémy Coutable d2afddfeff
Refactor EventFilter and increase its test coverage
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-09-26 18:34:26 +02:00
Igor Kapkov 65cf805278
Allow events filter to be set in the URL in addition to cookie 2018-09-26 18:34:26 +02:00
Stan Hu 0920342094 Merge branch 'fa-handle_invalid_utf8_errors' into 'master'
Render 412 when invalid UTF-8 is passed as parameter

See merge request gitlab-org/gitlab-ce!21774
2018-09-25 16:35:10 +00:00
Felipe Artur 1fcc7f9ba2 Render 412 for invalid UTF-8 parameters
Renders 412 error page when invalid UTF-8 is passed
as parameters in controllers.
2018-09-22 12:15:53 -03:00
gfyoung 73322a0e55 Enable frozen string in app/controllers/**/*.rb
Enables frozen string for the following:

* app/controllers/*.rb
* app/controllers/admin/**/*.rb
* app/controllers/boards/**/*.rb
* app/controllers/ci/**/*.rb
* app/controllers/concerns/**/*.rb

Partially addresses #47424.
2018-09-18 21:22:45 -07:00
Jan Provaznik a415a904b8 Ask user explicitly about usage stats agreement 2018-09-07 14:32:28 +00:00
Stan Hu 93005b4e81 Add User-Agent to production_json.log
This will help production gain more visibility which browsers may be
having issues.
2018-09-05 14:43:09 -07:00
Stan Hu a7e2f96b59 Fix logins via OAuth2 geting logged out in an hour
Users without GitLab 2FA enabled would be logged out after an hour
due to a regression in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20700.

The OAuth2 controller sets the current_user after the controller is finished, so
we should only limit session times after this has been done.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/50210
2018-08-10 14:41:59 -07:00
Peter Leitzen ffcf50c872 Don't set gon variables in JSON requests 2018-08-07 21:28:57 +00:00
Tim Zallmann d737abc537 Merge branch 'sh-support-bitbucket-server-import' into 'master'
Add support for Bitbucket Server imports

Closes #25393

See merge request gitlab-org/gitlab-ce!20164
2018-08-06 17:32:12 +00:00
Grzegorz Bizon 98e9f52cf4 Improve blocked user tracking code readability 2018-08-03 12:58:00 +02:00
Grzegorz Bizon e698a22e10 Skip redunant before_logout warden events 2018-08-02 15:41:14 +02:00
Grzegorz Bizon 9c6aa0a0a6 Improve authentication events-related code readability 2018-08-01 17:08:59 +02:00
Grzegorz Bizon 4eb9d6a96f Do not implicitly authenticate user during session creation 2018-08-01 16:57:59 +02:00
Grzegorz Bizon 4bcf72e734 Improve blocked user tracking and fire some events only once 2018-08-01 14:23:06 +02:00
Stan Hu fe16ce0acb Merge branch 'master' into sh-support-bitbucket-server-import 2018-07-31 08:57:00 -07:00
Sean McGivern e6dd3c5276 Merge branch 'feature/gb/login-activity-metrics' into 'master'
Add user authentication activity metrics

Closes #47789

See merge request gitlab-org/gitlab-ce!20668
2018-07-31 10:44:22 +00:00
Grzegorz Bizon 00e4d918a3 Add authentication metrics for sessionless sign in 2018-07-27 12:56:34 +02:00
Stan Hu 930ca2d599 Merge branch 'master' into sh-support-bitbucket-server-import 2018-07-18 21:35:24 -07:00
Stan Hu c559c43daf Limit the TTL for anonymous sessions to 1 hour
By default, all sessions are given the same expiration time configured in the
session store (e.g. 1 week). However, unauthenticated users can generate a lot
of sessions, primarily for CSRF verification. It makes sense to reduce the TTL
for unauthenticated to something much lower than the default (e.g. 1 hour) to
limit Redis memory. In addition, Rails creates a new session after login,
so the short TTL doesn't even need to be extended.

Closes #48101
2018-07-18 12:39:51 -07:00
Stan Hu 2d3fd6a142 Merge branch 'master' into sh-support-bitbucket-server-import 2018-07-12 05:21:37 -07:00
Dmitriy Zaporozhets 6743147b7d Improve manifest feature after backend review
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-07-11 12:22:57 +03:00
Dmitriy Zaporozhets 98d29f6e78 Add ability to disable manifest import
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-07-11 12:22:57 +03:00
Stan Hu ebd8e4333a WIP: Add support for Bitbucket Server imports 2018-06-25 13:06:10 -07:00
blackst0ne 6fef87f17f [Rails5] Force the `protect_from_forgery` callback run first
Since Rails 5.0 the `protect_from_forgery` callback doesn't run first by
default anymore. [1]

Instead it gets inserted into callbacks chain where callbacks get
called in order.

This commit forces the callback to run first.

[1]: 3979403781
2018-06-21 21:44:31 +11:00
Bob Van Landuyt 7fe92d9981 Render access denied without message
The `errors/access_denied` page should not fail to render when no
message is provided.

When accessing something as a sessionless user, we should also display
the terms message if possible.
2018-06-13 17:03:48 +02:00
Stan Hu 5d3abdf9a7 Log response body to production_json.log when a controller responds with a 422 status
We have a number of import errors occurring with 422 errors, and
it's hard to determine why they are happening. This change will
surface the errors in the log lines.

Relates to #47365
2018-06-06 13:16:15 -07:00
Bob Van Landuyt 491e1fc905 Render a 403 when showing an access denied message
When we want to show an access denied message to a user, we don't have
to hide the resource's existence.

So in that case we render a 403, this 403 is not handled by nginx on
omnibus installs, making sure the message is visible to the user.
2018-06-05 10:29:27 +02:00
Paul Slaughter bbff2d680d Update 404 and 403 pages 2018-05-31 21:28:19 +00:00
Bob Van Landuyt a5cb2fe2e0 Allow a user to sign out when on the terms page
Before we would block the `sign_out` request when the user did not
accept the terms, therefore redirecting them to the terms again.

By allowing all request to devise controllers, we avoid this problem.
2018-05-11 08:27:43 +02:00
Bob Van Landuyt 7684217d68 Enforces terms in the web application
This enforces the terms in the web application. These cases are
specced:

- Logging in: When terms are enforced, and a user logs in that has not
  accepted the terms, they are presented with the screen. They get
  directed to their customized root path afterwards.
- Signing up: After signing up, the first screen the user is presented
  with the screen to accept the terms. After they accept they are
  directed to the dashboard.
- While a session is active:
  - For a GET: The user will be directed to the terms page first,
    after they accept the terms, they will be directed to the page
    they were going to
  - For any other request: They are directed to the terms, after they
    accept the terms, they are directed back to the page they came
    from to retry the request. Any information entered would be
    persisted in localstorage and available on the page.
2018-05-04 13:54:43 +02:00
blackst0ne 991db50f88 [Rails5] Update `ApplicationController#log_exception` to fix `undefined method 'clean'` error
This commit fixes the error:
```
  1) Projects::TodosController Merge Requests POST create when not authorized for merge_request doesn't create todo
     Failure/Error: application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace

     NoMethodError:
       undefined method `clean' for #<Hash:0x000055be5bda35d0>
       Did you mean?  clear
     # ./app/controllers/application_controller.rb:113:in `log_exception'
     # ./app/controllers/application_controller.rb:40:in `block in <class:ApplicationController>'
     # ./spec/controllers/projects/todos_controller_spec.rb:80:in `go'
     # ./spec/controllers/projects/todos_controller_spec.rb:138:in `block (6 levels) in <top (required)>'
     # ./spec/controllers/projects/todos_controller_spec.rb:138:in `block (5 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # ActiveRecord::RecordNotFound:
     #   Couldn't find MergeRequest
     #   ./app/finders/concerns/finder_methods.rb:19:in `raise_not_found_unless_authorized'

Finished in 7.53 seconds (files took 12.8 seconds to load)
1 example, 1 failure
```

Also see 6d85804bc6
2018-04-28 20:01:31 +11:00
blackst0ne eddf3febd7 [Rails5] Add `safe_params` helper
Rails 5.0 requires to explicitly permit attributes when building a URL
using current `params` object.

The `safe_params` helper allows developers to just call `safe_params.merge(...)`
instead of manually adding `permit` to every call.

https://github.com/rails/rails/pull/20868
2018-04-08 15:35:30 +11:00
Francisco Javier López ae84eaeba7 Add better LDAP connection handling 2018-04-04 09:07:28 +00:00
Horatiu Eugen Vlad 1ad5df49b1 Moved o_auth/saml/ldap modules under gitlab/auth 2018-02-28 16:53:02 +01:00
Bob Van Landuyt 148816cd67 Port `read_cross_project` ability from EE 2018-02-22 17:11:36 +01:00
Mario de la Ossa eaada9d706 use Gitlab::UserSettings directly as a singleton instead of including/extending it 2018-02-02 18:39:55 +00:00
Stan Hu 79a829a037 Return a blank JSON response for a missing .js file to prevent Rails CSRF errors
The default 404 handler would return the Content-Type format based on the
given format extension. This would cause the Rails CSRF protection to flag an
error, since the .js extension gets mapped to text/javascript format.

Closes #40771
2018-01-23 22:24:30 -08:00
Markus Koller 257fd57134 Allow password authentication to be disabled entirely 2017-11-23 13:16:14 +00:00
Tiago Botelho 053a198846 Impersonation no longer gets stuck on password change. 2017-11-20 18:02:41 +01:00
Rémy Coutable 4f09d099e9 Merge branch '18040-rubocop-line-break-after-guard-clause' into 'master'
Adds Rubocop rule for line break after guard clause

Closes #18040

See merge request gitlab-org/gitlab-ce!15188
2017-11-20 09:22:14 +00:00
Francisco Lopez aecc3eb080 Applied some code review comments 2017-11-17 10:02:10 +01:00
Francisco Lopez 41ebd06ddc Some fixes after rebase 2017-11-17 10:01:20 +01:00
Michael Kozono 43a682ccaa Fix OAuth API and RSS rate limiting 2017-11-17 09:58:18 +01:00
Michael Kozono dc9266fbea Add request throttles 2017-11-17 09:58:18 +01:00
Jacopo 181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
Douwe Maan 294fa6fcdc Remove authentication using user.private_token 2017-11-02 11:39:02 +01:00
Toon Claes d8d7faf68c URI decode Page-Title header to preserve UTF-8 characters 2017-10-20 16:44:29 +00:00
Stan Hu 5d52bb59dc Fix username and ID not logging in production_json.log for Git activity
Devise sets `current_user`, but not all controllers authenticate users by
session tokens. Try to use the controller-defined `authenticated_user` if
`current_user` is not available.

Closes gitlab-org/gitlab-ee#3611
2017-10-04 11:47:36 -07:00
Douwe Maan 5adae3d85b Encode Page-Title header as ISO-8859-1 2017-09-26 18:05:19 +02:00
Douwe Maan 711bb28568 Add Page-Title header to tree and blob JSON endpoints 2017-09-26 17:31:47 +02:00
Tiago Botelho 37383d9a9d Rollsback changes made to signing_enabled. 2017-09-01 10:51:40 +01:00
Rémy Coutable c946ee1282
Enable the Layout/SpaceBeforeBlockBraces cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-09 11:52:22 +02:00
Bob Van Landuyt faabcbd3ae GRPC::Unavailable (< GRPC::BadStatus) is wrapped in a CommandError 2017-08-07 14:37:01 +02:00
Bob Van Landuyt 3598e60bf2 Add a Circuitbreaker for storage paths 2017-08-04 15:38:48 +02:00
Stan Hu 9bc176b2c3 Add remote IP, user ID and username to JSON lograge output
This makes the logs a bit more useful to search requests by users.
2017-07-28 00:48:03 -05:00
Robin Bobbitt 672a68d372 Fixes needed when GitLab sign-in is not enabled
When sign-in is disabled:
 - skip password expiration checks
 - prevent password reset requests
 - don’t show Password tab in User Settings
 - don’t allow login with username/password for Git over HTTP requests
 - render 404 on requests to Profiles::PasswordsController
2017-07-13 10:08:27 -04:00
Rémy Coutable 186048a404 Allow to enable the performance bar per user or Flipper group
A `performance_team` Flipper group has been created. By default this
group is nil but this can be customized in `gitlab.yml` via the
performance_bar.allowed_group setting.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-06 11:18:25 +02:00
Stan Hu 73d019e11f Log rescued exceptions to Sentry
Support noticed that a number of exceptions, such as
"Encoding::CompatibilityError (incompatible character encodings: UTF-8 and
ASCII-8BIT)", failed to report to Sentry. The `rescue_from` in the
ApplicationController prevented these exceptions from being recorded.
This change ensures that these exceptions are properly captured.
2017-07-04 14:03:46 -07:00
Pawel Chojnacki 15b7b9ec41 Add rescue_from(ActionController::UnknownFormat) in Application Controller 2017-06-20 15:53:23 +02:00
Rémy Coutable b173ae6b48 Fix linting, route, and specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-09 17:21:39 +02:00
Rémy Coutable f45094a485 Small adjustments
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-09 17:21:39 +02:00
Rémy Coutable 47054451da Don't use Pygment,rb, use Rouge instead, and put peek-pg in the :postgres group
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-09 17:21:39 +02:00
Rémy Coutable d39ecf1ca7 New performance bar that can be enabled with the `p b` shortcut
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-09 17:21:39 +02:00
Douwe Maan b3b6c78112 Merge branch '32748-emails-are-being-sent-with-the-wrong-language' into 'master'
Bugfix: Always use the default language when generating emails.

Closes #32748

See merge request !11662
2017-05-25 18:05:06 +00:00
Ruben Davila 5c921809cd Bugfix: Always use the default language when generating emails.
There was a race condition issue when the application was generating an
email and was using a language that was previously being used in other
request.
2017-05-25 10:22:45 -05:00
Alexis Reigel 6efe9c2f14 atom links with rss token instead of private token 2017-05-24 22:29:59 +02:00
Fatih Acet 0151325dac Merge request widget redesign 2017-05-09 04:15:34 +00:00
Michael Kozono 7d02bcd2e0 Redirect from redirect routes to canonical routes 2017-05-05 12:11:57 -07:00
Ruben Davila dbd1bdaeed More updates for translations plus some refactoring. 2017-05-03 21:08:43 -05:00
Ruben Davila 6d5364cfb0 First round of updates from the code review. 2017-05-02 23:36:36 -05:00
Ruben Davila bbfbcebdf6 Merge branch 'master' into 28433-internationalise-cycle-analytics-page 2017-05-02 13:20:41 -05:00
Dosuken shinya 73ac7b2dd6 Resolve "Add more tests for spec/controllers/projects/builds_controller_spec.rb" 2017-04-28 09:38:32 +00:00
Ruben Davila 1de135bc04 Fix Rubocop complains plus some small refactor 2017-04-19 23:19:24 -05:00
Ruben Davila 73d0730d09 Set locale through controller filter 2017-04-13 01:03:47 -05:00
Markus Koller 7140e09e39 Extract 2FA-related code from ApplicationController 2017-04-06 10:01:13 +02:00
Markus Koller a3430f011f Support 2FA requirement per-group 2017-04-06 10:01:13 +02:00
Markus Koller 57374feabe Move AuthHelper#two_factor_skippable? into ApplicationController 2017-04-06 10:01:13 +02:00
Rémy Coutable 8b6041bce3 Don't try to find a user by personal_access_token if the token is nil
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-03-22 17:06:19 +01:00
http://jneen.net/ 0ea04cc5bf use the policy stack to protect logins 2017-03-09 11:49:52 -08:00
http://jneen.net/ 846e581732 use a magic default :global symbol instead of nil
to make sure we mean the global permissions
2017-03-09 11:49:52 -08:00
Pawel Chojnacki 2ff139ddee Make Warden set_user hook validate user ip uniquness
+ rename shared context
2017-03-06 15:41:25 +01:00
Pawel Chojnacki 0ef8a64348 Remove unecessary calls to limit_user!, UniqueIps Middleware, and address MR review
- cleanup formating in haml
 - clarify time window is in seconds
 - cleanup straneous chunks in db/schema
 - rename count_uniqe_ips to update_and_return_ips_count
 - other
2017-03-06 15:41:25 +01:00
Paweł Chojnacki 76e96878aa Stop setting Strict-Transport-Securty header from within the app 2017-03-03 11:05:24 +00:00
Rémy Coutable b50b5a4461
Fix the redirect to custom home page URL and move it to RootController
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-02-27 16:51:23 +01:00
Douwe Maan 215228b477 Enable Performance/RedundantBlockCall 2017-02-23 09:31:57 -06:00
Douwe Maan f40716f48a No more and/or 2017-02-21 16:31:14 -06:00
Robert Speicher 191bcb4d1b Don't perform Devise trackable updates on blocked User records 2017-02-10 11:51:14 -05:00
Rémy Coutable 103114e3d7 Rename Gogs to Gitea, DRY the controller and improve views
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-19 17:35:51 +01:00
Kim "BKC" Carlbäcker 5d4531db25 Gogs Importer 2016-12-19 17:35:51 +01:00
Valery Sizov 32c6c9c457 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into bitbucket-oauth2 2016-11-30 14:53:30 +02:00
Douwe Maan a7a9db803b Merge branch 'dz-allow-nested-group-routing' into 'master'
Add nested groups support to the routing

## What does this MR do?

It allows routing with `/` in namespace name 

## Why was this MR needed?

For nested groups feature(https://gitlab.com/gitlab-org/gitlab-ce/issues/2772). We need URI like `/group/subgroup/project` be routed correctly


## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~
- ~~API support added~~
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/2772

See merge request !7459
2016-11-24 04:31:54 +00:00
Dmitriy Zaporozhets 6683fdcfb0
Add nested groups support to the routing
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-11-23 14:08:36 +02:00
Douglas Barbosa Alexandre 267e27b0cd Remove code to clone Bitbucket repositories using SSH 2016-11-21 16:47:26 -08:00
Oren Kanner 8dd9a8b6e0 Allow admins to stop impersonating users without e-mail addresses
Resolves #24576

Modify the guard clause of the `ApplicationController#require_email`
before action to skip requests where an admin is impersonating the
current user.
2016-11-17 23:28:39 -05:00
Lin Jen-Shin 5416d0e083 Pass `@ref` along so we know which pipeline to show
Closes #23615
2016-10-24 22:26:06 +08:00
Sean McGivern 86dcb79be3 Merge branch 'master' into merge-conflicts-editor-2 2016-10-17 10:56:55 +01:00
Dmitriy Zaporozhets 2b9a25bd5a
Handle unmatched routing with not_found method
We need this to prevent routing error when user access URL like /123
when there is no resource located under such name

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-15 00:36:22 +03:00
Sean McGivern 241cca011f Fix specs 2016-10-13 14:16:34 -05:00
Sean McGivern 3f71c43e88 Allow setting content for resolutions
When reading conflicts:

1. Add a `type` field. `text` works as before, and has `sections`;
   `text-editor` is a file with ambiguous conflict markers that can only
   be resolved in an editor.
2. Add a `content_path` field pointing to a JSON representation of the
   file's content for a single file.
3. Hitting `content_path` returns a similar datastructure to the `file`,
   but without the `content_path` and `sections` fields, and with a
   `content` field containing the full contents of the file (with
   conflict markers).

When writing conflicts:

1. Instead of `sections` being at the top level, they are now in a
   `files` array. This matches the read format better.
2. The `files` array contains file hashes, each of which must contain:
   a. `new_path`
   b. `old_path`
   c. EITHER `sections` (which works as before) or `content` (with the
      full content of the resolved file).
2016-10-13 14:16:34 -05:00
Clement Ho b4d614bdbc Fix inconsistent highlighting of already selected activity nav-links 2016-10-05 15:38:18 -05:00
http://jneen.net/ 5853c96b49 remove Ability.abilities 2016-08-30 11:35:06 -07:00
Z.J. van de Weg 4c8e9a8d27 Remove gitorious 2016-08-25 10:10:10 +01:00
Stan Hu 170885edd6 Add Sentry logging to API calls
Closes #21043
2016-08-24 12:09:51 -07:00
zs 84a3225b0c State specific default sort order for issuables
Provide more sensible default sort order for issues and merge requests
based on the following table:

| type           | state  | default sort order |
|----------------|--------|--------------------|
| issues         | open   | last created       |
| issues         | closed | last updated       |
| issues         | all    | last created       |
| merge requests | open   | last created       |
| merge requests | merged | last updated       |
| merge requests | closed | last updated       |
| merge requests | all    | last created       |
2016-08-01 11:28:56 +02:00
Timothy Andrew 4b33c4c6d1 Load Javascript U2F library selectively.
1. Only on supported Chrome versions

2. Mainly, this lets us simplify the javascript-based U2F check to
   `window.u2f`, where `window.u2f` can either be loaded from the GitLab
   server (for Chrome) or from the Firefox extension.

3. This is a better way to provide browser detection for U2F.
2016-07-14 08:19:09 +05:30
Rémy Coutable 654565c9dc Raise a new Gitlab::Access::AccessDeniedError when permission is not enough to destroy a member
This is a try for a new approach to put the access checks at the service level.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-18 06:06:34 +02:00
Douwe Maan 9b7fd74805 Merge branch 'feature/project-export' into 'master'
Export project functionality

This is a MR for the export functionality of https://gitlab.com/gitlab-org/gitlab-ce/issues/3050, which adds the ability to export single projects.

- [x] members
- DB data
  - [x] issues
  - [x] issue comments
  - [x] merge requests
  - [x] merge request diff
  - [x] merge request comments
  - [x] labels
  - [x] milestones
  - [x] snippets
  - [x] releases
  - [x] events
  - [x] commit statuses
  - [x] CI builds
- File system data
  - [x] Git repository
  - [x] wiki
  - [x] uploads
  - [ ] ~~CI build traces~~
  - [ ] ~~CI build artifacts~~
  - [ ] ~~LFS objects~~
- DB configuration
  - [x] services
  - [x] web hooks
  - [x] protected branches
  - [x] deploy keys
  - [x] CI variables
  - [x] CI triggers

See merge request !3114
2016-06-17 15:35:27 +00:00
Timothy Andrew 7ee0898a9e Implement @DouweM's feedback.
- Extract a duplicated `redirect_to`
- Fix a typo: "token", not "certificate"
- Have the "Expires at" datepicker be attached to a text field, not inline
- Have both private tokens and personal access tokens verified in a
  single "authenticate_from_private_token" method, both in the
  application and API. Move relevant logic to
  `User#find_by_personal_access_token`
- Remove unnecessary constants relating to API auth. We don't need a
  separate constant for personal access tokens since the param is the
  same as for private tokens.
2016-06-16 08:24:13 +05:30
Timothy Andrew d0bcba1105 Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-06-14 09:06:53 +05:30
James Lopez e83fc684a5 Merge branches 'feature/project-export-ui-experimental' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental
# Conflicts:
#	Gemfile.lock
#	app/helpers/todos_helper.rb
#	app/models/todo.rb
#	app/views/projects/edit.html.haml
#	lib/gitlab/import_export/import_service.rb
2016-06-13 14:00:19 +02:00
Timothy Andrew 1779d68bfe Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-06-09 14:40:14 +05:30
Douwe Maan 8c3ba8d6c9 Add workhorse controller and API helpers 2016-06-06 13:16:30 +02:00
Timothy Andrew 128549f10b Implement U2F registration.
- Move the `TwoFactorAuthsController`'s `new` action to `show`, since
  the page is not used to create a single "two factor auth" anymore. We
  can have a single 2FA authenticator app, along with any number of U2F
  devices, in any combination, so the page will be accessed after the
  first "two factor auth" is created.
- Add the `u2f` javascript library, which provides an API to the
  browser's U2F implementation.
- Add tests for the JS components
2016-06-06 12:50:31 +05:30
Timothy Andrew 791cc9138b Add a `U2fRegistrations` table/model.
- To hold registrations from U2F devices, and to authenticate them.
- Previously, `User#two_factor_enabled` was aliased to the
  `otp_required_for_login` column on `users`.
- This commit changes things a bit:
    - `User#two_factor_enabled` is not a method anymore
    - `User#two_factor_enabled?` checks both the
      `otp_required_for_login` column, as well as `U2fRegistration`s
    - Change all instances of `User#two_factor_enabled` to
      `User#two_factor_enabled?`
- Add the `u2f` gem, and implement registration/authentication at the
  model level.
2016-06-06 12:50:31 +05:30
Timothy Andrew 0dff6fd714 Fix rubocop spec. 2016-06-03 10:11:36 +05:30
Timothy Andrew ae0d8222af Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-06-03 09:31:16 +05:30
Robert Speicher 7d33fba7af Merge branch 'upgrade-devise-two-factor' into 'master'
Upgrade devise, devise-two-factor, and attr_encrypted

Devise 4 includes support for Rails 5, working towards #14286. devise-async doesn't support Devise 4.0 and in 4.1 the bug that was blocking using Devise's built-in ActiveJob integration was fixed. So devise-async is removed. devise-two-factor 3.0.0 is required for Devise 4 support.

attr_encrypted and encryptor are optional but recommended upgrades for devise-two-factor 3.0.0. The mode and algorithm will need to be changed in order to update to attr_encrypted 4.x in the future.

See merge request !4216
2016-06-02 00:44:41 +00:00
Timothy Andrew 6d44433176 Don't look for personal access tokens in the DB when the parameter/header is not passed. 2016-06-01 14:09:17 +05:30
Timothy Andrew 05b319b0b4 Perform private token and personal access token authentication in the same `before_action`.
- So that the check for valid personal access tokens happens only if
  private token auth fails.
2016-06-01 14:04:38 +05:30
Felipe Artur 56f3b243ce Add leading comment space cop 2016-05-31 19:33:46 -03:00
Connor Shea d47b2b92c9
Upgrade devise and devise-two-factor, remove devise-async
Devise (3.5.4 => 4.1.1) Changelog:
https://github.com/plataformatec/devise/blob/master/CHANGELOG.md

devise-two-factor (2.0.1 => 3.0.0) Changelog:
https://github.com/tinfoil/devise-two-factor/blob/master/CHANGELOG.md

These are reliant on each other, so they have to be upgraded together.

devise-async is no longer necessary as Devise 4.1 fixes a bug with the
ActiveJob integration.
2016-05-30 13:51:21 -06:00
Gabriel Mazetto f5a0ac0fc1 Codestyle: make sure we have space around operators 2016-05-13 04:46:56 -03:00
Timothy Andrew d915e7d5ca Reuse the private token param and header for personal access tokens.
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3749#note_11626427
- Personal access tokens are still a separate entity as far as the
  codebase is concerned - they just happen to use the same entry point
  as private tokens.
- Update tests and documentation to reflect this change
2016-05-11 10:16:23 +05:30
Timothy Andrew 2e9742997d Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens 2016-05-11 09:52:58 +05:30
James Lopez 6fe8b5da1f Merge branch 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental 2016-05-09 18:06:20 +02:00
Artem Sidorenko d6c2d6bab9 Use sign out path only if not empty 2016-05-03 22:10:49 +02:00
Timothy Andrew bafbf22c6a Address @DouweM's feedback on !3749.
- Use `TokenAuthenticatable` to generate the personal access token
- Remove a check for `authenticity_token` in application controller;
  this should've been `authentication_token`, maybe, and doesn't make
  any sense now.
- Have the datepicker appear inline
2016-04-28 22:28:36 +05:30
Timothy Andrew 051324e12a Refactor `authenticate_user_from_private_token!`
- No need to use `if`s when we have a `presence` check already.
2016-04-28 22:28:36 +05:30
Timothy Andrew ade40fdcd2 Authenticate non-API requests with personal access tokens.
- Rename the `authenticate_user_from_token!` filter to
  `authenticate_user_from_private_token!`
- Add a new `authenticate_user_from_personal_access_token!` filter
- Add tests for both.
2016-04-28 22:28:36 +05:30
James Lopez acf297955a gitlab import UI - icon, file selector, etc... Also updated font-awesome and modified import source settings. 2016-04-22 17:44:59 +02:00
Robert Speicher f583129767 Add Sentry program context even without a current user 2016-04-14 13:56:30 -04:00
Stan Hu e450892f56 Include GonHelper separately and remove created_at in factory 2016-04-14 07:25:27 -07:00
Stan Hu c7e384aab2 Add spec for deletion of authorized OAuth2 application
Closes #14370

Move gon function into its own helper
2016-04-14 07:24:58 -07:00
Robert Speicher 2378ec0d63 Add a `program` tag to Sentry Raven context
This will let us filter errors by the program environment in which they
were encountered.

Source: http://stackoverflow.com/a/28370539/223897

Closes #15092
2016-04-09 19:57:27 -04:00
Douwe Maan ae7b2ef62c Merge branch 'master' into issue_12658
# Conflicts:
#	app/models/issue.rb
#	app/views/projects/_home_panel.html.haml
#	app/views/shared/projects/_project.html.haml
#	db/schema.rb
#	spec/models/project_spec.rb
2016-03-21 23:22:21 +01:00
Douwe Maan 8db1292139 Tweaks, refactoring, and specs 2016-03-20 21:04:07 +01:00
Robert Speicher 085538c2bd Use the configured Kaminari "per page" default 2016-03-19 17:37:54 -04:00
Jacob Vosmaer e7df3f51c9 Move method to User 2016-03-10 12:37:14 +01:00
Jacob Vosmaer cda0b7e1b1 Rename ExpiringLock to ExclusiveLease 2016-03-10 10:41:16 +01:00
Jacob Vosmaer acd9bc0213 Acquire lock before LDAP sync 2016-03-09 19:11:24 +01:00
Rubén Dávila b8295fc323 Fix build and add specs 2016-02-19 13:14:53 -05:00
Robert Speicher ae13389b0b Provide explicit html format when rendering git_not_found page
Prior, if the request format was, for example, .zip, we'd get an
`ActionView::MissingTemplate` error.
2016-02-15 16:38:27 -05:00
Robert Speicher 012c75d1b0 Properly render the `errors/git_not_found` page 2016-02-15 15:52:39 -05:00
Josh Frye 2ad094132d Various filter fixes 2016-02-04 13:03:41 -05:00
Josh Frye 7522ac0b3c Paginate + ajax filter dashboard projects 2016-02-04 11:40:19 -05:00
Stan Hu 7aa739ddc7 Support download access by PRIVATE-TOKEN header
Currently there is no way to download a raw file without embedding
the token in the URL, which exposes the token in the URL. There
should be an way of sending this information via the header as the
API does.

Closes https://github.com/gitlabhq/gitlabhq/issues/8137
2016-02-03 15:42:24 +01:00
Rubén Dávila c3c92c7317 Make default sorting preference work for Issues and MRs. 2016-01-22 18:43:21 -05:00
Rubén Dávila 9ef468922c Merge branch 'master' into issue_5546 2016-01-22 17:54:37 -05:00
Rubén Dávila 7c520c7803 Make sorting preference reusable for all projects. 2016-01-22 17:00:35 -05:00
Rubén Dávila eccaa099d1 Make cookie suffix more simpler. 2016-01-21 15:06:07 -05:00
Rubén Dávila 0f79620ccb Little refactor plus some specs. 2016-01-21 12:54:10 -05:00
Rubén Dávila 4d345bc400 Remember last sort option used. 2016-01-20 17:29:53 -05:00
Douwe Maan 7d347ae564 Merge branch 'master' into issue_3945 2016-01-20 20:04:15 +01:00
Douwe Maan 0ad6b44a27 Send user context to Sentry 2016-01-20 16:15:19 +01:00
Douwe Maan c23ca0b0b5 Merge branch 'master' into issue_3945 2016-01-20 14:53:41 +01:00
Rubén Dávila c8db25c37c Merge branch 'master' into issue_3945 2016-01-14 17:28:44 -05:00
Rubén Dávila df8776f480 Consider that URL can end with '/' before redirecting. #7975 2016-01-13 17:03:24 -05:00
Rubén Dávila 21b602c60a Change strategy to highlight diffs. #3945
Now we apply syntax highlighting to the whole old and new files.
This basically help us to highlight adequately multiline content.
2016-01-07 22:37:01 -05:00
Yorick Peterse 9dacc3bc56 Sort by ID when sorting using "Recently created"
Sorting by "id" has the same effect as sorting by created_at while
performing far better and without the need of an extra index (in case
one wanted to speed up sorting by "created_at").

Sorting by "Recently updated" still uses the physical "updated_at"
column as there's no way to use the "id" column for this instead.
2016-01-07 14:53:02 +01:00
Gabriel Mazetto 1249289f89 Fixed codestyle and added 2FA documentation 2015-12-24 19:01:30 -02:00
Gabriel Mazetto b61a5bc20c specs for forced two-factor authentication and grace period
simplified code and fixed stuffs
2015-12-24 19:01:30 -02:00
Gabriel Mazetto 31fb2b7702 Grace period support for TFA 2015-12-24 19:01:30 -02:00
Gabriel Mazetto 33964469b3 WIP require two factor authentication 2015-12-24 19:00:18 -02:00
tduehr 8e3f1fa629 add CAS authentication support 2015-12-14 21:43:41 -06:00
Jeroen van Baarsen 2dec5ec990 Only redirect to homepage url when its not the root url
It was possible to create an infi redirect when the user set up the
`home_page_url` to redirect to the main URL of the gitlab instance.

This fix makes sure this redirect is not possible.

Fixes !1020

Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-11-02 15:42:30 +01:00
Robert Speicher 7924dd5c9f Merge branch 'project-path-case-sensitivity' into 'master'
Prefer project with exact path to differently cased one when both exist.

Fixes #3113.

See merge request !1649
2015-10-22 13:03:04 +00:00
Douwe Maan e17e5a5ce4 Move case sensitivity check to find_with_namespace. 2015-10-21 10:09:32 +02:00
Stan Hu 9bfc531ec6 Redirect to a default path if HTTP_REFERER is not set
Safari 9.0 does not yet honor the HTML5 `origin-when-cross-origin` mode,
and it's possible load balancers/proxies strip the HTTP_REFERER from
the request header. In these cases, default to some default path.

Closes #3122

Closes https://github.com/gitlabhq/gitlabhq/issues/9731
2015-10-20 07:45:48 -07:00
Douwe Maan 2f7fc7e9f7 Prefer project with exact path to differently cased one when both exist. 2015-10-20 16:16:08 +02:00
Douwe Maan c993481d99 Merge branch 'master' into git-archive-golang 2015-10-15 11:47:36 +02:00
Jacob Vosmaer a74915a4ad Always return HTML in git_not_found
This allows us to give a nice 404 for e.g. archive.zip.
2015-10-14 15:22:03 +02:00
Valery Sizov 8346dde052 Only render 404 page from /public 2015-10-13 20:12:34 +03:00
Francesco Levorato 1bbcc29687 Redirect case sensitive project path to the normalized one 2015-09-18 16:37:21 +02:00
Dmitriy Zaporozhets 0b5d627cd4 Merge branch 'master' into ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g 2015-09-09 14:56:02 +02:00
Dmitriy Zaporozhets 90c338a495 Move helpers back to original directory 2015-09-09 14:37:34 +02:00
Jared Szechy e156f42079 FogBugz project import 2015-09-08 20:23:01 -04:00
Douwe Maan 30555c1d24 Merge branch 'rs-remove-user-color-scheme-class' into 'master'
Apply syntax highlighting to fenced code blocks client-side

Instead of applying the syntax highlighting scheme class to these blocks
server-side, we use Javascript and Gon to apply the user's color scheme
(or the default) client-side.

This will make it easier to cache these blocks in the future because
they're no longer state-dependent.

See merge request !1203
2015-08-27 16:24:51 +00:00
Douwe Maan 843694f902 Merge branch 'master' into ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g 2015-08-26 17:53:31 -07:00
Stan Hu c1fe98e0b9 Prevent too many redirects error when home page URL set to external_urll
Many users naively set the home page URL setting to external_url
(e.g. https://mydomain.com). When an unauthenticated user signs in, this
causes endless redirections. For example, this is occuring:

1. Unauthenticated user attempts to access https://mydomain.com/dashboard
2. Application redirects to the home page URL: https://mydomain.com
3. Repeat step 2

In step 3, ApplicationController should have redirected the user to
https://mydomain.com/users/sign_in. Disabling the redirection if home
page URL is the same as external_url prevents users from messing up.

Closes https://github.com/gitlabhq/gitlabhq/issues/8843
Closes #2057
2015-08-26 07:38:33 -07:00
Douwe Maan 046b283127 Groundwork for merging CI into CE 2015-08-25 18:42:46 -07:00
Robert Speicher 2c3e42e4a4 Remove user_color_scheme_class
Instead of rendering this value server-side, we use Javascript and Gon
to apply the user's color scheme (or the default) to any syntax
highlighted code blocks.

This will make it easier to cache these blocks in the future because
they're no longer state-dependent.
2015-08-25 15:32:38 -07:00
Artem Sidorenko e238a8dad5 Import sources: show only enabled sources 2015-08-20 12:13:22 +02:00
Douwe Maan 70a3c165a9 Allow custom label to be set for authentication providers. 2015-07-23 15:20:12 +02:00
Stan Hu f4f216db67 Only enable HSTS header for HTTPS and port 443
Closes https://github.com/gitlabhq/gitlabhq/issues/9449
2015-07-12 21:37:10 -07:00
Robert Speicher 335749d754 Ensure `@sort` is set by set_filters_params
Closes #1750
2015-07-08 18:17:13 -04:00
Daniel Gerhardt bee3979a4a Fix redirection to home page URL for unauthorized users
Redirection to the home page URL was broken by changing the target for
`root_url` from `DashboardController` to `RootController` in
94d3c1433d. This regression was introduced
in the 7.12.0 release.

Fixes #1916.
2015-07-03 00:22:20 +02: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
Alex Lossent 60225a067d Allow to configure a URL to show after sign out 2015-05-29 18:20:15 +02:00
Douwe Maan 45e4727f97 Set milestone on new issue when creating issue from index with milestone filter active. 2015-05-27 14:22:11 +02:00
Robert Speicher e512f770cd Fix Devise parameter sanitizer for otp_attempt 2015-05-09 17:31:40 -04:00
Dmitriy Zaporozhets de9e1c3bad Turn 2-factor authentication into 2 steps process. Disabled 2fa UI for ldap users since it is not supported 2015-05-09 17:31:10 -04:00
Dmitriy Zaporozhets e097812f57 Merge pull request #9234 from dsander/group-milestones-by-title
Group milestones by title in the dashboard and all other issue views
2015-05-03 14:29:31 +03:00
Douwe Maan 92fd3ccee0 Add helpers for header title and sidebar, and move setting those from controllers to layouts. 2015-05-01 10:39:16 +02:00
Dominik Sander 8d17e79d1d Removed unused ApplicationController#set_filter_values method
The instance variables assigned in `set_filter_values` are not used by
anything anymore.
2015-05-01 00:18:40 +02:00