Skip to content

Latest commit

 

History

History
147 lines (76 loc) · 6.17 KB

KEYCLOAK.md

File metadata and controls

147 lines (76 loc) · 6.17 KB

Some first words

As you can see in the deployment, we provided the default user_name and password are admin/admin. We know it looks insecured but we want to make it as simple as possible so you can update it later in the docker-compose.yaml file. Just don’t forget that is the authentication for the Master realm in Keycloak.

Entering the system

Enter the Keycloak, go to http://localhost:8080/auth. Normally, the default location for Keycloak is http://localhost:8080/auth, but in this project we use nginx as a gateway, so please do not confuse.

Then click Administration Console, to go to the Master realm login screen.

In the Master realm login screen, use username and password as provided before. In this case, it is admin/admin.

In the Master realm UI, create the vinlab realm for the project by clicking into the drop down menu at the top left corner near the realm's name. Then, click Add realm

Master

Type vinlab then click Create.

Add Realm

Here is the result

View Realm

Roles

Now, we go ahead to another element of the system: Roles. In the Vinlab, we provided roles as follows: PO, PO_PARTNER, ANNOTATOR, REVIEWER, GUEST.

View Roles

To create a new role, go to the Roles function in the left panel, the click Add role to create a new role.

Add Roles

Clients

This part is a bit more complicated. Vinlab includes 2 components, vinlab-frontend and vinlab-backend, corresponding to 2 clients.

View Client

To create a new OIDC client go to the Clients item at the left menu. On this page you’ll see a Create button on the right.

View Add Client

Go to the Scope tab of the vinlab-frontend client, verify that Full Scope Allowed toggle is checked. It should be changed but to make everything smooth, leave it here.

Add Scope

It can be considered that the creation of vinlab-frontend is done from here.

View Client

Now comes the slightly more complicated part, the vinlab-backend client. Similar to the steps above, install vinlab-backend. However, in the client configuration section, you have to change some settings:

  • Access Type: from public to confidential
  • Turn on Service Accounts Enabled and Authorization Enabled Then click Save.

View Client

There is one more thing to do in this step, for the vinlab-frontend client, go to the Mappers tab then create a new mapper object by clicking Add Builtin button.

Add Client

You will see some new items named realm roles, audience resolve in the list. Check them and click Add selected. The page will back to Mappers tab. Click the realm roles then activate the Add to userinfo, Add to ID token toggle and change Token Claim Name to realm_roles.

Add Mapper

Finally we have

Add Client

Authorizing Permissions

Now, here is the interesting part. You will create some of the Authorization rules for the project. Select realm roles from the list then hit Add selected.

Authorization Scopes

Firstly, we initialize the Authorization Scopes. Then click the Create button to create a new scope. We have 4 common scopes following the CRUD: create, read, update, delete. After that, we got:

View Scopes

Resources

Secondly, go to Authorization/Resources

Then click the Create button to go to the Add Resource window. Please focus on the fact that we have resources: accounts, annotations, labels, label_groups, projects, tasks, objects, stats, sessions, studies, label_exports because you are going to create all of these. For each type of resources, we provide totally 4 scopes:

Add Resources

After all, here is the result:

View Resources

Policies

Thirdly, Policies coming. Click the Create Policy… button, select Role in the drop-down list.

View Policies

To create a new policy, it will match with the role of the realm. For example:

Add Policies

After that, we got 5 policies are represented as 5 roles.

View Policies

Permission

Finally, after resource, scope and policies, we create a new Permission.

View Permission

Click the Create Permission… button and select Scope-Based option. For example, we have Create Studies permission. Remember, after Name, Resource, Scope and Apply Policy, set the Decision Strategy to Affirmative.

Add Permission

And final result

View Permission

Users

Now turn to the Users section in the left menu.

View Users

Then click Add user button

Add Users

Create a new username Turn to the Credentials tab, set the password you want, make sure you got it and Set Password.

Add Users

Calm down, there is another small step. Go to Role Mappings tab, the assign PO role to this account.

View Users

And here we go!

=========

More information, please visit user guide of Keycloak.