RFC: CSRF protection #1095
pilcrowonpaper
started this conversation in
Ideas
Replies: 1 comment
-
See PR #1096 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Simplify
LuciaRequest
andLuciaRequestContext
interface, which would allow us to simplify existing middleware.Background
LuciaRequest
was built with the standardRequest
in mind, which provides access to the request url, method, and headers. However, Node'sIncomingMessage
does not provide the full url, and Next.js App Router does not provide the request url or method in certain context.CSRF protection
Where:
URL
isLuciaRequestContext.request.url
HOST
isConfiguration.csrfProtection.host
HOST_HEADER
isConfiguration.csrfProtection.hostHeader
(default:"Host"
)ALLOWED_SUBDOMAINS
isConfiguration.csrfProtection.allowedSubdomains
CSRF protection will be handled in the following order:
Origin
header is not defined, the request is invalidHOST
is defined:Origin
header matchesHOST
, the request is validURL
is defined:Origin
header matches the host ofURL
, the request is validOrigin
header matchesHOST_HEADER
header, the request is validALLOWED_SUBDOMAINS
will be taken into account when determining if a host matches another.API Design
LuciaRequest.headers
now take a standardHeaders
. As such, this interface fully compatible with the standardRequest
.LuciaRequest.storedSessionCookie
will be moved toLuciaRequestContext.sessionCookie
.The new CSRF protection configuration will add
host
andhostHeader
options.Considerations
While the new
LuciaRequest
will replace the old one in v3, both versions will be deemed valid for v2 to not introduce breaking changes.Deprecation
AuthRequest.validateRequestOrigin()
(remove v3)Beta Was this translation helpful? Give feedback.
All reactions