Moar hound fixes, I guess.
parent
bf27cd8d0e
commit
a3c1134724
|
@ -1,14 +1,14 @@
|
||||||
# Generates a JSON Web Token (JWT) for a given user. Typically placed in the
|
# Generates a JSON Web Token (JWT) for a given user. Typically placed in the
|
||||||
# `Authorization` header, or used a password to gain access to the MQTT server.
|
# `Authorization` header, or used a password to gain access to the MQTT server.
|
||||||
class SessionToken < AbstractJwtToken
|
class SessionToken < AbstractJwtToken
|
||||||
MUST_VERIFY = 'Verify account first'
|
MUST_VERIFY = "Verify account first"
|
||||||
DEFAULT_OS = "https://api.github.com/repos/" \
|
DEFAULT_OS = "https://api.github.com/repos/" \
|
||||||
"farmbot/farmbot_os/releases/latest"
|
"farmbot/farmbot_os/releases/latest"
|
||||||
DEFAULT_FW = "https://api.github.com/repos/FarmBot/farmbot-arduino-firmware/"\
|
DEFAULT_FW = "https://api.github.com/repos/FarmBot/farmbot-arduino-firmware/"\
|
||||||
"releases/latest"
|
"releases/latest"
|
||||||
OS_RELEASE = ENV.fetch('OS_UPDATE_SERVER') { DEFAULT_OS }
|
OS_RELEASE = ENV.fetch("OS_UPDATE_SERVER") { DEFAULT_OS }
|
||||||
FW_RELEASE = ENV.fetch('FW_UPDATE_SERVER') { DEFAULT_FW }
|
FW_RELEASE = ENV.fetch("FW_UPDATE_SERVER") { DEFAULT_FW }
|
||||||
MQTT = ENV.fetch('MQTT_HOST')
|
MQTT = ENV.fetch("MQTT_HOST")
|
||||||
EXPIRY = 40.days
|
EXPIRY = 40.days
|
||||||
|
|
||||||
def self.issue_to(user,
|
def self.issue_to(user,
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Auth
|
||||||
def execute
|
def execute
|
||||||
token = SessionToken.decode!(just_the_token)
|
token = SessionToken.decode!(just_the_token)
|
||||||
claims = token.unencoded
|
claims = token.unencoded
|
||||||
sub = claims['sub']
|
sub = claims["sub"]
|
||||||
case sub
|
case sub
|
||||||
when Integer then User.find(sub)
|
when Integer then User.find(sub)
|
||||||
# HISTORICAL CONTEXT: We once used emails as a `sub` field. At the time,
|
# HISTORICAL CONTEXT: We once used emails as a `sub` field. At the time,
|
||||||
|
|
|
@ -3,7 +3,7 @@ require "spec_helper"
|
||||||
describe Auth::FromJWT do
|
describe Auth::FromJWT do
|
||||||
let(:user) { FactoryGirl.create(:user) }
|
let(:user) { FactoryGirl.create(:user) }
|
||||||
let(:token) { SessionToken.issue_to(user).encoded }
|
let(:token) { SessionToken.issue_to(user).encoded }
|
||||||
fake = lambda (sub) {
|
fake = -> (sub) {
|
||||||
AbstractJwtToken.new([{ sub: sub,
|
AbstractJwtToken.new([{ sub: sub,
|
||||||
iat: Time.now.to_i,
|
iat: Time.now.to_i,
|
||||||
jti: SecureRandom.uuid,
|
jti: SecureRandom.uuid,
|
||||||
|
|
Loading…
Reference in New Issue