Skip to content

Only set primary key fields as non-accessible.#134

Merged
lorenzo merged 1 commit intomasterfrom
entity
Jul 15, 2015
Merged

Only set primary key fields as non-accessible.#134
lorenzo merged 1 commit intomasterfrom
entity

Conversation

@ADmad
Copy link
Copy Markdown
Member

@ADmad ADmad commented Jul 14, 2015

This change avoids having to update the accessible list when new fields are added to table.

This avoids some hair pulling for new users who don't realize the entity also needs to be updated if they change table fields. I have seen newbies often struggle to figure out why their new fields are not getting saved. e.g. http://stackoverflow.com/questions/31385268/cakephp-3-new-fields-wont-save-correctly

This change avoids having to update the accessible list when new
fields are added to table.
@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Jul 14, 2015

Make me sad making the security feature less obvious

@ADmad
Copy link
Copy Markdown
Member Author

ADmad commented Jul 14, 2015

@lorenzo Life is full of compromises 😄

@markstory
Copy link
Copy Markdown
Member

😢 At least people who need more secure apps have better tools at their disposal.

@markstory markstory added this to the 1.0.11 milestone Jul 14, 2015
lorenzo added a commit that referenced this pull request Jul 15, 2015
Only set primary key fields as non-accessible.
@lorenzo lorenzo merged commit 11e525d into master Jul 15, 2015
@lorenzo lorenzo deleted the entity branch July 15, 2015 10:06
@GuidoHendriks
Copy link
Copy Markdown

👎 I'd rather have security by default than ease of use for "newbies".

@Spriz
Copy link
Copy Markdown

Spriz commented Jul 29, 2015

+1 to @GuidoHendriks 😄

@ADmad
Copy link
Copy Markdown
Member Author

ADmad commented Jul 29, 2015

@GuidoHendriks @Spriz I am not particularly thrilled by this change either but keeping things simpler for newbies is also important as initial impressions matter.

You can use custom bake template to get earlier behavior.

@bcrowe
Copy link
Copy Markdown
Contributor

bcrowe commented Jul 29, 2015

Maybe we should add a note to the docblock?

@ADmad
Copy link
Copy Markdown
Member Author

ADmad commented Jul 29, 2015

@bcrowe Sounds good, can you please make a PR with appropriate text?

@ndm2
Copy link
Copy Markdown
Contributor

ndm2 commented Sep 2, 2015

The fields and no-fields options are now kinda superflous as they are not being used anymore. I'm wondering whether they should be removed, or maybe incorporated again, so that they override the default behavior in case they are being used? ie, if no-fields is used, don't created $_accessible, if fieldsis used, fill $_accessible with only those fields specified.

@markstory
Copy link
Copy Markdown
Member

I would expect fields would result in specific fields being added into the accessible list.

@ndm2
Copy link
Copy Markdown
Contributor

ndm2 commented Sep 2, 2015

@markstory You mean added to what is currently being generated (the * and the primary key fields)?

@markstory
Copy link
Copy Markdown
Member

Well if there is an explicit lust of fields from the user only those fields should be marked accessible.

@ndm2
Copy link
Copy Markdown
Contributor

ndm2 commented Sep 3, 2015

OK, that's what I was suggesting too, I misunderstood you then. I'll try to implement this before I continue with the entity property hints.

ndm2 pushed a commit to ndm2/bake that referenced this pull request Sep 3, 2015
@ndm2 ndm2 mentioned this pull request Sep 3, 2015
@htstudios
Copy link
Copy Markdown

Maybe instead mass assigning to a field that is not accessible could throw a warning on debug true?

markstory added a commit that referenced this pull request Sep 4, 2017
This was removed in #134 to make adding new fields to the database
easier for new developers. This created a tradeoff with more secure
defaults. I'd like to re-add more secure defaults alongside warning log
messages in the marshaller during debug mode to help new developers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants