Allow creating deploy keys with an expiry date
Problem
In the User Settings > SSH Keys form, users can set Expiration date to the key.
However, Project > Settings > Repository > Deploy Keys form doesn't have the field yet. We need to add the same field so that we can fill keys.expires_at in the database table.
Especially, this becomes problematic when a Maximum allowed lifetime for SSH keys is set on an instance. It is not possible to use deploy keys at all.
Proposal
GitLab should provide the ability to create deploy keys with an expiry date, so that users can still make use of deploy keys even if a Maximum allowed lifetime for SSH keys is set in the instance settings.
Implementation guide
- Add datetime picker to the Project-level Deploy Key creation form.
- Pass the expiration date to
Projects::DeployKeysController#create_paramsandDeployKeys::CreateService.
Please see PoC for more details.
Testing
- Make sure the expiration date is persisted into
keys.expires_at. - Make sure users can use project-level deploy keys when a
Maximum allowed lifetime for SSH keysis set on an instance.
Workaround
In the meantime, deploy tokens might be the best alternative.
Edited by Shinya Maeda

