-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template is still rendered before redirect_to_login
?
#145
Comments
Hi Kat, This is a good question. If I'm understanding you, your current custom security handler works, but you'd rather not have to do the Unfortunately, there's not a way, currently, to short-circuit a request (though if ever there was an argument for it, a redirect is probably the strongest argument that exists). Without a short-circuit to end request dead, you'll need to change the page module, however, to eliminate any amount of flashing, you could do the following:
I just made a quick change to the This should solve that problem for you. ====== That said, the longer-term argument should be toward pushing to add a short-circuit option. Implementing this would be a few steps long: In
Doing that slight rework should allow If you're comfortable making those changes (I know it's getting a little deep in the request flow), have at 'er and I'll gladly review and pull a PR. If not, I'm happy to do this. |
Heya @choptastic, sorry for the delay getting back to this, I've been a bit swamped. I appreciate the reply and the update to allow short-circuiting the request! It hadn't occurred to me to use an empty The code now looks like this, and seems to work nicely:
I haven't had a chance to look at doing a PR for the request flow. It's looking like I won't have time to do that anytime soon, so don't set the task aside for me or anything! But if you haven't updated it by whenever I have some free cycles again, I will revisit it. Thanks!! |
I'm not sure if there's a bug here or if I'm doing something wrong.
We have a fairly basic custom security handler for access control. Here's the
init
function:As the comment says, we've found that if we don't change the
page_module
to something innocuous, the protected template will still render, allowing it to be visible in a brief flash before the redirect to login. (Or, in some cases, allowing it to crash, if it's expecting session data to exist.)I found this ancient StackOverflow example, in which a user advises a custom security handler "Instead of having the
main/0
logic you describe in each of your page handlers". The example code provided simply callsredirect_to_login
without otherwise changing the state. I did also try setting a status code of401
, resulting in the server happily rendering the entire protected template, with a 401 status code.It's my impression that with a custom security handler, we shouldn't have to double-check for access in the
main
function of every page handler. What am I missing? Is there a better workaround than setting a dummy page handler? Or perhaps some way to cancel the in-progress page load and immediately execute the redirect?The text was updated successfully, but these errors were encountered: