Skip to content

Grant Management - #23

Draft
guymoyo wants to merge 17 commits into
tnorimat:mainfrom
guymoyo:grant_management
Draft

Grant Management#23
guymoyo wants to merge 17 commits into
tnorimat:mainfrom
guymoyo:grant_management

Conversation

@guymoyo

@guymoyo guymoyo commented May 20, 2021

Copy link
Copy Markdown

In the scope of this PR, I would like to show the conception of Grant Management.
Please note, it's not totally complete. If the conception is correct (I will go on then), if there are some advice or propositions - feel free to comment. Thank you!

Draft design: keycloak/keycloak-community#265

spec: https://openid.net/specs/fapi-grant-management-01.html

@guymoyo guymoyo changed the title grant management initial commit Grant Management May 20, 2021
Comment thread model/jpa/src/main/java/org/keycloak/grant/jpa/impl/GrantServiceImpl.java Outdated
@tnorimat
tnorimat self-requested a review May 20, 2021 23:53
@tnorimat

Copy link
Copy Markdown
Owner

Hello @guymoyo ,
Thank you for your implementation. I will review it and add comments afterwards.

@tnorimat tnorimat left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guymoyo I've reviewed this PR and add some review comments. Could you check them?

Comment thread core/src/main/java/org/keycloak/representations/AccessTokenResponse.java Outdated
Comment thread services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocolService.java Outdated
Comment thread server-spi-private/src/main/java/org/keycloak/models/GrantService.java Outdated
Comment thread model/jpa/src/main/java/org/keycloak/grant/jpa/impl/GrantServiceImpl.java Outdated
Comment thread model/jpa/src/main/java/org/keycloak/grant/jpa/UserGrantEntity.java Outdated
@guymoyo
guymoyo force-pushed the grant_management branch 2 times, most recently from 62ae006 to a6f786e Compare June 2, 2021 13:37
@guymoyo
guymoyo force-pushed the grant_management branch from a6f786e to 3eebd37 Compare June 2, 2021 13:45
@guymoyo

guymoyo commented Jun 16, 2021

Copy link
Copy Markdown
Author

Hi @tnorimat, I made some changes. I added the possibility to select 'grant_id_supported' in the admin UI, also I changed the logic of this grant flow, IMO I think it makes more sense to go with 'RequiredActionProvider', WDYT?

There is some cross logic with the RAR, you will see that as comments in code.

@tnorimat

Copy link
Copy Markdown
Owner

Hello @guymoyo ,

As you've proposed, it is good to use Required Action instead of coding onto login service flow.

One point I would like to notice is as follows.

As discussed previously, to implement newly introduced User Grant, the following relationship is assumed.

Consent 1 --- 1 Grant

The current keycloak's Consent has the following relationship.

{Client, User} 1 --- 1 Consent

Therefore, the following relationship is newly introduced.

{Client, User} 1 --- 1 Consent 1 --- 1 Grant

I'm afraid that what you want to do by Grant Management is achieved under this relationship.

@guymoyo

guymoyo commented Jun 21, 2021

Copy link
Copy Markdown
Author

Hello @tnorimat,
Yes, you're right, consent is an agreement between a User and a Client. And the grant will extend that with fine-grained authorization. Therefore when the consent is canceled, all it's extended should be cancel/delete.

I would like to try this:

grant representation

` {

	"grantId" : ""

	"consentId" : "" // should be not null

	"clientId" : ""  // for quick access

	"userId" : ""   // for quick access

	"authorization_details" : {}

	"scopes" : []   // this scopes should be less than consent->grantedClientScopes

	"claims" : []   // same for the claims

	"createdDate" ""

	"lastUpdatedDate" ""
}`

if we delete a consent, all grants with that consent will be deleted.

When creating the grant, if there is not yet consent between that Client and that User, it will be created implicitly.

@tnorimat

Copy link
Copy Markdown
Owner

Hello @guymoyo ,

Thank you for your clarification.

@guymoyo

guymoyo commented Jun 28, 2021

Copy link
Copy Markdown
Author

TODO:

  • Incorporates the updates from the latest grant management publication (23.06.01)
  • Avoid modifying RealmModel directly and follow CibaConfig for the spec param
  • GrantEndpoint should follow --> CibaRootEndpoint concept
  • Code redundancies for checking should be removed and make usage of this pull request
  • Make grant and consent working like described in a comment upper
  • Remove unnecessary code, space ...
  • Write test
  • write documentation

Hi @tnorimat, here some tasks that I will continue working on, please feel free to add anything pertinent.

