sam
(Sam Saffron)
2018 年 1 月 7 日午後 10:58
5
One option here is amending the default current user provider via a plugin:
# frozen_string_literal: true
require_relative "../route_matcher"
# You may have seen references to v0 and v1 of our auth cookie in the codebase
# and you're not sure how they differ, so here is an explanation:
#
# From the very early days of Discourse, the auth cookie (_t) consisted only of
# a 32 characters random string that Discourse used to identify/lookup the
# current user. We didn't include any metadata with the cookie or encrypt/sign
# it.
#
# That was v0 of the auth cookie until Nov 2021 when we merged a change that
# required us to store additional metadata with the cookie so we could get more
# information about current user early in the request lifecycle before we
# performed database lookup. We also started encrypting and signing the cookie
# to prevent tampering and obfuscate user information that we include in the
# cookie. This is v1 of our auth cookie and we still use it to this date.
#
# We still accept v0 of the auth cookie to keep users logged in, but upon
# cookie rotation (which happen every 10 minutes) they'll be switched over to
This file has been truncated. show original
Inheriting off this and adding custom logic to look at parent cookie, then in parent cookie also store the expected user name, if mismatching, nuke cookies.
I am not entirely against amending it so you can force sso when you are already authenticated via a cookie, but it needs to be carefully tested.