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

A wiki / documentation / tutorial for TOTP in KeePass2Android + some reports #1248

Closed
Phelo972 opened this issue May 6, 2020 · 14 comments · Fixed by #2497
Closed

A wiki / documentation / tutorial for TOTP in KeePass2Android + some reports #1248

Phelo972 opened this issue May 6, 2020 · 14 comments · Fixed by #2497
Milestone

Comments

@Phelo972
Copy link

Phelo972 commented May 6, 2020

Hello,

First of all thanks for this great work resulting in KeePass2Android!

I'm new on things like GitHub so sorry if there is a better way to submit what I'm requesting.

Anyway it would be very useful to write some doc / tutorial for TOTP and its application in KeePass2Android, as I've struggled a lot to find all the infos to use properly TOTP in KeePass2Android.

Here I put (meanwhile) a kind of draft documentation for those who, like me, didn't know anything about all of these before starting with KeePass + some reports for TOTP in KeePass2Android.


Changelog:
March 13th, 2021: Added reference to aaFn comment
May 13th, 2020: Added informations from Rookiestyle and reference to Rookiestyle comment
May 6th, 2020: Initial version

TOTP in brief

TOTP stands for Time-based One-Time Password algorithm which is one of the most common way proposed by websites to do a two-factor authentication (2FA).

On these websites, this option will often be mentioned in the 2FA configuration menu as things like "use code generated by an application", "use [Google] Authenticator app".

You're prompted to scan a QR code with the app, which essentially contains a code called "seed", usually with a form like "AZER TYUI OPQS DFGH JKLM", used to generate TOTPs. The seed can be also directly copied if there is no scanning option on the app.

Most common apps:

  • Google Authenticator
  • Authy
  • Microsoft Authenticator
  • FreeOTP
  • LastPass Authenticator

TOTP in KeePass and benefits

In KeePass (by Dominik Reichl) there are currently 3 plugins wich enables this Authenticator app ability:

