<div dir="ltr">Great. Thanks Pedro. Let me give this a go. The authorization was the missing piece in KeyCloak and if this can fill in that gap, that's great.</div><br><div class="gmail_quote"><div dir="ltr">On Sat, 30 Jul 2016 at 11:27 Pedro Igor Silva <<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Travis,<br>
<br>
You are not hijacking anything. And I'm also Silva anyways :)<br>
<br>
It is pretty much related. Although different use cases. I need to get more input from Rong before going further.<br>
<br>
Regarding your use case, the answer is yes. I think you can address most of these requirements with our authorization services. For instance, projects are *resources* in Keycloak. You may define a resource that represents a set of one or more resources or have resource instances. In this case, resources instances inherit all permissions. You can also override permissions on a resource-basis as well. Eg.: define specific policies for a scope associated with a resource.<br>
<br>
Here resources can be you projects. You application, which is acting as a resource server, is also allowed to manage their own resources in Keycloak using the Protection API. Which basically provides an API to CRUD resources + other things.<br>
<br>
Scopes can be actions that PM, PMOs, etc, can perform on your resources. Here, you can also specify permissions for each scope individually.<br>
<br>
Both resources and scopes are associated with permissions, which define the authorization policies that should be applied in order to GRANT or DENY access. For last, policies represent the conditions that you actually want to enforce. We have a few policy providers that allows you to use ABAC, RBAC, Javascript, JBoss Rules/Drools, Time constraints, Users, etc. The idea is have introduce more in the future. Eg.: XACML, Group-based, etc.<br>
<br>
There is also an evaluation tool that you can use to simulate authorization requests and check how your permissions and policies are being evaluated. Useful when designing your policies, testing or trying to figure out issues.<br>
<br>
Right now, I'm working on a few improvements. If you want to get latest changes (just sent a PR now), please check both upstream doc and code.<br>
<br>
Regards.<br>
Pedro Igor<br>
<br>
----- Original Message -----<br>
From: "Travis De Silva" <<a href="mailto:traviskds@gmail.com" target="_blank">traviskds@gmail.com</a>><br>
To: "Pedro Igor Silva" <<a href="mailto:psilva@redhat.com" target="_blank">psilva@redhat.com</a>>, "Rong Sang (CL-ATL)" <<a href="mailto:rsang@carelogistics.com" target="_blank">rsang@carelogistics.com</a>><br>
Cc: <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
Sent: Friday, July 29, 2016 9:37:02 PM<br>
Subject: Re: [keycloak-user] How to implement this using Keycloak<br>
<br>
Hi Pedro,<br>
<br>
I have just started looking at the Keycloak Authorization Services that was<br>
introduced in 2.0.0.Final.<br>
<br>
I too have a similar use case. For example, we have a project management<br>
system where projects belong to a project manager. A project manager can<br>
have more than one project. Each project manager has access to only their<br>
own projects.<br>
<br>
Project Managers in turn report to Portfolio Managers. So a Portfolio<br>
Manager should be able to access all his/her project manager's projects.<br>
<br>
At the moment, how we handle this is by having a seperate mapping within<br>
the application and since we build/own the applicaiton, we filter out the<br>
JPA query results based on the above rules.BTW, our services are REST based<br>
(i.e. JAX-RS) KeyCloak is essentially used for Authentication via a<br>
federated LDAP/AD provider and we use Keycloak roles to protect the<br>
services/front end screen options.<br>
<br>
Are you saying that we can filter the data outside the application via Keycloak<br>
Authorization Services? Maybe I need to start looking at the demo examples<br>
a bit more.<br>
<br>
I believe Rong's use case is also the same so hope I have not hijacked this<br>
thread.<br>
<br>
Cheers<br>
Travis<br>
<br>
<br>
<br>
<br>
<br>
On Sat, 30 Jul 2016 at 09:51 Pedro Igor Silva <<a href="mailto:psilva@redhat.com" target="_blank">psilva@redhat.com</a>> wrote:<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<br>
> or just a user claim/attribute ?<br>
> * What is behind: "Users should not have the access to patients<br>
> in a unit that they are not authorized". What "not authorized" really means<br>
> ? What kinds of policies you want to apply ?<br>
><br>
> From what you described, it seems that you can achieve what you want<br>
> with different approaches. It all depends on what you really need and how<br>
> fine-grained you want to be. For instance, units can be represented as<br>
> groups in Keycloak. You can enforce group membership in your application by<br>
> introspecting the bearer token (issued by a Keycloak server to some<br>
> client). The same logic applies if you are using roles or attributes to<br>
> represent units.<br>
><br>
> In 2.0.0.Final, we have introduced Keycloak Authorization Services.<br>
> This one is related with externalized and fine-grained authorization, which<br>
> gives you great flexibility to define, manage, deploy and enforce<br>
> authorization polices to your application and organization. Indeed, one of<br>
> the protocols we are supporting (not fully, yet), UMA, is pretty much based<br>
> on several healthcare use cases. For instance, you can manage the policies<br>
> that apply to patient records in Keycloak and also let Keycloak enforce<br>
> these policies to requests sent to your application. In this case, you can<br>
> define not only a "from unit have access" policy, but also apply even more<br>
> fine-grained policies to your service using the different policy providers<br>
> (ABAC and Context-based, RBAC, Time-based, Rules-based, User-based, more to<br>
> come...) we provide. We are still missing some very nice parts of UMA<br>
> though, as currently we are focusing on API security use cases. But I hope<br>
> to get those missing parts implemented soon.<br>
><br>
> Regards.<br>
> Pedro Igor<br>
><br>
><br>
> ----- Original Message -----<br>
> From: "Rong Sang (CL-ATL)" <<a href="mailto:rsang@carelogistics.com" target="_blank">rsang@carelogistics.com</a>><br>
> To: <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><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<br>
> features work well, but I have the following requirement that cannot find a<br>
> straightforward solution for. I hope some security experts in the mailing<br>
> list can point me to the right direction.<br>
><br>
><br>
><br>
> Here is the requirement. A hospital has multiple units. Users should not<br>
> have the access to patients in a unit that they are not authorized. I have<br>
> one service that returns a list of patients across units. What’s the best<br>
> 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<br>
> idea is greatly appreciated.<br>
><br>
><br>
><br>
> Thanks,<br>
><br>
><br>
><br>
> Rong<br>
><br>
> _______________________________________________<br>
> keycloak-user mailing list<br>
> <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
><br>
> _______________________________________________<br>
> keycloak-user mailing list<br>
> <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</blockquote></div>