tiny refactor
This commit is contained in:
parent
0816167746
commit
85bf18ad0e
|
@ -44,11 +44,7 @@ class SingleSignOn
|
||||||
end
|
end
|
||||||
|
|
||||||
decoded_hash.each do |k,v|
|
decoded_hash.each do |k,v|
|
||||||
# 1234567
|
if field = k[/^custom\.(.+)$/, 1]
|
||||||
# custom.
|
|
||||||
#
|
|
||||||
if k[0..6] == "custom."
|
|
||||||
field = k[7..-1]
|
|
||||||
sso.custom_fields[field] = v
|
sso.custom_fields[field] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -57,9 +53,7 @@ class SingleSignOn
|
||||||
end
|
end
|
||||||
|
|
||||||
def diagnostics
|
def diagnostics
|
||||||
SingleSignOn::ACCESSORS.map do |a|
|
SingleSignOn::ACCESSORS.map { |a| "#{a}: #{send(a)}" }.join("\n")
|
||||||
"#{a}: #{send(a)}"
|
|
||||||
end.join("\n")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def sso_secret
|
def sso_secret
|
||||||
|
@ -74,12 +68,10 @@ class SingleSignOn
|
||||||
@custom_fields ||= {}
|
@custom_fields ||= {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def sign(payload)
|
def sign(payload)
|
||||||
OpenSSL::HMAC.hexdigest("sha256", sso_secret, payload)
|
OpenSSL::HMAC.hexdigest("sha256", sso_secret, payload)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def to_url(base_url=nil)
|
def to_url(base_url=nil)
|
||||||
base = "#{base_url || sso_url}"
|
base = "#{base_url || sso_url}"
|
||||||
"#{base}#{base.include?('?') ? '&' : '?'}#{payload}"
|
"#{base}#{base.include?('?') ? '&' : '?'}#{payload}"
|
||||||
|
@ -92,16 +84,14 @@ class SingleSignOn
|
||||||
|
|
||||||
def unsigned_payload
|
def unsigned_payload
|
||||||
payload = {}
|
payload = {}
|
||||||
|
|
||||||
ACCESSORS.each do |k|
|
ACCESSORS.each do |k|
|
||||||
next if (val = send k) == nil
|
next if (val = send k) == nil
|
||||||
|
|
||||||
payload[k] = val
|
payload[k] = val
|
||||||
end
|
end
|
||||||
|
|
||||||
if @custom_fields
|
@custom_fields&.each do |k, v|
|
||||||
@custom_fields.each do |k,v|
|
payload["custom.#{k}"] = v.to_s
|
||||||
payload["custom.#{k}"] = v.to_s
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Rack::Utils.build_query(payload)
|
Rack::Utils.build_query(payload)
|
||||||
|
|
Loading…
Reference in New Issue