Skip to content

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

NandanPrabhu
Copy link

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

@NandanPrabhu NandanPrabhu requested a review from a team as a code owner June 10, 2025 05:37
@pmathew92
Copy link
Contributor

pmathew92 commented Jun 12, 2025

@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?
Copy link
Contributor

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

Copy link
Author

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? {
Copy link
Contributor

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

Copy link
Author

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

@NandanPrabhu NandanPrabhu changed the title GH issue Allow accessing credentials without an attempt to refresh #378 Exposes UserProfile to return contents of id token without refreshing credentials Jun 12, 2025
return credentials
}

public override val userProfile: UserProfile?
Copy link
Contributor

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

Copy link
Author

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() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests are incomplete

Copy link
Author

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

Copy link
Contributor

@pmathew92 pmathew92 left a 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

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