Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Check hashed passphrase returned by LCPAuthenticating #75

Merged
merged 2 commits into from
Mar 10, 2020

Conversation

mickael-menu
Copy link
Member

@mickael-menu mickael-menu commented Feb 11, 2020

When the test-app only had a hashed version of a passphrase, it could not send it through LCPAuthenticating.

This PR allows to provide both hashed and clear passphrases.

With this, it would be possible to implement retrieving the passphrases using Authentication for OPDS (as defined here: https://readium.org/lcp-specs/notes/lcp-key-retrieval.html) by creating a OPDSLCPAuthentication class implementing LCPAuthenticating.

You can also create a simple LCPAuthenticating implementation to provide a raw clean or hashed passphrase. The fallback is used, for example, to revert on showing a credentials pop-up if the passphrase was wrong.

final class LCPPassphrase: LCPAuthenticating {
    private let passphrase: String
    private let fallback: LCPAuthenticating
   
    init(_ passphrase: String, fallback: LCPAuthenticating) {
      self.passphrase = passphrase
      self.fallback = fallback
    }
   
    func requestPassphrase(for license: LCPAuthenticatedLicense, reason: LCPAuthenticationReason, completion: @escaping (String?) -> Void) {
        guard reason == .passphraseNotFound else{
            fallback.requestPassphrase(for: license, reason: reason, completion: completion)
            return
        }
     
        completion(self.passphrase)
    }
}

Use DWARF with dSYM for DEBUG_INFORMATION_FORMAT, to fix breakpoints
@mickael-menu mickael-menu merged commit d820272 into develop Mar 10, 2020
@mickael-menu mickael-menu deleted the fix/check-hashed-passphrases branch March 10, 2020 10:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant