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

Update playground app to support ID Token encryption #2313

Merged
merged 1 commit into from
Feb 15, 2018
Merged

Update playground app to support ID Token encryption #2313

merged 1 commit into from
Feb 15, 2018

Conversation

vihanga-liyanage
Copy link
Contributor

@vihanga-liyanage vihanga-liyanage commented Feb 13, 2018

Proposed changes in this pull request

  • Main changes proposed are the UI and the backend servlets that can decrypt JWE id tokens. User can provide the private key of the client and the decrypted id token header and claims data will be displayed.

image

In reference to wso2/product-is#2336

When should this PR be merged

No dependencies. We can merge this ASAP.

Follow up actions

N/A

Checklist (for reviewing)

General

  • Is this PR explained thoroughly? All code changes must be accounted for in the PR description.
  • Is the PR labeled correctly?

Functionality

  • Are all requirements met? Compare implemented functionality with the requirements specification.
  • Does the UI work as expected? There should be no Javascript errors in the console; all resources should load. There should be no unexpected errors. Deliberately try to break the feature to find out if there are corner cases that are not handled.

Code

  • Do you fully understand the introduced changes to the code? If not ask for clarification, it might uncover ways to solve a problem in a more elegant and efficient way.
  • Does the PR introduce any inefficient database requests? Use the debug server to check for duplicate requests.
  • Are all necessary strings marked for translation? All strings that are exposed to users via the UI must be marked for translation.

Tests

  • Are there sufficient test cases? Ensure that all components are tested individually; models, forms, and serializers should be tested in isolation even if a test for a view covers these components.
  • If this is a bug fix, are tests for the issue in place? There must be a test case for the bug to ensure the issue won’t regress. Make sure that the tests break without the new code to fix the issue.
  • If this is a new feature or a significant change to an existing feature? has the manual testing spreadsheet been updated with instructions for manual testing?

Security

  • Confirm this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • Are all UI and API inputs run through forms or serializers?
  • Are all external inputs validated and sanitized appropriately?
  • Does all branching logic have a default case?
  • Does this solution handle outliers and edge cases gracefully?
  • Are all external communications secured and restricted to SSL?

Documentation

  • Are changes to the UI documented in the platform docs? If this PR introduces new platform site functionality or changes existing ones, the changes should be documented.
  • Are changes to the API documented in the API docs? If this PR introduces new API functionality or changes existing ones, the changes must be documented.
  • Are reusable components documented? If this PR introduces components that are relevant to other developers (for instance a mixin for a view or a generic form) they should be documented in the Wiki.


ServletOutputStream out = response.getOutputStream();

if (idToken.equals("") || privateKeyString.equals("")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When the id_token is empty this will return "Client private key cannot be empty!".
Better to do separate checks or change the error message to say "Client private key and id_token cannot be empty!"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do separate checks.

json.put(entry.getKey(), entry.getValue());
}

out.print(json.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we are sending the payload of the JWT.
What about the JWT header? Shouldn't we display it as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we can. But the header comes as an object. We'll have to build a JSON with info we need to display.

try {
name = SignedJWT.parse(idToken).getJWTClaimsSet().getSubject();
} catch (Exception e) {
//ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we at least log the exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was already there before me. What should be the best way? Can we log them since this is a jsp?

@darshanasbg darshanasbg merged commit 90a60ec into wso2:5.5.x Feb 15, 2018

jwt.decrypt(decrypter);

return jwt;
Copy link
Contributor

Choose a reason for hiding this comment

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

In this method, actually what is happening is returning a decrypted jwt.
But the return type is set to 'EncryptedJWT'. What is actually happening(decrypting) and the retrun value(Encrypted) seems contradictory.
Can you please explain this behavior? or can we fix it properly to match the flow.

@@ -307,24 +459,24 @@

<tr>
<td><label>Client Id : </label></td>
<td><input type="text" id="consumerKey" name="consumerKey" value="<%=consumerKey%>" style="width:350px"></td>
<td><input type="text" id="consumerKey" name="consumerKey" value="<%=consumerKey%>" style="width:450px"></td>
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we use Encode.forHtmlAttribute(consumerKey)?

@@ -440,21 +592,21 @@
</tr>
<tr>
<td>Callback URL :</td>
<td><input type="text" id="callbackurl" name="callbackurl" value="<%=callbackUrl%>" style="width:350px"></td>
<td><input type="text" id="callbackurl" name="callbackurl" value="<%=callbackUrl%>" style="width:450px"></td>
Copy link
Contributor

Choose a reason for hiding this comment

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

lets use Encode.forHtmlAttribute(callbackUrl) to prevent possible XSS attacks

</tr>
<tr>
<td>Access Token Endpoint :</td>
<td><input type="text" id="accessEndpoint" name="accessEndpoint" value="<%=accessTokenEndpoint%>" style="width:350px"></td>
<td><input type="text" id="accessEndpoint" name="accessEndpoint" value="<%=accessTokenEndpoint%>" style="width:450px"></td>
Copy link
Contributor

@denuwanthi denuwanthi Oct 25, 2018

Choose a reason for hiding this comment

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

shall we use Encode.forHtmlAttribute()?

</tr>
<tr>
<td><label>Client Secret : </label></td>
<td><input type="password" id="consumerSecret" name="consumerSecret" value="<%=consumerSecret%>" style="width:350px">
<td><input type="password" id="consumerSecret" name="consumerSecret" value="<%=consumerSecret%>" style="width:450px">
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets enncode the input to prevent security threats.

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.

4 participants