Skip to content
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

@Logged vs @NotLogged #196

Closed
oojacoboo opened this issue Dec 18, 2019 · 5 comments
Closed

@Logged vs @NotLogged #196

oojacoboo opened this issue Dec 18, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@oojacoboo
Copy link
Collaborator

I'd like to suggest an additional NotLogged annotation that, instead, makes the assumption that all operations are authenticated operations, unless the NotLogged annotation has been added.

As it is now, security is set such that, any missing Logged annotation, could expose the API. I think this is dangerous, and would much prefer the option of taking the alternate approach to security.

@oojacoboo
Copy link
Collaborator Author

oojacoboo commented Dec 18, 2019

To further expand on this. A simple BC solution would be to add a new method to the AuthenticationServiceInterface. Something like function getAuthenticationPolicy(): AuthenticationPolicy. The AuthenticationPolicy class can define defaults for the auth policy.

Additionally, a similar concept could be applied to the AuthorizationServiceInterface where this would be useful for settings like HideIfUnauthorized. If you have a default authorization policy, you could define that, if not logged, always hide when unauthorized.

These default policies can also support future settings.

@oojacoboo
Copy link
Collaborator Author

FWIW we've put our auth layer higher in the stack and forgone the need for this within GraphQLite. I still think that it's a better assumption that operations require authentication by default. I realize that'd be a BC break. I guess a setting could be added :/

@moufmouf
Copy link
Member

moufmouf commented Jan 2, 2020

I do understand your idea on this.
I'm not quite completely sure how to handle this.

In particular, in the future, there might be third party packages providing GraphQL controllers. I'm not sure whether those third party controllers should be part or not of those default settings.

Maybe we could have a AuthenticationPolicy by namespace?

An alternative might be to be able to put @Logged annotations in the class docblock (rather than in the methods docblock) as proposed in #138.
While not as safe as your proposal, it could be a step forward to increased security.

Anyway, this requires a bit of work. I'll focus on releasing v4.0 first, and I'll come back to this topic when 4.0 is released.

@oojacoboo
Copy link
Collaborator Author

@moufmouf yea, as I was saying, we just put a layer in front of GraphQL to handle this, it can definitely wait. Unfortunately, the solution requires us to parse the graphql request body prior to passing the request to GraphQLite, which is redundant and less performant, but necessary in our case.

Ultimately, the issue is that annotations are terribly easy to overlook and miss. And when it comes to something like security, that's problematic. I'd be all for any way to define a policy. I just find the current method to be insufficient.

@oojacoboo oojacoboo added the enhancement New feature or request label Mar 29, 2021
@oojacoboo
Copy link
Collaborator Author

Following back on this. I think the @Logged annotation should be deprecated and removed from this lib entirely. I just don't see why we need auth being handled in this lib. If it's a symfony thing, I think it should be added to the symfony bundle instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants