Commit Graph

141 Commits

Author SHA1 Message Date
Małgorzata Ksionek dfcf4cf5f1 Add captcha if there are multiple failed login attempts
Add method to store session ids by ip

Add new specs for storing session ids

Add cleaning up records after login

Add retrieving anonymous sessions

Add login recaptcha setting

Add new setting to sessions controller

Add conditions for showing captcha

Add sessions controller specs

Add admin settings specs for login protection

Add new settings to api

Add stub to devise spec

Add new translation key

Add cr remarks

Rename class call

Add cr remarks

Change if-clause for consistency

Add cr remarks

Add code review remarks

Refactor AnonymousSession class

Add changelog entry

Move AnonymousSession class to lib

Move store unauthenticated sessions to sessions controller

Move link to recaptcha info

Regenerate text file

Improve copy on the spam page

Change action filter for storing anonymous sessions

Fix rubocop offences

Add code review remarks
2019-07-31 11:47:55 +02:00
Imre Farkas 929b403d21 Ensure Warden triggers after_authentication callback
By not triggering the callback:
- ActiveSession lookup keys are not cleaned
- Devise also misses its hook related to session cleanup
2019-07-26 07:05:50 +00:00
George Thomas a9707e8cf7
Rewrite `if:` argument in before_action and alike when `only:` is also used
Closes #55564
This is first discovered in #54739 (comment 122609857) that if both if: and only:
are used in a before_action or after_action or alike, if: is completely ignored.
2019-07-18 10:04:06 +05:30
James Edwards-Jones fab6a50f17 Prevent password sign in restriction bypass 2019-05-21 14:12:41 +07:00
Illya Klymov 3eff85a97c Remove "You are already signed in" banner 2019-04-24 13:23:07 +00:00
Martin Wortschack 76e8960f4a Externalize strings in flash messages
- Externalize strings in controllers
- Update PO file
2019-04-08 14:17:45 +00:00
Jasper Maes 616fbd028c Rails5: env is deprecated and will be removed from Rails 5.1 2018-11-15 08:12:24 +01: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
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02: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 68547bc0e0 Track blocked users and two factor authentications 2018-07-23 15:13:11 +02:00
Lin Jen-Shin d0afab482f Disable SAML if OmniAuth is disabled
We also try to unify the way we setup OmniAuth, and how we check
if it's enabled or not.
2018-07-20 18:54:46 +08:00
Lin Jen-Shin 4ee08b77bc Updates from `rubocop -a` 2018-07-09 21:13:08 +08:00
Stan Hu 7376ffc3a3 Add Prometheus metrics to track reCAPTCHA success/failures 2018-07-03 11:39:00 -07:00
Stan Hu 9b48d9f43f Show a reCAPTCHA on signin page if custom header is set
This will only be displayed if `X-GitLab-Show-Login-Captcha` is set as an HTTP
header.
2018-06-21 15:37:34 -07:00
Bob Van Landuyt 39916fdfed Reuses `InternalRedirect` when possible
`InternalRedirect` prevents Open redirect issues by only allowing
redirection to paths on the same host.

