<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:MingLiU;
        panose-1:2 2 5 9 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Calibri;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">I will research the KeycloakSecurityContext class then. I can see that including the “unit” id in the path is another way to go. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Yes, I’m using a role-based policy, but instead of applying to individual patients, I apply the policy to a resource represents all patients. In essence, any user with any “unit” role can
access the resource, but the filter mechanism described earlier returns the right set of patients for the user. Any better ideas?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Regards.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-family:Calibri;color:black">From: </span>
</b><span style="font-family:Calibri;color:black">Pedro Igor Silva <psilva@redhat.com><br>
<b>Date: </b>Monday, August 1, 2016 at 12:26 PM<br>
<b>To: </b>rongsang <rsang@carelogistics.com><br>
<b>Cc: </b>Travis De Silva <traviskds@gmail.com>, "keycloak-user@lists.jboss.org" <keycloak-user@lists.jboss.org><br>
<b>Subject: </b>Re: [keycloak-user] How to implement this using Keycloak<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">In this case, I think you can just obtain the KeycloakSecurityContext, get the roles from there and then filter patients. Don't think you need a request header for that.<br>
<br>
The KeycloakSecurityContext is attached to the request as an attribute. So you just need to obtain it as follows:<br>
<br>
KeycloakSecurityContext keycloakSecurityContext = (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName());<br>
<br>
Also, maybe you could do the filtering by having the "unit" id in your path. In this case, the client would just invoke your API passing the "unit" id and get the patients.<br>
<br>
So, are you already using our authorization services to enforce policies to individual patients ?<br>
<br>
Regards.<br>
<br>
----- Original Message -----<br>
From: "Rong Sang (CL-ATL)" <rsang@carelogistics.com><br>
To: "Pedro Igor Silva" <psilva@redhat.com>, "Travis De Silva" <traviskds@gmail.com><br>
Cc: keycloak-user@lists.jboss.org<br>
Sent: Monday, August 1, 2016 12:12:16 PM<br>
Subject: Re: [keycloak-user] How to implement this using Keycloak<br>
<br>
Hi Pedro,<br>
<br>
Thank you for your quick response! Travis… thank you for chiming in too. I agree your use case is the same as mine. Let me first answer Pedro’s questions, and then I explain my use cases in detail.<br>
<br>
* Are you the service owner ? Answer: yes, we have the full control of the API.<br>
* Is your service using a REST-style ? How the API looks like ? Answer: it is a REST-style service.<br>
* Is your service already protected using a bearer token ? Answer: yes, more details below.<br>
* How are you representing the user's unit ? Realm, Group, role or just a user claim/attribute ? Answer: Group and role, more details below.<br>
* What is behind: "Users should not have the access to patients in a unit that they are not authorized". What "not authorized" really means ? What kinds of policies you want to apply ? I explain this in the following description of my use case.<br>
<br>
In my application, I have patients who stay in the hospital for overnight treatments. They stay in various units based on their diagnosis and treatment plans. In each unit, there are nurses, who are the users of my application. To protect patients’ privacy,
a nurse can only view the information of patients who stay in her unit. If a patient is not in the unit that the nurse works in, the nurse should be denied the access to the patient’s information.<span style="font-family:MingLiU"><br>
<br>
</span>Nurse information is stored in a LDAP server. I use Keycloak LDAP module to sync users/groups, and do group-to-role mappings in Keycloak too. Doing so, I will know which nurse works in which units.<br>
<br>
I use OAuth tokens for authentication in Keycloak. I use the UMA features for fine-grained authorization. The patient service in my application returns the patient records. Because the service is a REST service, I use a bearer token to protect it. Because I
want the service to “filter” the returned patient records based on user’s units (or roles that represent units), I will need to get the units or roles somehow. I think the roles can be a part of the bearer token passed to the server<br>
<br>
Here is the api for now. The endpoint is “/patients”, the user/roles information is embedded in the bearer token. I think I can extract roles from the token and map the request to an API call getPatients(units). Here the “units” is equivalent to “roles”.<span style="font-family:MingLiU"><br>
<br>
</span>I think it will be easier if the Keycloak adapter can extract roles and set them in a new request header for me. When the request is mapped to the API call, mapping the roles (filters) is just like mapping a regular request header.<span style="font-family:MingLiU"><br>
<br>
</span>Do you think this is a far-fetched idea? Or do you have better ideas to archive the similar effect?<br>
<br>
Thanks!<br>
<br>
Rong<br>
<br>
<br>
<br>
<br>
From: Pedro Igor Silva <psilva@redhat.com><br>
Date: Friday, July 29, 2016 at 7:50 PM<br>
To: rongsang <rsang@carelogistics.com><br>
Cc: "keycloak-user@lists.jboss.org" <keycloak-user@lists.jboss.org><br>
Subject: Re: [keycloak-user] How to implement this using Keycloak<br>
<br>
Hi Rong,<br>
<br>
Can you provide more details about your use case ? For instance:<br>
<br>
* Are you the service owner ?<br>
* Is your service using a REST-style ? How the API looks like ?<br>
* Is your service already protected using a bearer token ?<br>
* How are you representing the user's unit ? Realm, Group, role or just a user claim/attribute ?<br>
* What is behind: "Users should not have the access to patients in a unit that they are not authorized". What "not authorized" really means ? What kinds of policies you want to apply ?<br>
<br>
From what you described, it seems that you can achieve what you want with different approaches. It all depends on what you really need and how fine-grained you want to be. For instance, units can be represented as groups in Keycloak. You can enforce group membership
in your application by introspecting the bearer token (issued by a Keycloak server to some client). The same logic applies if you are using roles or attributes to represent units.<br>
<br>
In 2.0.0.Final, we have introduced Keycloak Authorization Services. This one is related with externalized and fine-grained authorization, which gives you great flexibility to define, manage, deploy and enforce authorization polices to your application and organization.
Indeed, one of the protocols we are supporting (not fully, yet), UMA, is pretty much based on several healthcare use cases. For instance, you can manage the policies that apply to patient records in Keycloak and also let Keycloak enforce these policies to
requests sent to your application. In this case, you can define not only a "from unit have access" policy, but also apply even more fine-grained policies to your service using the different policy providers (ABAC and Context-based, RBAC, Time-based, Rules-based,
User-based, more to come...) we provide. We are still missing some very nice parts of UMA though, as currently we are focusing on API security use cases. But I hope to get those missing parts implemented soon.<br>
<br>
Regards.<br>
Pedro Igor<br>
<br>
<br>
----- Original Message -----<br>
From: "Rong Sang (CL-ATL)" <rsang@carelogistics.com><br>
To: keycloak-user@lists.jboss.org<br>
Sent: Friday, July 29, 2016 5:23:20 PM<br>
Subject: [keycloak-user] How to implement this using Keycloak<br>
<br>
<br>
<br>
Hi all,<br>
<br>
<br>
<br>
I’m doing a POC using Keycloak. The normal authentication/authorization features work well, but I have the following requirement that cannot find a straightforward solution for. I hope some security experts in the mailing list can point me to the right direction.<br>
<br>
<br>
<br>
Here is the requirement. A hospital has multiple units. Users should not have the access to patients in a unit that they are not authorized. I have one service that returns a list of patients across units. What’s the best way to set up authorization for this
service?<br>
<br>
<br>
<br>
As I said earlier, I cannot find a feature for me to implement this. Any idea is greatly appreciated.<br>
<br>
<br>
<br>
Thanks,<br>
<br>
<br>
<br>
Rong<br>
<br>
_______________________________________________<br>
keycloak-user mailing list<br>
keycloak-user@lists.jboss.org<br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user">https://lists.jboss.org/mailman/listinfo/keycloak-user</a>><o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>