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

How are json params deserialized / secured? #109

Open
camallen opened this issue Jan 28, 2020 · 4 comments
Open

How are json params deserialized / secured? #109

camallen opened this issue Jan 28, 2020 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@camallen
Copy link
Contributor

I can't see the use of jsonapi_deserialize to ensure only whitelisted controller params are making it through to the model layer, https://github.com/stas/jsonapi.rb#deserialization

Also I can't see the controller layer using strong params to ensure only whitelisted attribtues are updated.

How do you ensure that only specific, allowed attributes are being updated at the model layer?

@camallen camallen added the question Further information is requested label Jan 28, 2020
@zwolf
Copy link
Member

zwolf commented Jan 30, 2020

Strong params isn't being used because it proved roughly impossible to get the require().permit() syntax to play well with the jsonapi schema. See #42, then b726cd2

jsonapi_deserialize is being used right here:

jsonapi_deserialize(params)

There is restriction of the approved status, but there does need to be a more general whitelist that will keep people from updating, like, updated_at or whatever directly.

@zwolf zwolf added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Jan 30, 2020
@camallen
Copy link
Contributor Author

Thank you for clarifying, I missed the use of the deserialize cmd in the transcriptions controller.

It's good to see you've got this setup and I agree about a more specific whitelist of allowed attributes and not any model attribute.

@zwolf
Copy link
Member

zwolf commented Jan 31, 2020

A good argument for keeping things like this inline, thanks for pointing it out. Looking at the code, I don't know if I'll need to bring strong params back and let the deserializer worry about it, or if I can just use the only: allowed_params as a whitelist. Seems like the latter, which would be a straightforward fix.

https://github.com/stas/jsonapi.rb/blob/master/lib/jsonapi/deserialization.rb#L31-L35

@camallen
Copy link
Contributor Author

My understanding is that you can use the deserialization instead of strong params.

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

No branches or pull requests

2 participants