mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-05 04:15:35 -04:00
Set token cookie after successful basic auth
This commit is contained in:
parent
60100c51fe
commit
1493c3de90
@ -36,7 +36,16 @@ class AuthHandler < Kemal::Handler
|
|||||||
if env.request.headers[AUTH]?
|
if env.request.headers[AUTH]?
|
||||||
if value = env.request.headers[AUTH]
|
if value = env.request.headers[AUTH]
|
||||||
if value.size > 0 && value.starts_with?(BASIC)
|
if value.size > 0 && value.starts_with?(BASIC)
|
||||||
return !verify_user(value).nil?
|
token = verify_user value
|
||||||
|
return false if token.nil?
|
||||||
|
|
||||||
|
# TODO use port number in token key
|
||||||
|
cookie = HTTP::Cookie.new "token", token
|
||||||
|
cookie.path = Config.current.base_url
|
||||||
|
cookie.expires = Time.local.shift years: 1
|
||||||
|
env.response.cookies << cookie
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user