Skip to content

DRY supported ssh key types

Bogdan Denkovych requested to merge refactor-ssh-public-key-implementation into master

What does this MR do and why?

Remove redundant format validation for Key#key. This type of validation covered by validate :key_meets_restrictions in Key model, that would return a comprehensive error message like: "Key type is forbidden. Must be RSA, DSA, ECDSA, or ED25519". We are about to add support for 2 new types of keys: ECDSA-SK and ED25519-SK. Removing this type of validation would allow easier extending the supported list of keys. See #213259 (closed).

Add Gitlab::SSHPublicKey.supported_types method. This method returns the names of ssh keys GitLab supports. Gitlab::SSHPublicKey should be the source of truth about such information. SUPPORTED_KEY_TYPES has the same information so I reused the method to prevent duplication that would allow easier to extend the list of supported keys. See #213259 (closed).

Describe in detail what your merge request does and why.

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Bogdan Denkovych

Merge request reports