It cleans up any unwanted strings from the path that could point to
another host (fe. //about.gitlab.com/hello). While preserving the
querystring and fragment of the uri.

It is already used by:

- `TermsController`
- `ContinueParams`
  - `ImportsController`
  - `ForksController`
- `SessionsController`: Only for verifying the host in CE. EE allows
   redirecting to a different instance using Geo.
2018-05-04 13:54:43 +02:00
Horatiu Eugen Vlad 1ad5df49b1 Moved o_auth/saml/ldap modules under gitlab/auth 2018-02-28 16:53:02 +01:00
🙈 jacopo beschi 🙉 729f05f0e3 Adds Rubocop rule for line break around conditionals 2018-01-11 16:34:01 +00:00
Markus Koller 257fd57134 Allow password authentication to be disabled entirely 2017-11-23 13:16:14 +00:00
Toon Claes d13669716a Create idea of read-only database
In GitLab EE, a GitLab instance can be read-only (e.g. when it's a Geo
secondary node). But in GitLab CE it also might be useful to have the
"read-only" idea around. So port it back to GitLab CE.

Also having the principle of read-only in GitLab CE would hopefully
lead to less errors introduced, doing write operations when there
aren't allowed for read-only calls.

Closes gitlab-org/gitlab-ce#37534.
2017-10-06 22:37:40 +02:00
Valery Sizov d57fea4f2d Minor backport from EE 2017-10-05 14:40:49 +03:00
Robert Speicher 4d5ea927d6 Merge branch 'enhance-logging' into 'master'
Improved file logging for authentication events

See merge request gitlab-org/gitlab-ce!9196
2017-10-02 18:10:01 +00:00
Brian Neel 7dac9624bc Remove lock reason and add guard clause 2017-09-29 17:34:47 -04:00
James Lopez 67d06dee30 refactor users update service 2017-09-28 08:46:39 +02:00
James Lopez 9621dd0c9d refactor services to match EE signature 2017-09-28 08:46:39 +02:00
Brian Neel 66d9d258ad Standardize capitalization and status 2017-09-27 23:54:52 -04:00
Brian Neel 8fa87ea3fb # This is a combination of 1 commit.
# This is the 1st commit message:
Add logging for all web authentication events

# This is the commit message #2:

Re-add underscore to after_inactive_sign_up_path_for

# This is the commit message #3:

Standardize on username=

# This is the commit message #4:

after_filter -> after_action, _resource -> resource

# This is the commit message #5:

Add two-factor login failures and account lockouts

# This is the commit message #6:

Move logging from two-factor concern to user model

# This is the commit message #7:

Add spaces around default parameter assignments

# This is the commit message #8:

Move logs out of user model

# This is the commit message #9:

Replace filtered_params with user_params

# This is the commit message #10:

Standardize case

# This is the commit message #1:

Fixes for username and AppLogger.info
2017-09-27 21:52:12 -04:00
Bob Van Landuyt f8865e9c13 Define ldap methods at runtime
This avoids loading the `OmniAuthCallbacksController` at boot time so
it doesn't mess up the `before_action`-chain
2017-08-24 17:33:53 +02:00
Rubén Dávila ef97cb54ae Backport some recent changes related to LDAP from EE 2017-07-27 08:45:16 -05:00
Bob Van Landuyt fa9adb6599 Explicitly add `protect_from_forgery` action
Otherwise the token might be cleared before authentication is
done, causing the authentication itself to fail
2017-07-24 23:28:07 +02:00
Douwe Maan be08202b4b Merge branch 'bjk/metric_names' into 'master'
Update metric names to match Prometheus guidelines.

Closes #35031

See merge request !12812
2017-07-14 18:05:18 +00: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
Ben Kochie 79465fb3d4 Update sessions metric name. 2017-07-12 15:05:51 +02:00
James Lopez b804db2648 refactor update user service not to do auth checks 2017-06-23 11:41:43 +02:00
James Lopez c9fd3dc42c more refactoring based on feedback 2017-06-23 11:41:42 +02:00
James Lopez 158550cf37 added service in the rest of controllers and classes 2017-06-23 11:41:42 +02:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Grzegorz Bizon 37dd19935b Merge branch 'instrument-infra' into 'master'
Add Prometheus metrics endpoint and basic infrastructure to meter code

See merge request !11553
2017-06-07 10:46:56 +00:00
Maxime Besson 9326d89623
Allow manual bypass of auto_sign_in_with_provider
This commit lets a user bypass the automatic signin on the login form,
in order to login with a technical (admin, etc) account

Closes #3786

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 20:00:11 +02:00
Pawel Chojnacki c134a72cdb Move Prometheus presentation logic to PrometheusText
+ Use NullMetrics to mock metrics when unused
+ Use method_missing in NullMetrics mocking
+ Update prometheus gem to version that correctly uses transitive dependencies
+ Ensure correct folders are used in Multiprocess prometheus client tests.
+ rename Sessions controller's metric
2017-06-02 19:45:58 +02:00
Pawel Chojnacki 770f07cd5c Make login_counter instance variable instead of class one.
+ remove unecessarey require
 + fix small formatiing issues
2017-06-02 19:45:58 +02:00
Kevin Lyda 6b9a091cee Add trailing newline to response.
Prometheus requires a trailing newline in its response.

+ cleanup
2017-06-02 19:45:57 +02:00
Kevin Lyda e4fb162186 Initial pass at prometheus monitoring.
This is a step for #29118.

Add a single metric to count successful logins.

Summary types are not supported so remove Collector.  Either
we need to support the summary type or we need to create a
multiprocess-friendly Collector.

Add config to load prometheus and set up the Collector and the
Exporter.

Fix `Gemfile` as current prometheus-client gemspec is missing the
`mmap2` dependency.
2017-06-02 19:45:57 +02:00
James Lopez 2951a8543e Add user activity service and spec. Also added relevant - NOT offline - migration
It uses a user activity table instead of a column in users.
Tested with mySQL and postgreSQL
2017-04-14 15:20:55 +02:00
Markus Koller 8e66514056 Rename check_2fa_requirement to check_two_factor_requirement 2017-04-06 10:01:13 +02:00
mhasbini af0c08b6f9 Fix redirection after login when the referer have params 2017-04-02 18:54:19 +03:00
Douwe Maan 1fe7501b49 Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
2017-02-23 09:33:05 -06:00
Douwe Maan 206953a430 Prefer leading style for Style/DotPosition 2017-02-23 09:32:22 -06:00
Douwe Maan 5c7f9d69e3 Fix code for cops 2017-02-23 09:31:57 -06:00
Douwe Maan 8a4d68c53e Enable Style/ConditionalAssignment 2017-02-23 09:31:57 -06:00
Rydkin Maxim 170efaaba2 Enable Style/MultilineOperationIndentation in Rubocop, fixes #25741 2016-12-16 21:37:22 +03:00
jnoortheen 3c36d9dc9b fix: removed signed_out notification
test: replaced signed_out message check with check for sign_in button

fixes #25294
2016-12-12 15:04:48 +05:30
jnoortheen 6ab74b1cb3 fix: 24982- Remove'Signed in successfully' message
After this change the sign-in-success flash message will not be shown

refactor: set flash message to be nil while signing in

test: changed tests to reflect removal of sign-in message

refactor: adding signed_in message back

See Merge Request !7837

issue#24982
2016-12-07 20:30:28 +05:30
Connor Shea 602fe11191
Remove provider path, replace with dynamic path. 2016-08-03 11:50:38 -06:00
Connor Shea e8c6f119cd
Add an oauth provider path helper.
The helper constructs the path for a given oauth provider since Devise 4.0 deprecated passing the provider to the omniauth authentication path.

Fixes #18110.
2016-08-03 11:50:29 -06:00
Jacob Vosmaer (GitLab) 2f459a03e0 Merge branch '18225-avoid-full-table-users-count' into 'master'
Check if the Users table has exactly one user limiting the whole set

## What does this MR do?

Limit the query set so about a full scan for all the rows on the users table (only scan to records)

#18225 

See merge request !4492
2016-06-15 15:12:56 +00:00
Robert Speicher d74e93ce46 Merge branch 'password-min-length-placeholder' into 'master'
Added minimum password length to password field

Add a placeholder to the password field in the register form with the minimum number of characters required. Also added a pattern to the field to stop it submitting if less than that.

Closes #17765

See merge request !4458
2016-06-08 19:48:03 +00:00
Paco Guzman 3b21174d32 Check if the Users table has exactly one user limiting the whole set 2016-06-06 15:51:56 +02:00
Timothy Andrew 4db19bb445 Add a U2F-specific audit log entry after logging in.
- "two-factor" for OTP-based 2FA
- "two-factor-via-u2f-device" for U2F-based 2FA
- "standard" for non-2FA login
2016-06-06 12:50:31 +05:30
Timothy Andrew 86b07caa59 Implement authentication (login) using a U2F device.
- Move the `authenticate_with_two_factor` method from
  `ApplicationController` to the `AuthenticatesWithTwoFactor` module,
  where it should be.
2016-06-06 12:50:31 +05:30
Phil Hughes 57a3f28456 Added minimum password length to password field
Closes #17765
2016-06-03 11:48:11 +01:00
Robert Speicher a602df3031 Pass the "Remember me" value to the 2FA token form
Prior, if a user had 2FA enabled and checked the "Remember me" field,
the setting was ignored because the OTP input was on a new form and the
value was never passed.

Closes #18000
2016-05-30 22:25:35 -04:00
Grzegorz Bizon 00da609cfd Fix 2FA authentication spoofing vulnerability
This commit attempts to change default user search scope if otp_user_id
session variable has been set. If it is present, it means that user has
2FA enabled, and has already been verified with login and password. In
this case we should look for user with otp_user_id first, before picking
it up by login.
2016-04-07 11:19:29 +02:00
Robert Speicher 599a6d7873 Allow the initial admin to set a password
Closes #1980
2016-03-04 17:37:57 -05:00
Robert Speicher fdf68a8d4d Skip the 2FA requirement during logout 2016-01-23 16:44:46 -08:00
Gabriel Mazetto a3469d914a reCAPTCHA is configurable through Admin Settings, no reload needed. 2015-12-28 18:50:29 -02:00
Stan Hu 9f7d379c2a Add support for Google reCAPTCHA in user registration to prevent spammers 2015-12-27 09:04:11 -08:00
Robert Speicher 259851c0d6 Bump devise-two-factor to 2.0.0
Addresses internal https://dev.gitlab.org/gitlab/gitlabhq/issues/2605

See https://github.com/tinfoil/devise-two-factor/pull/43
2015-09-19 21:16:18 -04:00
Valery Sizov 3700e5a960 Crowd integration 2015-09-02 12:42:01 +03:00
Alex Lossent fb6e8008c4 Fix redirection after sign in when using auto_sign_in_with_provider
Logic for redirect path moved to a filter.
2015-08-12 17:31:35 +02:00
Douwe Maan 70a3c165a9 Allow custom label to be set for authentication providers. 2015-07-23 15:20:12 +02:00
Valery Sizov 411829fdb5 Audit log for user authentication 2015-07-06 12:36:08 +03:00
Robert Speicher b6318297fc Use User#two_factor_enabled instead of otp_required_for_login 2015-06-19 15:14:37 -04:00
Alex Lossent 5491f6fbde Add an option to automatically sign-in with an Omniauth provider without showing the GitLab sign-in page
This is useful when integrating with existing SSO environments and we want to use a single Omniauth provider for
all user authentication.
2015-05-29 18:15:03 +02:00
Robert Speicher c802d8eee1 Refactor SessionsController to use a controller concern 2015-05-14 14:24:05 -04:00
Robert Speicher 5cd526f77f Prevent "You are already signed in." error message upon 2FA login 2015-05-09 17:32:49 -04:00
Robert Speicher 76873ce4a4 Move "invalid 2FA code" error message to the flash
This makes it consistent with the Invalid email/password error message
from the previous step.
2015-05-09 17:32:49 -04:00
Robert Speicher 32971b0af4 Refactor SessionsController
Also adds test case for providing an invalid 2FA code and then a valid
one without re-entering username and password.
2015-05-09 17:32:09 -04:00
Robert Speicher 5520397f04 Make two-factor login work and add a feature spec 2015-05-09 17:32:08 -04:00
Robert Speicher 125ee5262a Don't use hard-coded sign_in path 2015-05-09 17:31:40 -04:00
Robert Speicher c84f1240d4 prepend_before_filter -> prepend_before_action 2015-05-09 17:31:40 -04:00
Dmitriy Zaporozhets 802fcd051f Add support for backup codes 2015-05-09 17:31:37 -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
Robert Speicher 57afaf9d92 Upon successful login, clear `reset_password_token` field
Closes #1942
2015-04-08 16:06:56 -04:00
Dmitriy Zaporozhets 57a65ede77 Improve application settings and write tests 2015-01-08 09:53:35 -08:00
Jan-Willem van der Meer 6ce65a3e95 Use Hash syntax for LDAP server declaration 2014-10-14 13:13:59 +02:00
Jan-Willem van der Meer a7e071e982 Add refactoring for multiple LDAP server support
These changes are ported from EE to CE. Apply changes for app directory
2014-10-13 13:39:54 +02:00
Jacob Vosmaer 3a6f9c093e Only redirect to referrer from public GitLab pages 2014-07-28 16:41:37 +02:00
Marin Jankovski b421750035 Call store_location_for once. 2014-07-22 08:34:16 +02:00
Marin Jankovski 9714061bb0 If the referer is not set, use fullpath. 2014-07-21 15:45:27 +02:00
Marin Jankovski 07b9d80604 Use devise stored_location to redirect after signing for both public and private pages. 2014-07-11 19:53:10 +02:00