4fb9c3b1c0b88f46386f29a5c02392f6b5651dd1
wiki/security.md
| ... | ... | @@ -45,6 +45,13 @@ For this to work, the Web Bundle requires at least the two bundles `org.apache.s |
| 45 | 45 | |
| 46 | 46 | The Web Bundle then provides a `shiro.ini` file in its classpath root, e.g., directly within its `src` or `resources` source folder. The `shiro.ini` file contains essential configuration information about which realms, which session and which cache manager to use. It also configures URLs for login pages, default success pages and permissions required for access to URLs. The file `com.sap.sse.security/resources/shiro.ini` serves as a reasonable copy template. In the `[urls]` section the `shiro.ini` flie provides so-called filter chains for specific or pattern-based sets of URLs. In particular, the configuration can require the authenticated user to have specific roles and / or specific permissions to access the URL. Note the use of the `AnyOfRolesFilter` and how it is different from the regular `roles` filter. |
| 47 | 47 | |
| 48 | +All authentication filters inheriting from `com.sap.sse.security.AbstractUserStoreBasedRealm` can provide an instance for the `permissionsForRoleProvider` property in the `shiro.ini` configuration file, e.g., as follows: |
|
| 49 | + |
|
| 50 | + permissionsForRoleProvider = com.sap.sailing.gwt.ui.client.shared.security.SailingPermissionsForRoleProvider |
|
| 51 | + upRealm = com.sap.sse.security.UsernamePasswordRealm |
|
| 52 | + upRealm.credentialsMatcher = $credentialsMatcher |
|
| 53 | + upRealm.permissionsForRoleProvider = $permissionsForRoleProvider |
|
| 54 | + |
|
| 48 | 55 | ## How to Implement Permission Checks |
| 49 | 56 | |
| 50 | 57 | There are generally two ways in which some feature can require the user to be equipped with permissions: declaratively in the `shiro.ini` file's `[urls]` section; or programmatically by using something like ``org.apache.shiro.SecurityUtils.getSubject().checkPermission(...)`` which will throw an `AuthorizationException` in case the user lacks the necessary permissions. |
| ... | ... | @@ -57,6 +64,14 @@ This requires users trying to access the URL `/api/v1/events` to be authenticate |
| 57 | 64 | Example for a programmatic check: |
| 58 | 65 | SecurityUtils.getSubject().checkPermission("event:view"); |
| 59 | 66 | |
| 67 | +### Special Case: Permission Checks in the AdminConsole |
|
| 68 | + |
|
| 69 | +The `AdminConsolePanel` provides some generic support for permission handling, aiming at customizing the UI to the user's actual permissions. Ideally, a user would only see UI features he/she has the permission to use. In particular, we don't want to bother the user by showing panels he/she isn't permitted to use at all. |
|
| 70 | + |
|
| 71 | +When an administration entry point uses the `AdminConsolePanel`, each widget shown in the panel can be configured to require any of a set of permissions. For example, a panel for managing users would ask for permission `manage_users`. This is actually short for `manage_users:*:*`, a wildcard permission that implies all more specific permissions such as `manage_users:view:*` or `manage_users:edit:peter`. However, a specific permissions such as `manage_users:edit:peter` doesn't imply `manage_users:*:*` by the rules of wildcard permissions. |
|
| 72 | + |
|
| 73 | +The widget shall be shown as soon as the user has any permission for managing users, even only a specific one. It is then up to the implementation of the widget to further constrain user interaction and information displayed, based on the user's actual permissions. To implement this, the permission check for the appearance of administration console widgets is slightly modified: a widget will appear if the permission it requires implies any of the permissions the user has, or if any of the user's permissions implies the permission required by the widget. This way, a user having a specific permission such as `manage_users:edit:peter` will see a widget that requires `manage_users`. Also, a user having the administrator permission `*` will see the same widget because `*` implies all other permissions, particularly `manage_users`. |
|
| 74 | + |
|
| 60 | 75 | ## Standard REST Security Services |
| 61 | 76 | |
| 62 | 77 | There are a number of RESTlets registered under the `/security` context root that allow RESTful clients to log in and log out a user, as well as obtain a bearer access token for a user which can then be used in conjunction with the `bearerToken` / `BearerTokenOrBasicOrFormAuthenticationFilter` authentication filter. These services are described in more detail at [/security/webservices/api/index.html](http://sapsailing.com/security/webservices/api/index.html). |