-
Notifications
You must be signed in to change notification settings - Fork 157
Exposes UserProfile to return contents of id token without refreshing credentials #840
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
base: main
Are you sure you want to change the base?
Conversation
@NandanPrabhu The title claims to return Credentials but this returns only the UserProfile to the end user . Please update the tile accordingly as it can be misleading when generating the release notes |
@@ -44,6 +51,18 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting | |||
Executors.newSingleThreadExecutor() | |||
) | |||
|
|||
public override val userProfile: UserProfile? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Credentials
class already has an userProfile
property which returns the decoded UserProfile . We can reuse that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add a getExistingCredentials() method here similar to SecureCredentialsManager to construct the complete Credentials object. Since here usecase is to retrieve id token and returns its contents, we are retrieving only the ID token from storage @pmathew92
@@ -250,6 +257,47 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT | |||
} | |||
} | |||
|
|||
private fun retrieveCredentials() : Credentials? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this as there is already a method getExistingCredentials
which does the exact same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done @pmathew92 updated the changes
return credentials | ||
} | ||
|
||
public override val userProfile: UserProfile? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse userProfile
property from Credentials
class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -721,6 +721,11 @@ public class CredentialsManagerTest { | |||
Assert.assertEquals(retrievedCredentials.accessToken, renewedCredentials.accessToken) | |||
} | |||
|
|||
@Test | |||
public fun shouldFailOnUserProfileWhenCredentialsIsNotSaved() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are incomplete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are using existing function removed these test cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can reuse already existing properties / methods and avoid redundant code
Changes
This PR covers addressing a github issue requesting a feature to allow accessing credentials without refresh.
Both SecureCredentialsManager and CredentialManager returns credentials directly from storage. In case of SecureCredentialsManager, it takes care of fetching from storage and decrypting as well.
References
auth0/auth0-flutter#378
Testing
Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. Since this library has unit testing, tests should be added for new functionality and existing tests should complete without errors.
This change adds unit test coverage
This change adds integration test coverage
This change has been tested on the latest version of the platform/language or why not
Checklist
I have read the Auth0 general contribution guidelines
I have read the Auth0 Code of Conduct
All existing and new tests complete without errors