Commit Graph

76 Commits

Author SHA1 Message Date
GitLab Bot 3e1c760141 Add latest changes from gitlab-org/gitlab@master 2020-11-05 18:08:48 +00:00
GitLab Bot c59765a50a Add latest changes from gitlab-org/gitlab@master 2020-06-24 18:09:03 +00:00
GitLab Bot cd52759ee3 Add latest changes from gitlab-org/gitlab@master 2020-03-12 12:09:17 +00:00
GitLab Bot 22e9af3c8b Add latest changes from gitlab-org/gitlab@master 2020-01-27 12:08:35 +00:00
GitLab Bot 1caa60060b Add latest changes from gitlab-org/gitlab@master 2019-12-19 00:08:01 +00:00
GitLab Bot 5bd24a54ef Add latest changes from gitlab-org/gitlab@master 2019-12-17 09:07:48 +00:00
GitLab Bot 175b4fa261 Add latest changes from gitlab-org/gitlab@master 2019-12-11 18:08:10 +00:00
Thong Kuah a2cfc150ce Add # frozen_string_literal to spec/models
Adds `# frozen_string_literal: true` to spec/models ruby files
2019-04-01 14:37:54 +13:00
Rubén Dávila 7044a3a54a Validate SSH keys through the sshkey gem 2018-02-16 11:32:08 -05:00
Rubén Dávila 75fd832454 Revert "Merge branch 'rd-43185-revert-sanitize-extra-blank-spaces-used-when-uploading-a-ssh-key' into 'master'"
This reverts commit e607fd7966.
2018-02-15 09:50:19 -05:00
Rubén Dávila 740499bab5 Revert "Merge branch 'rd-40552-gitlab-should-check-if-keys-are-valid-before-saving' into 'master'"
This reverts commit a58f8c32c6, reversing
changes made to cd5d75c362.
2018-02-12 12:39:47 -05:00
Douwe Maan a58f8c32c6 Merge branch 'rd-40552-gitlab-should-check-if-keys-are-valid-before-saving' into 'master'
Sanitize extra blank spaces used when uploading a SSH key

Closes #40552

See merge request gitlab-org/gitlab-ce!16821
2018-02-02 19:18:12 +00: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
Rubén Dávila 972f564dcd Sanitize extra blank spaces used when uploading a SSH key 2018-02-01 17:00:16 -05:00
Yorick Peterse 3e561736b2
Cache the number of user SSH keys
By caching the number of personal SSH keys we reduce the number of
queries necessary on pages such as ProjectsController#show (which can
end up querying this data multiple times).

The cache is refreshed/flushed whenever an SSH key is added, removed, or
when a user is removed.
2017-11-16 14:59:38 +01:00
Nick Thomas eaa1ce4fbe
Ensure key fingerprints are generated correctly when modified 2017-10-03 18:45:01 +01:00
Yorick Peterse b3566a0104
Stop using Sidekiq for updating Key#last_used_at
This makes things simpler as no scheduling is involved. Further we
remove the need for running a SELECT + UPDATE just to get the key and
update it, whereas we only need an UPDATE when setting last_used_at
directly in a request.

The added service class takes care of updating Key#last_used_at without
using Sidekiq. Further it makes sure we only try to obtain a Redis lease
if we're confident that we actually need to do so, instead of always
obtaining it. We also make sure to _only_ update last_used_at instead of
also updating updated_at.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36663
2017-09-20 14:24:14 +02:00
haseeb cc2daa74d8 created services for keys 2017-09-15 15:35:24 +00:00
Nick Thomas 6847060266 Rework the permissions model for SSH key restrictions
`allowed_key_types` is removed and the `minimum_<type>_bits` fields are
renamed to `<tech>_key_restriction`. A special sentinel value (`-1`) signifies
that the key type is disabled.

This also feeds through to the UI - checkboxes per key type are out, inline
selection of "forbidden" and "allowed" (i.e., no restrictions) are in.

As with the previous model, unknown key types are disallowed, even if the
underlying ssh daemon happens to support them. The defaults have also been
changed from the lowest known bit size to "no restriction". So if someone
does happen to have a 768-bit RSA key, it will continue to work on upgrade, at
least until the administrator restricts them.
2017-08-30 20:50:44 +01:00
Nick Thomas b0f982fbdf Add settings for minimum key strength and allowed key type
This is an amalgamation of:

* Cory Hinshaw: Initial implementation !5552
* Rémy Coutable: Updates !9350
* Nick Thomas: Resolve conflicts and add ED25519 support !13712
2017-08-30 20:50:44 +01:00
Nick Thomas da5262f4e6 Backport changes in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2551 to CE 2017-08-07 19:17:11 +01:00
Rémy Coutable 29f1fa8250 Merge branch 'use-rspec-support-helper' into 'master'
Don't include EmailHelpers manually, pick with rspec

