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

[PM-17424] Implement disk data source for key data #4608

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SaintPatrck
Copy link
Contributor

@SaintPatrck SaintPatrck commented Jan 21, 2025

🎟️ Tracking

PM-17424

Relates to #4606, #4486

📔 Objective

Introduce a new disk data source, KeyDiskSource, for managing key-related data.
This includes:

  • Storing the alias and host of the selected mTLS key.
  • Retrieving the alias and host of the selected mTLS key.

A default implementation, KeyDiskSourceImpl, is provided using encrypted shared preferences to securely store the key data.
The PlatformDiskModule is updated to provide an instance of KeyDiskSource.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Jan 21, 2025

Logo
Checkmarx One – Scan Summary & Details68d4bcd1-bef8-418a-b199-30d086b17ed5

Great job, no security vulnerabilities found in this Pull Request

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.37%. Comparing base (bb5aeaa) to head (58b65ce).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4608      +/-   ##
==========================================
- Coverage   88.39%   88.37%   -0.02%     
==========================================
  Files         604      604              
  Lines       40830    40855      +25     
  Branches     5725     5754      +29     
==========================================
+ Hits        36090    36104      +14     
+ Misses       2749     2745       -4     
- Partials     1991     2006      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

override fun storeMutualTlsKey(
userId: String,
alias: String?,
host: MutualTlsKeyHost?,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't actually use the host here?

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 will be used by the KeyRepo (coming soon) to determine where the key is stored; system KeyChain or AndroidKeyStore.

Alternatively, we could make KeyDiskSource responsible for delegating between KeyChain and KeyStore. That would mean passing Context down to a DiskSource, which I don't see happening anywhere. We don't really pass Context to repositories either. 🤔

I plan on invoking KeyChain.choosePrivateKeyAlias(activity) from a KeyChainManager available to Composables. Another option is to move the other KeyChain calls that only require Context to this KeyChainManager. Downside to that approach is the number of Actions and Events that will have to be wired up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see an inherent issue with letting the disk source determine whether it needs to got to the key chain or shared preferences, since they are bot disk (sorta). Similar to how the other disk sources determine between encrypted and unencrypted preferences.

What I was mainly pointing out was that we do not actually store the host value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha. I completely missed that. 🤦

I'm actually going to refactor this so the repo doesn't need to distinguish between the two locations. 🚀

@SaintPatrck SaintPatrck marked this pull request as draft January 22, 2025 23:08
This commit introduces a new disk data source, `KeyDiskSource`, for managing key-related data.
This includes:
- Importing a mutual TLS certificate into the AndroidKeyStore.
- Removing a mutual TLS certificate from the AndroidKeyStore.
- Retrieving a mutual TLS certificate from the AndroidKeyStore
@SaintPatrck SaintPatrck force-pushed the PM-17424/store-mtls-key-alias-and-host branch from 5e37666 to 58b65ce Compare January 23, 2025 23:07
@SaintPatrck SaintPatrck marked this pull request as ready for review January 23, 2025 23:14
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