mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-08 03:10:20 +00:00
22 lines
391 B
Ruby
22 lines
391 B
Ruby
# frozen_string_literal: true
|
|
|
|
class VineJwtService
|
|
ALGORITHM = "HS256"
|
|
ISSUER = "openfoodnetwork"
|
|
|
|
def initialize(secret: )
|
|
@secret = secret
|
|
end
|
|
|
|
def generate_token
|
|
generation_time = Time.zone.now
|
|
payload = {
|
|
iss: ISSUER,
|
|
iat: generation_time.to_i,
|
|
exp: (generation_time + 1.minute).to_i,
|
|
}
|
|
|
|
JWT.encode(payload, @secret, ALGORITHM)
|
|
end
|
|
end
|