Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP-0005 JWT RBAC #18

Merged
merged 6 commits into from
Jun 8, 2017
Merged

MP-0005 JWT RBAC #18

merged 6 commits into from
Jun 8, 2017

Conversation

starksm64
Copy link
Contributor

Proposal for a MicroProfile specification

! DO NOT MERGE this Pull Request BEFORE REVIEW is finished!

Merging this Pull Request means that the proposal is officially accepted by the MicroProfile Core Team as a MicroProfile incubation project. A public discussion and an agreement within the MicroProfile Core Team is expected before a proposal is accepted/rejected.

If this PR is not a proposal for a new specification, delete this template description.

Suggested steps to follow before this proposal is accepted

  • add label proposal to this PR on github
  • initiate a public discussion on the mP mailing list
    • Email Subject: "Review announcement: <<PROPOSAL_NAME>>"
    • Email Body: Based on review announcement template
      • fill in <<PROPOSAL NAME>>, <<REVIEW END DATE>> (not mandatory, can be announced later, but should be at least 7 days after the announcement email is sent)
        and <<REVIEW MANAGER NAME>> (the name of the sender)
      • update the link to a proposal (NNNN-proposal.md) to point to this Pull Request

After the review, the Core Team should form an agreement whether or not to accept the proposal, or whether ask its author for amendments.

Once this Pull Reuest is merged, the proposal is considered accepted and an incubation repository should be created to facilitate collaboration.

@starksm64 starksm64 changed the title [Review] MP-0005 JWT RBAC MP-0005 JWT RBAC Mar 11, 2017

## Motivation

MicroProfile 1.1 is a baseline platform definition that optimizes Enterprise Java for a microservices architecture and delivers application portability across multiple MicroProfile runtimes. While Java EE is a very feature rich platform and is like a toolbox that can be used to to address a wide variety of application architectures, MicroProfile focuses on defining a small and a minimum set of Java EE standards that can be used to deliver applications based on a microservice architecture, are they:
Copy link
Contributor

Choose a reason for hiding this comment

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

  • they are (last two words)
  • I'm not sure we've defined what MP 1.1 is

Copy link
Member

Choose a reason for hiding this comment

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

The content ofr MP 1.1 was proposed on Jan 16th on this thread:

Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the on going discussions, I think it would be better if each spec removed references to the MP version they're planning to associate to, since it looks like we're going to the big bang EE route and proposing umbrella specs to pull things together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

* CDI
* JSON-P

The security requirements that involve microservice architectures are strongly related with RESTful Security. In a RESTful architecture style, services are usually stateless and any security state associated with a client is sent to the target service on every request in order to allow services to re-create a security context for the caller and perform both authentication and authorization checks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you able to cite this? It seems that both per-request and maintaining session state are used, so I'm not sure we can make this claim.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is just the original stateless requirement from Fielding's original work:
https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm


## Impact on existing code (if applicable)

Existing services that desire to implement JWT RBAC must configure the container to support integration with an authorization implementation that is capable of parsing the JWT bearer token to validate the token and populate a security context with the caller and granted roles for use in ```getCallerPrincipal()/getUserPrincipal(), isCallerInRole(String)/isUserInRole(String)``` type of container methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

For the methods here, while we can leverage them, would it make more sense to have a dedicated domain around user that could solve these method calls as well?

Choose a reason for hiding this comment

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

  1. nonce: The "nonce" claim in ID_Token is unmodified authentication request parameter to mitigate replay attack. How does JWT receiver interpret this claim? Use it as normal "nonce" for replay attack prevention? Do we expect token be reused?
    For JWT, the "jti" claim is commonly used in replay mitigation. Should we suggest "jti" as alternative to "nonce"
  2. preferred_username: Comparing to other claims, "preferred_username" is very long. What is the definition and intended usage? How about those names like "upn", or "username", or "user", or "login"? Maybe we should have 2 claims, "user" or "username" or "preferred_name", and "upn" or "principal" or "unique_name" or "uid"?
  3. "realm_access": If "role" in "realm_access" is similar or equivalent to the "role" in J2EE security, that represents all service roles that the subject has been granted, why do not we remove "realm_access", and simply use "roles" claim.
  4. "resource_access": To me, this claim is more like OAuth "scope". Can you explain the difference between "resource_access" and "scope"?
    We believe that following claims are also very useful
  5. "groups": Although "roles" claim represents service roles a subject has been granted, this requires existing service is re-written or packaged in order to use JWT. We believe that we should offer alternative option of "group" claim to allow existing service to map service role to "group". This also allows service to decouple authorization and authentication.
  6. scope: allow scope claim in JWT.

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be helpful to outline how this would affect the microprofile conference service sample. That has 4 micro services written by 4 different groups on 4 different runtimes, so if we can relate how this would help have a JWT token issued once be available and understood by the individual runtimes and services I think that would help people understand the proposal. Certainly for those of us who are not as familiar with JWT.

Choose a reason for hiding this comment

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

Existing services that desire to implement JWT RBAC must configure the container to support integration with an authorization implementation that is capable of parsing the JWT bearer token to validate the token and populate a security context with the caller and granted roles for use in getCallerPrincipal()/getUserPrincipal(), isCallerInRole(String)/isUserInRole(String) type of container methods.

The heavy lifting for setting up this context for use in getCallerPrincipal()/getUserPrincipal() etc has been done by Soteria/JSR 375, so by taking advantage of that this task would basically be trivial.

@rdebusscher even did an initial POC for parsing the JWT bearer token and from it populate the above mentioned security context. See https://github.com/rdebusscher/soteria-jwt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NottyCode, Ok, I'll write that up.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry to jump into the discussion at such a late point.

I see in the proposal a very good description of the JWT and "protocol" which will be used to communicate the authentication/authorization information to some endpoint.

But will be there a description how the info (username, roles, ...) will be transferred to the "container"?
When using
@Inject private Principal;
there will be access to the username, but not to the "roles".

There was a mentioning of using Soteria/JSR-375 which is mainly a layer on top of JASPIC (and JACC). Going that way, we specify that every MicroProfile compliant server will need those specs. Which is not recommended in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rdebusscher we wont' get into that until the spec starts to get written. proposals are not specs.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the clarification about the process.

JWT and the info that was written in the proposal is absolutely fine for me.

Choose a reason for hiding this comment

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

Thanks @johnament for clarification of spec process. We are good for the proposal to start the spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will certainly address the details of what the claims are named and how they need to map to the standard container APIs in the tck of the jwt-auth repository.

@arjantijms
Copy link

arjantijms commented May 30, 2017 via email

@rdebusscher
Copy link
Member

rdebusscher commented May 30, 2017 via email

@arjantijms
Copy link

arjantijms commented May 30, 2017 via email

@johnament
Copy link
Contributor

@rdebusscher @arjantijms while these are great comments, we're getting into how the spec is going to work. The goal of the proposal is to say " we want to do something with JWT " not "this is how we're going to use JWT"

@mikecroft mikecroft merged commit 82b65a1 into eclipse:master Jun 8, 2017
@mikecroft
Copy link
Member

Merged after successful vote:
https://groups.google.com/forum/#!topic/microprofile/z0gen1KcThc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants