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

Check hashed passphrase returned by LCPAuthenticating #64

Merged
merged 2 commits into from
Apr 16, 2020

Conversation

mickael-menu
Copy link
Member

@mickael-menu mickael-menu commented Mar 31, 2020

Same PR for Swift: readium/r2-lcp-swift#75

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.

class LCPPassphrase(val passphrase: String, val fallback: LCPAuthenticating) : LCPAuthenticating {

    override fun requestPassphrase(license: LCPAuthenticatedLicense, reason: LCPAuthenticationReason, completion: (String?) -> Unit) {
        if (reason != LCPAuthenticationReason.passphraseNotFound) {
            fallback.requestPassphrase(license, reason, completion)
            return
        }

        completion(passphrase)
    }

}

@llemeurfr
Copy link

Do you mean the app has to store the passphrase in clear in order to handle this? This is not good practice, even if secured.

@mickael-menu
Copy link
Member Author

@llemeurfr No this is to be able to provide a hashed passphrase instead of a clear passphrase from a dialog. For example, by getting the hashed passphrase from an authenticated OPDS feed. We talked about this a few weeks ago for Swift.

@mickael-menu mickael-menu merged commit 32fe913 into develop Apr 16, 2020
@mickael-menu mickael-menu deleted the fix/check-hashed-passphrases branch April 16, 2020 12:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants