...
Define roles in the database for a confluence user
Use the following commands to create user, role and grant the privileges to the role. The commands work for PostgreSQL database. You may need to contact your DB administrator for the respective commands if you are using other database.
- create user bob; /* bob is a confluence user whose user id/username in confluence is bob
- create role dbrole ;
- grant dbrole to bob ;
- grant SELECT ON cwd_group to dbrole ; /* you are granting the "SELECT" operation for the table cwd_group to the role "DB_role"
...
Let's say you have an application data source already defined in server.xml (as shown in screenshot below), for which you want to implement this role based security. Follow the steps below:
- Go to UPM and find the SQL for Confluence add-on (Manage add-onsapps).
- Click the Configure button.
- To Select the View and modify data source profiles tab. To add a role based security datasource, use dataSource parameterselect the data source as required. Refer to the screenshot below:
The new profile (in this case "rolebased") is available immediately. Test it on a page to ensure expected behavior.
...
Since select on "cwd_group" table is granted to bob, only the respective data is visible but not "cwd_user" table data.
- If any other user (lets say random user who has no database role associated to their own account/userid) tries to access the page:
Since there is no role associated with this user, an error message will be shown.