Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Do not give everyone permission to read answers #156

Merged
merged 4 commits into from
Oct 21, 2016

Conversation

Natim
Copy link
Member

@Natim Natim commented Oct 5, 2016

Refs Kinto/kinto#828 (comment)
r? @almet
f? @enguerran

When we created the formbuilder it wasn't possible to let people read the schema without being able to read all the form answer.

This limitation was fixed in Kinto 4.3 and people with the record:create permission can now read the collection schema and their answer only.

This is the implementation of the fix for the formbuilder.

return (dispatch, getState) => {
dispatch({type: SCHEMA_RETRIEVAL_PENDING});
new KintoClient(config.server.remote, {
headers: getAuthenticationHeaders(collection)
headers: getAuthenticationHeaders("EVERYONE")
Copy link
Member Author

@Natim Natim Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be "AUTHENTICATED" or "ANYONE" or a random uuid too.

Copy link
Member

@almet almet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small change needed, otherwise looks good.

@@ -8,7 +8,7 @@ import config from "./config";
* are stored. This is useful to always have one id to pass to the clients,
* and they can figure out what the user token and collection name is.
**/
export function getUserToken(adminToken) {
export function getFormID(adminToken) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change the name of the function, you need to update the description for it as well (returns the unique identifier of the form, from the administrative token)

@Natim
Copy link
Member Author

Natim commented Oct 5, 2016

Note that this needs Kinto >= 4.3

@enguerran
Copy link
Member

I test the new formbuilder with the https://kinto.dev.mozaws.net/v1/ backend.

The admin token is: 91ec309e9a3c463ca63fd8036d9e6d71
The form ID is: 91ec309e9a3c463c

As you can see in the admin console it looks ok! 👍

I suggest to update the README.md as it still refers to userToken instead of formID.

I find a bug too when you create a form without any required field, it fails publishing the form → 2502118#diff-d3be7b791c4d0d2548517ed3b5b9834bR81

@Natim
Copy link
Member Author

Natim commented Oct 5, 2016

I removed the PUBLICATION_FAILED so I should probably put it back.

@enguerran
Copy link
Member

In fact, I cannot reproduce. I got an error in the console

TypeError: schema.required is undefined

@Natim
Copy link
Member Author

Natim commented Oct 5, 2016

Yes but the TypeError should change the form status as well.

@enguerran
Copy link
Member

You can add something like that to forbid empty form publication:

    if(Object.keys(schema.properties).length === 0) {
      dispatch(addNotification("We cannot publish an empty form.", {type: "error"}));
      dispatch({ type: FORM_PUBLICATION_FAILED });
    }

@almet
Copy link
Member

almet commented Oct 5, 2016

We should already have this somewhere. It rings a bell :)

@almet
Copy link
Member

almet commented Oct 19, 2016

@Natim, how does this affects people with already in use forms? Does this continues to work for them or is this breaking compatibility? Thanks for the precision, and thanks for the code submission :-)

Rémy HUBSCHER and others added 4 commits October 20, 2016 11:46
@almet almet force-pushed the do-not-give-everyone-permission-to-read-answers branch from 03c9308 to cdab572 Compare October 20, 2016 09:48
@almet
Copy link
Member

almet commented Oct 20, 2016

This is now ready to be merged!

@almet almet merged commit 3f4e4a2 into master Oct 21, 2016
@almet almet deleted the do-not-give-everyone-permission-to-read-answers branch October 21, 2016 14:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants