diff options
author | elijah <elijah@riseup.net> | 2015-01-28 12:32:15 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2015-01-28 12:32:15 -0800 |
commit | eebe08aba43302b080c7b534a746f0f30359f370 (patch) | |
tree | 40d20aa9db55319328d70126635a8d84b542828a /app/models/client_certificate.rb | |
parent | 42ba688eabcdb428e0ce230175b72c357bea9cdb (diff) |
client certificates: allow for time units to be specified in client_cert_lifespan config option.
Diffstat (limited to 'app/models/client_certificate.rb')
-rw-r--r-- | app/models/client_certificate.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/client_certificate.rb b/app/models/client_certificate.rb index 815801e..688d5c0 100644 --- a/app/models/client_certificate.rb +++ b/app/models/client_certificate.rb @@ -48,7 +48,7 @@ class ClientCertificate end def expiry - @expiry ||= lifespan.months.from_now.utc.at_midnight + @expiry ||= lifespan end private @@ -109,12 +109,14 @@ class ClientCertificate # We normalize timestamps at utc and midnight # to reduce the fingerprinting possibilities. # - def last_month 1.month.ago.utc.at_midnight end def lifespan - APP_CONFIG[:client_cert_lifespan] + number, unit = APP_CONFIG[:client_cert_lifespan].split(' ') + unit ||= :months + Time.now.utc.at_midnight.advance(unit.to_sym => number.to_i) end + end |