How create TOTP DEVICE

409 views
Skip to first unread message

pablo gonzalez

unread,
Dec 15, 2017, 10:03:18 AM12/15/17
to django-otp

Hello,

i follow this tutorial, https://hackernoon.com/5-ways-to-make-django-admin-safer-eb7753698ac8

and i found this excellent idea of authentication, but now i stuck where he saids, create in the admin the TOTP DEVICE ?

But how can i do that?

I make the migrations of the otp app, so i have the Table in my postgres db.












Peter Sagerson

unread,
Dec 15, 2017, 12:39:22 PM12/15/17
to djang...@googlegroups.com
There are two possible workarounds here:

1. Use the normal Django AdminSite (not the OTPAdminSite) until you have a device set up.

2. Assuming you have otp_static installed, run `manage.py addstatictoken programador` to generate a single-use token.

Thanks,
Peter



--
You received this message because you are subscribed to the Google Groups "django-otp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-otp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pablo gonzalez

unread,
Dec 15, 2017, 1:04:28 PM12/15/17
to django-otp
Hello Peter,

I change to the default Django Admin Site.

And trying the commands you posted, return this 

==========================================================================================

manage.py@otaProject > addstatictoken programador
"C:\Program Files\JetBrains\PyCharm 2017.2.4\bin\runnerw.exe" C:\virtualenv\otaupdateEnv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.4\helpers\pycharm\django_manage.py" addstatictoken programador C:/Users/Programador/PycharmProjects/otaProject
System check identified some issues:

WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.2.4\helpers\pycharm\django_manage.py", line 43, in <module>
    run_module(manage_file, None, '__main__', True)
  File "C:\Users\Programador\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "C:\Users\Programador\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Programador\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:/Users/Programador/PycharmProjects/otaProject\manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\virtualenv\otaupdateEnv\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "C:\virtualenv\otaupdateEnv\lib\site-packages\django\core\management\__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\virtualenv\otaupdateEnv\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\virtualenv\otaupdateEnv\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\virtualenv\otaupdateEnv\lib\site-packages\django_otp\plugins\otp_static\management\commands\addstatictoken.py", line 28, in handle
    self.stdout.write(statictoken.token)
  File "C:\virtualenv\otaupdateEnv\lib\site-packages\django\core\management\base.py", line 107, in write
    if ending and not msg.endswith(ending):
TypeError: endswith first arg must be bytes or a tuple of bytes, not str


==========================================================================================

Peter Sagerson

unread,
Dec 15, 2017, 1:06:35 PM12/15/17
to djang...@googlegroups.com
That just looks like a Python 3 compatibility bug, easily resolved. Fortunately, you only need one of the two workarounds. If you can create your initial device through the default AdminSite, you have no need of addstatictoken.

pablo gonzalez

unread,
Dec 15, 2017, 1:28:03 PM12/15/17
to django-otp
Ok sure, but.. how make OTP Devices, appears in the Django Admin site?

how a register on admin.py

Peter Sagerson

unread,
Dec 15, 2017, 1:31:05 PM12/15/17
to djang...@googlegroups.com
The standard device models (in django_otp.plugins.otp_*) all register themselves with the default admin site, like any good Django app. If the plugins are in INSTALLED_APPS, the models should be there.

pablo gonzalez

unread,
Dec 15, 2017, 2:09:57 PM12/15/17
to django-otp
After doing everything you say,

Appears in Django Admin Site!

Now when i create, show this, i try to read with Authenticator of Google and dont work, you know maybe why happen this?


Peter Sagerson

unread,
Dec 15, 2017, 3:11:24 PM12/15/17
to djang...@googlegroups.com
That's peculiar. Have you compared with other browsers? Inspected the DOM to see what's going wrong? Right-clicked the image to open it separately?

pablo gonzalez

unread,
Dec 15, 2017, 3:23:59 PM12/15/17
to django-otp

im missing add to the setting.py, this OTP_TOTP_ISSUER = 'OtaUpdate'

and i try it in other browsers, the problem comes with Microsoft Edge , but in Chrome and Firefox Developer Edition works fine

Peter Sagerson

unread,
Dec 15, 2017, 3:31:04 PM12/15/17
to djang...@googlegroups.com
Ah yes, I believe Microsoft browsers have a long history of ineptitude when it comes to SVG, although I'm surprised that Edge still has issues.

pablo gonzalez

unread,
Dec 15, 2017, 3:45:25 PM12/15/17
to django-otp
Yes, they still have some issues .. 
But thanks Peter for your time and support !
Reply all
Reply to author
Forward
0 new messages