Repository navigation
KEYCLOAK-16137 Client Policy : Support New Admin REST API - #188
Conversation
|
@mposolda This PR is about what I mentioned in page 15 of FAPI-SIG 6th Meeting Agenda. I'm afraid I'm not sure whether you are an appropriate person to review it. Could you or your team review this PR? |
There was a problem hiding this comment.
@tnorimat Thanks for the design update!
As discussed already, it will be good to have the concept of "Update client policy as JSON" available from the admin console . Also it will be good to have the concept of preSet/builtin client policies, which won't be updateable. It's nice that your design covers this. However I am not sure about some details - especially if we need separate representation objects for everything and how exactly to track builtin/preSet components and represent them in the realm JSON export etc. This will be good to clarify with @stianst . Some of my thoughs for this are as follows:
-
I think we don't need separate java types like
ClientPolicyConditionRepresentation,ClientPolicyExecutorRepresentationandClientPolicyRepresentation. IMO we can live with the existing type likeComponentRepresentationbut maybe slightly update it for the case of better support of the preSet/builtin policies? -
I think that none of condition, executors and policies need
subTypefield to be available. The policy may needdescription, but IMO conditions and executors does not needdescriptionon itself? -
I understand that it will be good to have some set of "pre-set" policies (built-in policies), which will be set by default. Few points to this:
- Field "subType" is probably not the best place to track whether the clientPolicy is built-in or not. IMO this should be tracked elsewhere as the information if policy is builtin policy is clearly not a "subType" .
- I agree that builtin/pre-set policies should not be creatable/updateable/removable. However IMO we may need at least some way to disable them somehow? WDYT @stianst ?
- Regarding this, I am thinking if we add the fields like "preSet" and "enabled" on the ComponentModel and ComponentRepresentation (or alternatively create subclasses of those with the new fields).
- In the realm export JSON files, we don't need the details about the "preSet" policies. However we may just need the info if the policy is enabled or not. For other manually created policies (those which are not preSet), we need to include full info. In the realm export JSON, we may have just some information like this:
{
"name" : "builtin-policy-xy",
"preSet" : true,
"enabled" : true
},
{
"name" : "builtin-policy-some-other",
"preSet" : true,
"enabled" : false
},
{
"id" : "82d3ec60-f2c0-4965-9825-cf88c59b4c3a"
"name" : "manually-created-policy",
"providerId" : "client-policy-provider",
"description" : "This policy is created for the first test for introducing Client Policy.",
"preSet" : false,
"enabled" : true,
"conditions" : [{
"id" : "047eb7c3-ba5f-45bc-9e27-9ca0d3ae5146",
"name" : "ClientRolesCondition",
"providerId" : "clientroles-condition",
"config" : {"roles" : [ "sample-client-role" ]}
}],
"executors" : [{
"id" : "47e818e3-f0d8-4a90-ace7-1a8b2362cec7",
"name" : "SecureRequestObjectExecutor",
"providerId" : "secure-reqobj-executor",
"config" : {}
}]
}
- In the admin console, we need the ability to show also the executors and conditions of the "preSet" policies. Hence for the REST endpoint for read policies, it will likely need the ability to return all of the informations (including executors and conditions of the particular policy etc). However the REST endpoint for edit may just need the capability for enable/disable the preSet policy and nothing else should be updateable.
|
@mposolda I agree with all points you've mentioned. Some existing provider represented by E.g. KeyProvider |
|
@mposolda As for the "enabled" claim for enabling/disabling the policy, it might be useful for the keycloak administrator to enable/disable the condition and executor. WDYT? |
|
@mposolda As for the "preSet" claim for indicating the policy being pre-set policy, it might be good to mark pre-set condition and executor with this "preSet" claim. The reason why is as follows. When deleting the condition/executor individually, keycloak needs to check whether this condition/executor is under the pre-set policy or not. The condition and executors does not have the information on which policy includes it. Therefore, keycloak needs to look into policies sequentially to find which policy includes the condition/executor to be deleted. It cost a lot. By introducing the marker indicating that the condition/executor is under the pre-set policy , we can avoid this costly operation. |
|
@tnorimat We discuss with @stianst on how to move forward. The preferred way for the client policies would be to have the JSON saved as the realm attribute and have the content of this JSON smaller and directly containing properties of the particular policy/condition/executor. So rather something as a blob. Something similar as described in the User profile design https://github.com/keycloak/keycloak-community/blob/master/design/user-profile.md#default-provider . Format can possibly look like this for our current policies implementations: So instead of using component model and the format of the JSON tight to the component model, we can use this one. In the admin console, we can have just the JSON editor for the first RHSSO 7.5 release. WDYT? |
|
To add to what Marek said. We are looking towards improving REST APIs in the future. The component model, and magnitude of endpoints are just way to complex, and hard to manage. Rather, we are looking at APIs more akin what Kubernetes has. So for client policies there'd be something like: /client-policies -- List all client policies One thing I'm wondering in that regards is if we should make a split between "conditions" and "executors". I can imagine that'd we want to separate those two things. For example we could have a built-in hard-coded "FAPI profile", which essentially is just the list of executors, an admin can then use an exiting "profile" and set the conditions it will apply to. So perhaps it's more something like: /client-policies/policies Where a "profile" would be a list of executors, while a policy would be a list of conditions and refer to one (or more?) profiles. Some profiles would be built-in like "FAPI", and be read-only, while others are defined by admins themselves and are read/write. |
|
@stianst The dividing to "policies" and "profiles" makes sense to me. Few more things to clarify:
With the approach (2), it will be harder to obtain list of all the policies. Unless, we have some convention like the attributes will need to have the prefix. So we would have something like "client.policies.policy1" and "client.policies.policy2" for the case when administrator want to have 2 policies called "policy1" and "policy2" . This looks a bit hacky, so my vote is to go with the approach (1) and just use the single attribute for handle the list of policies. And similarly for the profiles. WDYT?
|
|
Not sure how we should save it, and we should align with how we do it for user profiles. So talk to @pedroigor and figure something out :) Yes, so I'd like to get away from saving default stuff (including auth flows) in the db. These can just be hardcoded in the codebase. Perhaps this is some JSON files included in the dist? Maybe even it could make sense to have a directory on KC server where we can have client policies and user profiles on a global level?!? Just brainstorming on that last part ;) |
|
@stianst Regarding the user profile, there is nothing yet available in Keycloak master? Or is it some work already @pedroigor ? I can summary my understanding how to proceed saving etc. We can align both client policies and user profile to same/similar behaviour regarding storage etc:
WDYT? |
|
@mposolda JSON should be fine and that is what the contributors behind user profile are willing to do. |
|
@tnorimat What do you think? Will it be possible to slightly change the design to align with the above? The example of the "policies" can be maybe like: And profiles like: |
|
@mposolda Basically, I agree with the result of the discussion here. I will start revising the design document along with the result of the discussion. I have a few comments as follows.
|
|
@tnorimat These are good questions. We had some more discussion with @stianst and @pedroigor in this topic. I will try to summary what we discuss. In basics, the idea is Keycloak is secured by default. Hence for example there won't be allowed to configure redirect URL like "*" or create clients with "Full Scope Allowed" enabled etc. Similarly for example PKCE should be enabled/enforced by default for the public clients etc. For this, we may have the profile like "oauth-best-practices" , which will contain some basic set of executors to enforce this. We may have more built-in profiles defined (For example the "fapi-read" profile and "fapi-rw" profile), which will have some different set of executors defined on them. However those "Fapi-*" profiles won't be used by default - administrator will need to bind them to some defined policy with some set of conditions to be applied to. So as you pointed, we may have some policy like "default", which will be enabled and used by default. Policy may just not need have any conditions, so it will be always applied (or alternatively it can have "always-use" condition on it). So the configuration can be like this: Administrator will have a chance to disable this and in that case, it will need to be changed as the attribute on the realm (By default, the built-in policies and profiles don't need to be saved anywhere.) More inline:
Yes, I think we may need to modify existing items to match with this, so that they don't use ComponentModel. You don't need to care about DB migration. For example if your changes are merged to Keycloak master after Keycloak 12 release, it means that Keycloak 12 would be released with ComponentModel used. So people migrating from Keycloak 12 to Keycloak 13 will need to re-create their client policies (no migration support provided). That is fine because Client policies are still "preview" and hence we don't care about backwards compatibility.
+1 , I think that saving the JSON directly inside
+1 as mentioned above
Yes, I think that your proposal is nice and we don't need the ability to enable/disable profiles.
I think we don't need this as we can handle this by just enable/disable policies. For example, if someone wants to enable/disable executor from the existing profile (like for example from "fapi" profile), he may just need to "copy" the existing "fapi" profile and then just remove the target executor from it. A bit similar manner like authenticationFlows when you need to "copy" the flow if you want to add/remove authenticationExecution from it and then you need to "bind" the copy of that flow.
Yes, I think that in the first version, we may need just the ability to CRUD the JSON file directly in the admin console. And this is something, which can be probably relatively easily added to the old admin console as well for now? Just add the new tab "Client policies" next to the tab "Client Registration Policies" and just add the JSON CRUD support in there for policies and CRUD support for profiles - the built-in profiles are not editable. The built-in policies can be just enabled/disabled but not re-configured. Regarding more fine-grained UXD design in the new admin console, we may need to come back to the UXD team once we have more clear this design (and maybe the initial implementation of JSON in the old admin console? I am not sure...) WDYT? |
|
@mposolda Thank you for your comments. I agree with you generally. I have some following comments.
|
+1 for built-in
+1
+1
Yes, this proposal makes a lot of sense to me. I had also some thoughts that it can be likely done this way. So +1 for doing it like this.
+1 |
|
@mposolda Thank you for your comments. It seems that all discussion points are clarified so that I will revise the design document by incorporating these points. |
|
@tnorimat Cool, Thanks! |
d509024 to
31b2316
Compare
|
@mposolda I've updated the document. Could you check whether the updated version of this document incorporates all what we have discussed? If this PR is merged, I'll start implementing new Admin REST APIs for Client Policies by following this document. |
There was a problem hiding this comment.
@tnorimat Thanks a lot! I am approving and merging your PR.
I've added just one inline comment regarding the old admin console: Basically knowing that old admin console will be removed soon, I suggest you to not spend much time on tweaking the old admin console. If needed, only add the parts related to JSON edit, but maybe even that is not needed at all... As long as we have REST endpoints, we are good to go.
| Admin REST API for Client Policies are designed to satisfy the following requirements. | ||
|
|
||
| - keycloak admin can view and update the client policy on the editable textarea UI (editing JSON representation directly). | ||
| - keycloak admin can control policies, conditions and executors on the ordinal UI (e.g. like the existing Client Registration Policy). |
There was a problem hiding this comment.
Just a note, that there is a question how to implement these points because the new admin console is in the design right now, but it is not yet ready... So if you want to start implementation of these points, you may not yet be able to add support in the admin console UI of new admin console as it is not ready yet...
If you implement some support to the old admin console, I suggest to add here only the editing by JSON to be able to test client policies with the old admin console.
There was a problem hiding this comment.
@mposolda Thank you for your comment.
AFAIK, the situation for the New Admin Console are as follows.
- The New Admin Console has not yet appeared on the keycloak's master branch, which means that I can not know how to implement the UI for any kind of keycloak's feature on this New Admin Console.
- The UI design for Client Policies on the New Admin Console has not yet been fixed. It has been pending because the design for the New Admin REST API for Client Policies had not yet been approved and merged.
Considering these points, I would like to work on the support of New Admin REST API as follows.
- Resume discussion on the UI design for Client Policies on the New Admin Console (https://marvelapp.com/prototype/6e70eh2/screen/74918976) and fix it.
- In parallel, Implement the New Admin REST API for Client Policies by following this merged design document.
- After completing 1 and 2, if the New Admin Console appears on the keycloak's master branch, implement the UI for Client Policies on the New Admin Console. If not, implement the UI for Client Policies on the existing Admin Console (only editable JSON).
There was a problem hiding this comment.
@tnorimat Your proposal sounds great to me. Thanks!
There was a problem hiding this comment.
@tnorimat FYI. The new admin console is being developed in its own repo: https://github.com/keycloak/keycloak-admin-ui
I agree with @mposolda that your proposal is good. If you want this functionality soon then it will need to go into old admin console.
There was a problem hiding this comment.
@ssilvert Thank you for your comment. I would like to check https://github.com/keycloak/keycloak-admin-ui .
This PR is for KEYCLOAK-16137 Client Policy : Support New Admin REST API. It is part of the work for realizing Client Policy Official Support as FAPI-SIG activity.
This PR adds description of new Admin REST API for Client Policies to the existing Client Policies' design document.