victor23k

victor23k

Proposal

I propose to add the Plug.Conn struct available inside the MFA configured for Phoenix.Endpoint.socket/3 under check_origin.

Benefits

This would make possible to use url params or headers to check if the origin is allowed. Example: passing a user_id param in the url, then checking somewhere else if the Origin is allowed by that user.

Changes

The actual change seems quite simple as conn is already present when the MFA is applied so. It would just need tests and modifying the documentation.
https://github.com/phoenixframework/phoenix/blob/83e4b3245f7cdc85b6c562860477500db9c72697/lib/phoenix/socket/transport.ex#L583-L584

I would be more than happy to send the PR.

Showing Posts 1 to 2

steffend

steffend

Phoenix Core Team

Hey @victor23k,

the issue with the proposal is that any change to the arguments here would be a breaking change. So it’s not something we can easily do.

An ugly solution if you need this could be to have a plug before the socket and store data you need in the process dictionary and then access it from there later.

victor23k

victor23k OP

You are right. Thanks for the workaround!

— All posts loaded —

Where Next? Top

Trending in Proposals: Ideas Top

woylie
We are seeing a lot of warning logs like this: navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews