Skip to content

Advise customer on separating security and business entities - #11824

Open
MarkvanMents wants to merge 11 commits into
developmentfrom
MvM-UpdateUserSpecializationSuggestions
Open

Advise customer on separating security and business entities#11824
MarkvanMents wants to merge 11 commits into
developmentfrom
MvM-UpdateUserSpecializationSuggestions

Conversation

@MarkvanMents

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread content/en/docs/howto/security/best-practices-security.md Outdated
* Constraints on widgets in pages should not be used as a measure of security, but can filter out irrelevant data for the context of the page
* Keep your attributes editable within data views, because if an access rule prohibits write access, your client will display it as non-editablethis way you are aware of the (correct) working of an access rule
* Do not make attributes determined by the system (like the status of an order) writable
* If an anonymous user is allowed to create objects, constrain these objects to the owner (an anonymous user is a **System.User** object created on the fly)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Link to a place in the docs where it shows how to do xpath id = currentuser?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done e6dcf89

* Keep your attributes editable within data views, because if an access rule prohibits write access, your client will display it as non-editablethis way you are aware of the (correct) working of an access rule
* Do not make attributes determined by the system (like the status of an order) writable
* If an anonymous user is allowed to create objects, constrain these objects to the owner (an anonymous user is a **System.User** object created on the fly)
* Do not set a default rule for read-and-write accessthis forces you to think about each attribute that is added to an entity

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not a 'rule you set'. This is about the radio button "Default rights for new members" (o)None ( ) Read ( ) Read, Write, where None must be selected. This is also what is taught in class room training, security workshops and CTF stuff, to never use this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done e6dcf89

Comment thread content/en/docs/howto/security/best-practices-security.md
* Disable anonymous access if it has no function within the application
* Some applications have anonymous access enabled, solely to serve a custom login form—this can be replaced by modifying the default *login.html* within your theme (which will also help the user experience with an improved loading time)
* Make roles managing other user roles as strict as possible (configured via **User management** within the user role options)
* Only allow the role of the app's administrator user (default **MxAdmin**) to create the actual administrative accounts (or configure Single Sign On (SSO))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Best practice: Use this Administrator role only for local account management and/or SSO config, do not give it further access rights on your business process data. (This happens a lot where app developers mindlessly check everything readwrite for their business app data, even if there is no UI for it at all.)

Use a separate user role to organize 'god mode' access to business data if needed (fixing things 'in the backend').

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done e6dcf89

Which users and roles are defined within an application changes, depending on the function of the app. However, there are some key guidelines to keep in mind when validating the user security:

You can take the following preventative measures:
* Disable anonymous access if it has no function within the application

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Link to other place where more best practices for Anonymous are mentioned?
https://docs.mendix.com/refguide/anonymous-users/

By the way, in there it should be mentioned more explicitly to best practice recommend to have a dedicated user role (preferably named "Anonymous") for it, and in modules have explicit Anonymous module roles, and not mixed with existing other module roles (for internal logged in user)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done e6dcf89

When deployed to Mendix Cloud, the information about the administrator user name and role is taken into account when using the **Change admin password** button on the environment. After changing the settings in Studio Pro and redeploying the application, a successful admin password change will trigger the creation of a user in the app with the new name and role.

{{% alert color="info" %}}
At this point, the application does not automatically remove the user with the previous user name. Removing the old **MxAdmin** account has to be done manually.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's only the old "MxAdmin account" if the previous name was MxAdmin, not if you change it from Banana to Apple later.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed e6dcf89

```

Because of this XPath constraint, access defined in the access rule is only applied to orders for which the customer is the current end-user.
Applying this XPath constraint means the current end-user can only see orders for the customer associated with the current end-user.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe?! change/improve wording because ambiguity: 'customer' can be used both as 'customer person' and 'customer company'. In the example here you constrain to the individual person.

A common real life case is of course that you can see orders placed by your customer company (also by other employees at your customer company). But we want to have a simple example here.

Another way to solve the confusion is to explicitly mention that the example we use is of the style of a webshop with individual visitors, not a business thing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Tried to clarify e6dcf89

@MarkvanMents MarkvanMents left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the review @knorrie
I've responded to most of the comments in e6dcf89.

* Constraints on widgets in pages should not be used as a measure of security, but can filter out irrelevant data for the context of the page
* Keep your attributes editable within data views, because if an access rule prohibits write access, your client will display it as non-editablethis way you are aware of the (correct) working of an access rule
* Do not make attributes determined by the system (like the status of an order) writable
* If an anonymous user is allowed to create objects, constrain these objects to the owner (an anonymous user is a **System.User** object created on the fly)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done e6dcf89

* Keep your attributes editable within data views, because if an access rule prohibits write access, your client will display it as non-editablethis way you are aware of the (correct) working of an access rule
* Do not make attributes determined by the system (like the status of an order) writable
* If an anonymous user is allowed to create objects, constrain these objects to the owner (an anonymous user is a **System.User** object created on the fly)
* Do not set a default rule for read-and-write accessthis forces you to think about each attribute that is added to an entity

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done e6dcf89

Which users and roles are defined within an application changes, depending on the function of the app. However, there are some key guidelines to keep in mind when validating the user security:

You can take the following preventative measures:
* Disable anonymous access if it has no function within the application

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done e6dcf89

* Disable anonymous access if it has no function within the application
* Some applications have anonymous access enabled, solely to serve a custom login form—this can be replaced by modifying the default *login.html* within your theme (which will also help the user experience with an improved loading time)
* Make roles managing other user roles as strict as possible (configured via **User management** within the user role options)
* Only allow the role of the app's administrator user (default **MxAdmin**) to create the actual administrative accounts (or configure Single Sign On (SSO))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done e6dcf89

When deployed to Mendix Cloud, the information about the administrator user name and role is taken into account when using the **Change admin password** button on the environment. After changing the settings in Studio Pro and redeploying the application, a successful admin password change will trigger the creation of a user in the app with the new name and role.

{{% alert color="info" %}}
At this point, the application does not automatically remove the user with the previous user name. Removing the old **MxAdmin** account has to be done manually.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed e6dcf89

```

Because of this XPath constraint, access defined in the access rule is only applied to orders for which the customer is the current end-user.
Applying this XPath constraint means the current end-user can only see orders for the customer associated with the current end-user.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Tried to clarify e6dcf89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants