-
Notifications
You must be signed in to change notification settings - Fork 17
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
Secured Links 2.0 #11
base: main
Are you sure you want to change the base?
Conversation
a3c0862
to
526c8e4
Compare
Can't you just throw a ForbiddenRequestException?
Actually there is. I needed to read |
Ad error 403) IMHO router should match and return an application request to a special presenter, that throws the error. Something like this: class BadRequestPresenter implements IPresenter
{
/**
* @inheritdoc
*/
function run(Request $request)
{
throw new BadRequestException($request->getParameter('message'), $request->getParameter('code'));
}
} |
Yes I can, the question is whether it is
Good point, hopefully it will good enough. I'll try to implement it today. Possibly as CompilerExtension to avoid any runtime analysis.
Yes, that is a nice trick I didn't thought about. |
b004f3a
to
8016e41
Compare
I feel that the implementation is now mostly finished, I just need to write more tests. |
@JanTvrdik It look good. Except that I'd like to use those generators for future version of EntityLoader as well. |
8016e41
to
1c5f608
Compare
Probably we should not remove the old traits. Let's add a warning to theirs methods. |
@hrach I'm still undecided on that but lean towards removing them. This is such a major rewrite that we will have to release it as a new major version (2.0). If you use both traits and new router in one project, it will break entirely. Therefore I don't see much benefit in keeping them in 2.0. |
Yeah, that seems ok, but let me ask: What if detection of some |
The new system relies on convention of method names Additionally to scanning classes and looking for nextras.securedLinks:
destinations:
Admin\ProductsPresenter:
delete!: true # protect all params for handleDelete
kill: [foobar] # protect all params except for param foobar for actionKill
Yes, that is a problem I don't know how to solve well, except for documenting it. |
Oh, I just figure out, how we can solve this. I'm amazing. |
I have ton of code which doesnt specify return type (neither phpdoc nor php 7 return type hint), beacuse it's totally useless. So my code will have to rely on the scanning & name convetion - is it right? |
@hrach No, you're screwed. The name conventions and return type for createComponent is currently a requirement for the static analysis to work. I can add option to emit warning when createComponent without return type is found (currently it is just silently ignored). I can modify the current control trait to throw an exception if signal leading to secured handler is received but the request was not signed. I wonder how difficult would to implement a simple code-flow analysis which would reliably deduce the return type (even when neither |
In such case the exception is a must have. This could cause serius security issue. |
I pushed a better version which throws exception if things go wrong and which can detect method return type even when neither return annotation or return type hint is presenter (requires nikic/php-parser) |
dfcdae3
to
35fa92f
Compare
35fa92f
to
70bf9d4
Compare
Note: Nextras Secured Links 1.x used to sign only parameters in |
This is a WIP of experimental redesign of Nextras Secured Links.
The new implementation (
SecuredRouter
) moved the logic from controls / presenters to router layer.Benefits
Problems
NULL
will result in 404 and may have security implications if user structures the routers badly (another router may match).action*
/handle*
method (and therefore its annotation) in presenters but there is no way to find targethandle*
method inside components.@secured
annotations to configuration passed to the router.SecuredRouterFlagBased
handles request signing and signature verification with request flags but not solve forcing flag existence and ensuring that request is generated with the flag.Using configuration instead of
@secured
annotation.The configuration may look sth like this.
Or we may move it to neon configuration.