Skip to content

Added support to configure credentials manager for iOS and Android [DO NOT MERGE] #576

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 1 commit into
base: main
Choose a base branch
from

Conversation

pmathew92
Copy link
Contributor

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

This PR adds support to configure the CredentialsManager class on both Android and iOS platforms. This change allows user to set the sharedpreferenceName in Android and secretKey , accessGroup and accessibility on iOS while setting up the CredentialsManager in auth0_flutter

📎 References

#553

class IOSCredentialsConfiguration {
String storeKey;
String accessGroup;
Accessibility accessibility;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can storeKey , accessGroup and accessibility be optional ?

Copy link
Contributor

Choose a reason for hiding this comment

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

storeKey has a default value on the Credentials manager (https://auth0.github.io/Auth0.swift/documentation/auth0/credentialsmanager/init(authentication:storekey:storage:)).

accessGroup defaults to nil on SimpleKeychain, and accesibility defaults to .afterFirstUnlock (https://auth0.github.io/SimpleKeychain/documentation/simplekeychain/simplekeychain/init(service:accessgroup:accessibility:accesscontrolflags:context:synchronizable:attributes:)).

Seeing that all of them have default values and thus are not mandatory, they should be optional.

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, it would be good to mention the default values in the doc comments.

@@ -0,0 +1,46 @@
//
class CredentialsManagerConfiguration {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add comments for all classes

var instance = CredentialsManagerHandler.credentialsManager ?? CredentialsManager(authentication: apiClient)


var createCredentialManager: (_ apiClient: Authentication, _ arguments: [String: Any]) -> CredentialsManager = { apiClient, arguments in
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest moving createCredentialManager out of credentialsManagerProvider. The point of credentialsManagerProvider being a var is that you can mock it out for tests.

I think it makes sense for createCredentialManager to be swappable as well, but that only makes sense as long as there are tests. Otherwise there is no point in having it be a var.

Copy link
Contributor Author

@pmathew92 pmathew92 May 15, 2025

Choose a reason for hiding this comment

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

I understand... I had initially created this as a function but compiler kept throwing me error
Cannot use instance member 'createCredentialManager' within property initializer; property initializers run before 'self' is available

Will check it again

@Widcket
Copy link
Contributor

Widcket commented May 14, 2025

<resources>
<string name="com_auth0_domain">YOUR_AUTH0_DOMAIN</string>
<string name="com_auth0_scheme">demo</string>
</resources>
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this file needed for the Android example, given that strings.xml is not committed?

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 accidentally pushed. Will revert

Comment on lines +52 to +53
/// Use [CredentialsManagerConfiguration] to configure platform specific
/// configuration of the CredentialsManager
Copy link
Contributor

@Widcket Widcket May 14, 2025

Choose a reason for hiding this comment

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

Suggested change
/// Use [CredentialsManagerConfiguration] to configure platform specific
/// configuration of the CredentialsManager
/// Use [CredentialsManagerConfiguration] to set platform-specific
/// configuration for the default CredentialsManager.

@Widcket
Copy link
Contributor

Widcket commented May 14, 2025

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