diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-03-27 23:24:02 +0100 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-04-02 14:39:32 +0100 |
commit | 590ddfdcba3d8b88d3351591d307087aaf0d15e0 (patch) | |
tree | 449762a748cb0bc2f6d0cfd204bd84bb2f4b8efd /app/validators | |
parent | 055a02edca0a49938542b57bc3652a0da5464f22 (diff) | |
download | gitlab-ce-590ddfdcba3d8b88d3351591d307087aaf0d15e0.tar.gz |
Adds validators and rack cookie helper
These changes are backported from EE, related to SAML settings in
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4549
Diffstat (limited to 'app/validators')
-rw-r--r-- | app/validators/certificate_fingerprint_validator.rb | 9 | ||||
-rw-r--r-- | app/validators/top_level_group_validator.rb | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/app/validators/certificate_fingerprint_validator.rb b/app/validators/certificate_fingerprint_validator.rb new file mode 100644 index 00000000000..17df756183a --- /dev/null +++ b/app/validators/certificate_fingerprint_validator.rb @@ -0,0 +1,9 @@ +class CertificateFingerprintValidator < ActiveModel::EachValidator + FINGERPRINT_PATTERN = /\A([a-zA-Z0-9]{2}[\s\-:]?){16,}\z/.freeze + + def validate_each(record, attribute, value) + unless value.try(:match, FINGERPRINT_PATTERN) + record.errors.add(attribute, "must be a hash containing only letters, numbers, spaces, : and -") + end + end +end diff --git a/app/validators/top_level_group_validator.rb b/app/validators/top_level_group_validator.rb new file mode 100644 index 00000000000..7e2e735e0cf --- /dev/null +++ b/app/validators/top_level_group_validator.rb @@ -0,0 +1,7 @@ +class TopLevelGroupValidator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + if value&.subgroup? + record.errors.add(attribute, "must be a top level Group") + end + end +end |