@guymoyo
guymoyo force-pushed the grant_management branch from b7d62c7 to a40fc66 Compare July 6, 2021 18:35
gmo added 9 commits July 6, 2021 20:44
# Conflicts:
#	core/src/main/java/org/keycloak/protocol/oidc/representations/OIDCConfigurationRepresentation.java
#	core/src/main/java/org/keycloak/representations/AccessTokenResponse.java
#	core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java
#	model/jpa/src/main/resources/META-INF/jpa-changelog-13.0.0.xml
#	server-spi-private/src/main/java/org/keycloak/events/Errors.java
#	server-spi-private/src/main/java/org/keycloak/models/utils/RepresentationToModel.java
#	server-spi/src/main/java/org/keycloak/models/UserModel.java
#	services/src/main/java/org/keycloak/protocol/oidc/OIDCConfigAttributes.java
#	services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java
#	services/src/main/java/org/keycloak/protocol/oidc/OIDCWellKnownProvider.java
#	services/src/main/java/org/keycloak/protocol/oidc/endpoints/AuthorizationEndpoint.java
#	services/src/main/resources/META-INF/services/org.keycloak.authentication.RequiredActionFactory
@guymoyo

guymoyo commented Jul 14, 2021

Copy link
Copy Markdown
Author

Hi @tnorimat, I made some refactoring, can you please check again?

@tnorimat

Copy link
Copy Markdown
Owner

Hello @guymoyo ,
Yes, I will check your revised codes.

@tnorimat

Copy link
Copy Markdown
Owner

@guymoyo I will check them completely, but I have one suggestion at this time.

As the same as PAR and CIBA, it might be better for this grant management to be provided as preview feature.

WDYT?

@guymoyo

guymoyo commented Jul 15, 2021

Copy link
Copy Markdown
Author

@guymoyo I will check them completely, but I have one suggestion at this time.

As the same as PAR and CIBA, it might be better for this grant management to be provided as preview feature.

WDYT?

Yes, you're right, I forgot to change. I will change.

*
* @return
*/
@Path("query")

@guymoyo guymoyo Jul 15, 2021

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tnorimat, the request to query a grant should be something like this

https://as.example.com/grants/TSdqirmAxDa0_-DB_1bASQ

and not

https://as.example.com/grants/query/TSdqirmAxDa0_-DB_1bASQ

but following the CIBA endpoint concept, I have no choice to give a path here.
do you have an idea how can we solve that?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but does the following work?

    @Path("/{grant_id}")
    @GET

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it doesn’t work.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I will find other solution.

*
* @return
*/
@Path("revoke")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as @Path("query")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but does the following work?

    @Path("/{grant_id}")
    @DELETE

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, it doesn’t work.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I will find other solution.

@tnorimat tnorimat left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guymoyo I've added some review comments. Could you check them?

Comment thread server-spi-private/src/main/java/org/keycloak/models/Constants.java Outdated
Comment thread server-spi-private/src/main/java/org/keycloak/protocol/LoginProtocol.java Outdated
Comment thread server-spi/src/main/java/org/keycloak/models/RealmModel.java
@guymoyo

guymoyo commented Jul 19, 2021

Copy link
Copy Markdown
Author

Hi @tnorimat, I made the changes but still having this problem with the path of the grant management endpoint.

@tnorimat

Copy link
Copy Markdown
Owner

@guymoyo As I added comments, I will find other solution for the final issue.

@guymoyo

guymoyo commented Sep 8, 2021

Copy link
Copy Markdown
Author

Hi @tnorimat, may this help to have a good overview on Relation Grant vs Consent

@tnorimat

tnorimat commented Sep 8, 2021

Copy link
Copy Markdown
Owner

Hello @guymoyo ,

Thank you for your reference https://bitbucket.org/openid/fapi/issues/442/grant-vs-consent-confusion ,
I will follow this discussion thread. I've looked it at a glance and found that it might be needed to discuss the definition of Consent and Grant by considering their nature and the relationship between them.

From your implementer's side, is it better to have relationship Consent 1 --- * Grant ?

@guymoyo

guymoyo commented Sep 8, 2021

Copy link
Copy Markdown
Author

Hello @guymoyo ,

Thank you for your reference https://bitbucket.org/openid/fapi/issues/442/grant-vs-consent-confusion ,
I will follow this discussion thread. I've looked it at a glance and found that it might be needed to discuss the definition of Consent and Grant by considering their nature and the relationship between them.

From your implementer's side, is it better to have relationship Consent 1 --- * Grant ?

Yes from the implementer's side, I think it is better to go in this way and it is actually implemented like that in this branch. but it can be changed if we have another clear relation view.

tnorimat pushed a commit that referenced this pull request Feb 11, 2024
test: adding unit tests for flat, structured and recursive disclosure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants