Esempio n. 1
0
 def get_init_detail(self, params=None, user=None):
     """
     to complete the token normalisation, the response of the initialization
     should be build by the token specific method, the getInitDetails
     """
     response_detail = TokenClass.get_init_detail(self, params, user)
     otpkey = self.init_details.get('otpkey')
     if otpkey:
         tok_type = self.type.lower()
         if user is not None:
             try:
                 motp_url = create_motp_url(otpkey,
                                            user.login, user.realm,
                                            serial=self.get_serial())
                 response_detail["motpurl"] = {"description": _("URL for MOTP "
                                                                "token"),
                                               "value": motp_url,
                                               "img": create_img(motp_url,
                                                                 width=250)
                                               }
             except Exception as ex:   # pragma: no cover
                 log.debug("{0!s}".format(traceback.format_exc()))
                 log.error('failed to set motp url: {0!r}'.format(ex))
                 
     return response_detail
Esempio n. 2
0
 def get_init_detail(self, params=None, user=None):
     """
     to complete the token normalisation, the response of the initialization
     should be build by the token specific method, the getInitDetails
     """
     response_detail = TokenClass.get_init_detail(self, params, user)
     otpkey = self.init_details.get('otpkey')
     if otpkey:
         tok_type = self.type.lower()
         if user is not None:
             try:
                 motp_url = create_motp_url(otpkey,
                                            user.login, user.realm,
                                            serial=self.get_serial())
                 response_detail["motpurl"] = {"description": _("URL for MOTP "
                                                                "token"),
                                               "value": motp_url,
                                               "img": create_img(motp_url,
                                                                 width=250)
                                               }
             except Exception as ex:   # pragma: no cover
                 log.debug("{0!s}".format(traceback.format_exc()))
                 log.error('failed to set motp url: {0!r}'.format(ex))
                 
     return response_detail
Esempio n. 3
0
 def test_01_apps_urls(self):
     r = create_google_authenticator_url("12345678")
     self.assertEqual(r,"otpauth://hotp/mylabel?secret=CI2FM6A&counter=0")
     r = create_oathtoken_url("12345678")
     self.assertEqual(r,"oathtoken:///addToken?name=mylabel&"
                        "lockdown=true&key=12345678")
     r = create_oathtoken_url("12345678", type="totp")
     self.assertEqual(r, "oathtoken:///addToken?name=mylabel&"
                          "lockdown=true&key=12345678&timeBased=true")
     r = create_motp_url("12345678")
     self.assertEqual(r, "motp://privacyidea:mylabel?secret=12345678")
Esempio n. 4
0
 def test_01_apps_urls(self):
     r = create_google_authenticator_url("12345678")
     self.assertTrue("otpauth://hotp/mylabel?secret=CI2FM6A&counter=1" in r,
                     r)
     r = create_oathtoken_url("12345678")
     self.assertEqual(
         r, "oathtoken:///addToken?name=mylabel&"
         "lockdown=true&key=12345678")
     r = create_oathtoken_url("12345678", type="totp")
     self.assertEqual(
         r, "oathtoken:///addToken?name=mylabel&"
         "lockdown=true&key=12345678&timeBased=true")
     r = create_motp_url("12345678")
     self.assertEqual(r, "motp://privacyidea:mylabel?secret=12345678")
Esempio n. 5
0
    def test_01_apps_urls(self):
        r = create_google_authenticator_url("12345678")
        self.assertTrue("otpauth://hotp/mylabel?secret=CI2FM6A&counter=1" in
                        r, r)

        r = create_google_authenticator_url(tokentype="TOTP", key="123456",
                                            period=60)
        self.assertTrue("otpauth://TOTP/mylabel?secret=CI2FM&period"
                        "=60&digits=6&issuer=privacyIDEA" in r, r)

        r = create_oathtoken_url("12345678")
        self.assertEqual(r, "oathtoken:///addToken?name=mylabel&"
                            "lockdown=true&key=12345678")
        r = create_oathtoken_url("12345678", type="totp")
        self.assertEqual(r, "oathtoken:///addToken?name=mylabel&"
                             "lockdown=true&key=12345678&timeBased=true")
        r = create_motp_url("12345678")
        self.assertEqual(r, "motp://privacyidea:mylabel?secret=12345678")