See merge request !13257
2017-08-03 16:42:02 +00:00
haseeb ae99f05b05 fix #35133 strip new lines from ssh keys 2017-08-03 16:39:10 +00:00
Lin Jen-Shin bb5f79d43e Don't include EmailHelpers manually, pick with rspec
`:mailer` is needed to pick it easily, while
`type: :mailer` is needed for picking it automatically for
tests located in spec/mailers/*_spec.rb

It's a bit complicated in spec/services/notification_service_spec.rb
but we'll leave it alone for now.
2017-08-03 21:55:48 +08:00
Rémy Coutable ddccd24c13 Remove superfluous lib: true, type: redis, service: true, models: true, services: true, no_db: true, api: true
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Rémy Coutable 857d039145
Lint our factories creation in addition to their build
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 19:06:50 +02:00
Adam Niedzielski 8c41d5f5e1 Record used SSH keys only once per day
Use Gitlab::ExclusiveLease to make sure that we enqueue Sidekiq job
at most once per day for given key.
2017-01-20 11:42:46 +01:00
Vincent Wong b6df93a51f Record and show last used date of SSH Keys
Addresses: Issue #13810

1. Adds a last_used_at attribute to the Key table/model
2. Update a key's last_used_at whenever it gets used
3. Display how long ago an ssh key was last used
2017-01-09 04:15:39 +11:00
Filipa Lacerda eb839b9af5 Merge CSS 2016-12-12 17:52:06 +00:00
Lin Jen-Shin 5430122c56 Now we need to include EmailHelpers for each test 2016-12-06 21:34:49 +08:00
Rémy Coutable 4e249d5bae
Use :maximum instead of :within for length validators with a 0..N range
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-06 10:23:17 +01:00
Lin Jen-Shin 60fe975452 Merge remote-tracking branch 'upstream/master' into feature/1376-allow-write-access-deploy-keys
* upstream/master: (497 commits)
  Use single quote for strings
  Ue svg from SVGs object
  Dont trigger CI builds [ci skip]
  Revert "Test only migrations"
  Add custom copy for each empty stage
  Fetch only one revision
  Highlight nav item on hover
  Test only migrations
  Fix migration paths tests
  Scroll CA stage panel on mobile
  Fix CSS declaration
  administer to administrator
  Move SVGs to JS objects for easy reuse
  Improve deploy command message
  No enough data to Not enough data
  Keep the cookie name as before
  Fix variable usage
  Evalute time_ago method instead of printing it
  Removed button styling from restricted visibility levels and added checkboxes with icons
  Do not show overview message if there’s already CA data
  ...
2016-11-22 13:59:07 +08:00
Lin Jen-Shin 9c4e0d6445 Use `Gitlab.config.gitlab.host` over `'localhost'`
This would fix long standing failures running tests on
my development machine, which set `Gitlab.config.gitlab.host`
to another host because it's not my local computer. Now I
finally cannot withstand it and decided to fix them once and
for all.
2016-11-18 20:17:10 +08:00
Lin Jen-Shin 428061678e Add tests for key/deploy key notifications 2016-11-18 19:09:03 +08:00
Semyon Pupkov 2a95184045 Remove instance vars from key model tests 2016-11-16 00:59:09 +05:00
Semyon Pupkov 34a86120ed Use setter for key instead AR callback
ref: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6763
2016-11-16 00:59:09 +05:00
Semyon Pupkov 85df1bf02d Remove empty describe block on key spec model 2016-10-11 11:02:53 +05:00
tiagonbotelho 1d268a89de adds second batch of tests changed to active tense 2016-08-09 15:11:39 +01:00
Keith Pope b371d75128 Tidy the key spec and fix failing user spec 2016-08-02 12:49:59 +01:00
Keith Pope 4768afbdbf Add simple identifier to public SSH keys 2016-08-02 06:56:23 +01:00
Paco Guzman ca01c4c648 Remove Duplicated keys add UNIQUE index to fingerprint 2016-06-20 13:29:04 +02:00
Jeroen van Baarsen f1479b56b7
Remove the annotate gem and delete old annotations
In 8278b763d9 the default behaviour of annotation
has changes, which was causing a lot of noise in diffs. We decided in #17382
that it is better to get rid of the whole annotate gem, and instead let people
look at schema.rb for the columns in a table.

Fixes: #17382
2016-05-09 18:00:28 +02:00
Gabriel Mazetto b5291f9599 Fixed Rubocop offenses 2015-12-15 00:53:52 -02:00
Douwe Maan 1e8d703a85 Tag model specs 2015-12-09 10:50:51 +01:00
Zeger-Jan van de Weg 4ccd767abf Only publish ssh key-type and key 2015-08-04 14:33:18 +02:00
Nikita Verkhovin 562d78a65a Add error message for SSH key linebreaks 2015-07-12 00:18:56 +06:00
Robert Speicher 47251b85e0 ensure_length_of -> validate_length_of 2015-06-10 01:31:26 -04:00
Stan Hu a3157626f1 Re-annotate models 2015-05-03 13:38:27 -07:00
Robert Speicher 273df6a44b Remove the invalid key factories
They're only used once each, and they're easy to build in-place.
2015-04-11 17:12:10 -04:00