The greatest benefits are:

  • the seed stays available contrary to the above apps (for which it's more or less hard to backup/restore/switch with another app)
  • TOTPs are available wherever the KeePass database is available. But conceptually it's not really 2FA anymore (all things are stored in the same place).

For what I know (I use KeePassOTP), in the configuration which works with KeePass2Android (i.e. not in a separate database), the plugin generates 2 (now 1 in the last update) custom fields in a classic KeePass entry (if a TOTP is set).

  • case of 2 fields: one for the seed, one for the technical settings of the TOTP generation (note this also for later)
  • case of 1 field: Key Uri Format

These fields enable the plugin to generate TOTPs for the entry.

TOTP in KeePass2Android (+ the reports)

(I'm French so I translate from how it's displayed on the French version of the app)

  1. To enable and use TOTP feature in KeePass2Android, three cases to make it work:
    1. (Not recommended) You want to start from KeePass2Android on your phone, not from KeePass by Dominik Reichl on PC. If so check this comment
    2. On KeePass you're using a KeePass plugin which generates 1 field in Key Uri Format* named "otp". If so, jump directly to step 3!
    3. On KeePass you're using a KeePass plugin which generates 2 fields as mentioned above. If so, you need to go to the "app settings" section of settings and then in "TrayTotp" section (like in the KeePass plugin).

* : Make sure that the URI doesn't contain spaces, otherwise KeePass2Android will fail to generate TOTPs as a space is an invalid character. If your URIs have spaces, check this comment.

[1st report: the original TrayTotp plugin doesn't even exist anymore, so naming the section like this is not very clear for newbies, maybe change the name of this section with something more relevant like "2 factor auth. - TOTP"]

  1. The 2 parameters "TOTP seed field name" and "TOTP settings field name" have to be filled with the name of the custom fields created by the KeePass plugin.

[2nd report: Bad French translation of "field name", should be "Nom du champ" not "Nom de domaine" (it misled me), also "seed" shouldn't be translated (potentially put "Nom du champ du "seed code" TOTP")] EDIT: I did the job on Crowdin

  1. A new custom field named "TOTP" containing the TOTPs will appear in KeePass entries which have a TOTP setup (only in KeePass2Android).
    This field will be also available in the special KeePass2Android one-line keyboard at the end.

[3rd report: Would be great if TOTP button could appear just after the password button !]

[4th report: in case of field in Key Uri Format, KeePass2Android fails to generate the TOTP if there are spaces in the seed inside the Uri, i.e.

otpauth://totp/ACME%20Co:john.doe@email.com?secret=HXDM VJECJJW SRB3HWI ZR4IFUG FTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30

instead of

otpauth://totp/ACME%20Co:john.doe@email.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30]

[5th report: I use the KeePass2Android AutoFill plugin, and when I have a TOTP to submit, I have to reopen KeePass2Android to search for the entry and activate the one-line keyboard. So that ruins the AutoFill plugin time gain. Isn't it possible to trigger a "xxx entry is available" notification just after the Autofill plugin action in order to quickly access to the TOTP ?"]

@Phelo972 Phelo972 changed the title A wiki / documentation / tutorial for TOTP in KeePass2Android + some reports for TOTP in KeePass2Android A wiki / documentation / tutorial for TOTP in KeePass2Android + some reports May 6, 2020
@PhilippC PhilippC added this to the 1.09 milestone May 9, 2020
@PhilippC
Copy link
Owner

PhilippC commented May 9, 2020

Thanks a lot for this suggestion of documentation! Very helpful!
Regarding the bad translation: Please feel free to improve translation errors on https://crowdin.com/project/keepass2android

@Rookiestyle
Copy link

KeePass2Android will generate TOTP if the entry contains a field named otp.
This field is expected to contain an otpauth-string, otherwise TOTP generation fails.
My KeePassOTP plugin stores OTP data in this format and due to that no special configuration is required in KeePass2Android.

Some pages display the secret as groups of 4 characters separated by spaces for improved readability.
KeePassOTP accepts these spaces (similar to other plugins and apps like andOTP) and unfortunately also saves them which leads to issues within KeePass2Android as a space is an invalid character.
I'll continue to accept spaces but will remove them during save in the next version.

In the meantime, you can manually remove them.
Either by updating the otp-field in all of the relevant entries or by doing a mass update using XML replace
This XML replace worked in my tests. It is based on https://keepass.info/help/v2/xml_replace.html#repstr
If you go for XML replace please make a backup fiurst - better safe then sorry
Tools -> Database tools -> XML replace...
Select nodes: //Entry/String[Key='otp']/Value
Action: Replace data
Data: Inner text
Find what: <enter a space here>
Replace with: <leave this field empty>

@Phelo972
Copy link
Author

Phelo972 commented May 13, 2020

Thanks a lot for these clarifications @Rookiestyle !
I edit my post reflecting those.

@bdeeming
Copy link

Thank you very much for this, I found this doc very useful - it allowed me to solve my problem (otp value was not in uri format, - for I don't know what reason since it was just one of my entries wasn't, had me stumped for ages until I found this!)

@aaFn
Copy link

aaFn commented Mar 12, 2021

Hello there, simple question = how to install the KeePass OTC plugin in keepass2android ?

so for now I can't make it work in my keepass2android.

Thank you in advance for any hint / help.

@Rookiestyle
Copy link

KeePassOTP is a plugin for KeePass, not a plugin for KeePass2Android.

If you use it within KeePass and decided to go for the OTP storage within the respective entry approach as described in KeePassOTP's wiki, KeePass2Android will generate otp codes as well and no further action is required.

@aaFn
Copy link

aaFn commented Mar 13, 2021

Hello @Rookiestyle , thanks, this is clear then.

So to set up (T)OTP for a given entry card in a DB managed by keepass2android, we have to:

@Phelo972 , you might want to add that in your description at the top ?

Thank you to both, aaFn.

@Rookiestyle
Copy link

You can also edit the entry in KeePass2Android and do "Configure TOTP"

@sydbarrett74
Copy link

Sorry if I missed it in the thread above, but will this all work if I maintain a separate database within KeePassOTP? (My goal is to maintain 2FA.)

@Rookiestyle
Copy link

Sorry if I missed it in the thread above, but will this all work if I maintain a separate database within KeePassOTP? (My goal is to maintain 2FA.)

No, this won't work.

@gpion
Copy link

gpion commented May 13, 2022

Does someone knopw if there any plan to have OTP management which is built-in in native Keepass for Windows (so dont require any plugin) supported in keepass2android?

@scruel
Copy link

scruel commented Aug 3, 2023

What about OTP storage in a separate database?

@jenssey11
Copy link

Thanks a lot for this suggestion of documentation! Very helpful! Regarding the bad translation: Please feel free to improve translation errors on https://crowdin.com/project/keepass2android

Hey @PhilippC can you please get ahold of me (jenssey@gmail.com) - my spouse uses one of your apps and he recently passed away.

PhilippC pushed a commit that referenced this issue Jan 3, 2024
@PhilippC
Copy link
Owner

PhilippC commented Jan 3, 2024

I have added https://github.com/PhilippC/keepass2android/blob/master/docs/Generating-TOTPs.md based on the documentation created here. I added some more details and updated some parts. For the feature requests mentioned above, there are already open tickets, so I am closing this issue.

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 a pull request may close this issue.

9 participants