Module: Awskeyring::Validate
- Defined in:
- lib/awskeyring/validate.rb
Overview
Validation methods for Awskeyring
Class Method Summary collapse
-
.access_key(aws_access_key) ⇒ Object
Validate an AWS Access Key ID.
-
.account_name(account_name) ⇒ Object
Validate an account name.
-
.mfa_arn(mfa_arn) ⇒ Object
Validate an Users mfa ARN.
-
.mfa_code(mfa_code) ⇒ Object
Validate an MFA CODE.
-
.role_arn(role_arn) ⇒ Object
Validate a Role ARN.
-
.role_name(role_name) ⇒ Object
Validate a Role name.
-
.secret_access_key(aws_secret_access_key) ⇒ Object
Validate an AWS Secret Key ID.
Class Method Details
.access_key(aws_access_key) ⇒ Object
Validate an AWS Access Key ID
22 23 24 25 26 |
# File 'lib/awskeyring/validate.rb', line 22 def self.access_key(aws_access_key) raise 'Invalid Access Key' unless /\AAKIA[A-Z234567]{16}\z/.match?(aws_access_key) aws_access_key end |
.account_name(account_name) ⇒ Object
Validate an account name
13 14 15 16 17 |
# File 'lib/awskeyring/validate.rb', line 13 def self.account_name(account_name) raise 'Invalid Account Name' unless /\S+/.match?(account_name) account_name end |
.mfa_arn(mfa_arn) ⇒ Object
Validate an Users mfa ARN
44 45 46 47 48 |
# File 'lib/awskeyring/validate.rb', line 44 def self.mfa_arn(mfa_arn) raise 'Invalid MFA ARN' unless %r(\Aarn:aws:iam::[0-9]{12}:mfa/\S*\z).match?(mfa_arn) mfa_arn end |
.mfa_code(mfa_code) ⇒ Object
Validate an MFA CODE
71 72 73 74 75 |
# File 'lib/awskeyring/validate.rb', line 71 def self.mfa_code(mfa_code) raise 'Invalid MFA CODE' unless /\A\d{6}\z/.match?(mfa_code) mfa_code end |
.role_arn(role_arn) ⇒ Object
Validate a Role ARN
62 63 64 65 66 |
# File 'lib/awskeyring/validate.rb', line 62 def self.role_arn(role_arn) raise 'Invalid Role ARN' unless %r(\Aarn:aws:iam::[0-9]{12}:role/\S*\z).match?(role_arn) role_arn end |
.role_name(role_name) ⇒ Object
Validate a Role name
53 54 55 56 57 |
# File 'lib/awskeyring/validate.rb', line 53 def self.role_name(role_name) raise 'Invalid Role Name' unless /\S+/.match?(role_name) role_name end |
.secret_access_key(aws_secret_access_key) ⇒ Object
Validate an AWS Secret Key ID
31 32 33 34 35 36 37 38 39 |
# File 'lib/awskeyring/validate.rb', line 31 def self.secret_access_key(aws_secret_access_key) begin raise 'Invalid Secret Access Key' unless Base64.strict_decode64(aws_secret_access_key).length == 30 rescue ArgumentError raise 'Invalid Secret Access Key' end aws_secret_access_key end |