예제 #1
0
    def getInitDetail(self, params , user=None):
        '''
        to complete the token normalisation, the response of the initialiastion
        should be build by the token specific method, the getInitDetails
        '''
        response_detail = {}

        info = self.getInfo()
        response_detail.update(info)
        response_detail['serial'] = self.getSerial()

        tok_type = self.type.lower()

        otpkey = None
        if 'otpkey' in info:
            otpkey = info.get('otpkey')

        if otpkey != None:
            response_detail["otpkey"] = {
                  "order"      : '1',
                  "description": _("OTP seed"),
                  "value"      :  "seed://%s" % otpkey,
                  "img"        :  create_img(otpkey, width=200),
                     }
            try:
                p = {}
                p.update(params)
                p['otpkey'] = otpkey
                p['serial'] = self.getSerial()
                # label
                goo_url = create_google_authenticator(p, user=user,
                                                      context=self.context)

                response_detail["googleurl"] = {
                      "order"      : '0',
                      "description": _("OTPAuth Url"),
                      "value" :     goo_url,
                      "img"   :     create_img(goo_url, width=250)
                      }

            except NoOtpAuthTokenException as exx:
                log.warning("%r" % exx)

            if user is not None:
                try:

                    oath_url = create_oathtoken_url(user.login, user.realm,
                                                    otpkey, tok_type,
                                                    serial=self.getSerial(),
                                                    context=self.context)
                    response_detail["oathurl"] = {
                           "order"      : '2',
                           "description" : _("URL for OATH token"),
                           "value" : oath_url,
                           "img"   : create_img(oath_url, width=250)
                           }
                except Exception as ex:
                    log.info('failed to set oath or google url: %r' % ex)

        return response_detail
예제 #2
0
    def getInitDetail(self, params, user=None):
        '''
        to complete the token normalisation, the response of the initialiastion
        should be build by the token specific method, the getInitDetails
        '''
        response_detail = {}

        info = self.getInfo()
        response_detail.update(info)
        response_detail['serial'] = self.getSerial()

        tok_type = self.type.lower()

        otpkey = None
        if 'otpkey' in info:
            otpkey = info.get('otpkey')

        if otpkey != None:
            response_detail["otpkey"] = {
                "order": '1',
                "description": _("OTP seed"),
                "value": "seed://%s" % otpkey,
                "img": create_img(otpkey, width=200),
            }
            try:
                p = {}
                p.update(params)
                p['otpkey'] = otpkey
                p['serial'] = self.getSerial()
                # label
                goo_url = create_google_authenticator(p, user=user)

                response_detail["googleurl"] = {
                    "order": '0',
                    "description": _("OTPAuth Url"),
                    "value": goo_url,
                    "img": create_img(goo_url, width=250)
                }

            except NoOtpAuthTokenException as exx:
                log.warning("%r" % exx)

            if user is not None:
                try:

                    oath_url = create_oathtoken_url(user.login,
                                                    user.realm,
                                                    otpkey,
                                                    tok_type,
                                                    serial=self.getSerial())
                    response_detail["oathurl"] = {
                        "order": '2',
                        "description": _("URL for OATH token"),
                        "value": oath_url,
                        "img": create_img(oath_url, width=250)
                    }
                except Exception as ex:
                    log.info('failed to set oath or google url: %r' % ex)

        return response_detail
예제 #3
0
파일: hmactoken.py 프로젝트: soitun/LinOTP
    def getInitDetail(self, params, user=None):
        """
        to complete the token normalisation, the response of the initialiastion
        should be build by the token specific method, the getInitDetails
        """
        response_detail = {}

        info = self.getInfo()
        response_detail.update(info)
        response_detail["serial"] = self.getSerial()

        tok_type = self.type.lower()

        otpkey = None
        if "otpkey" in info:
            otpkey = info.get("otpkey")

        if otpkey is not None:
            response_detail["otpkey"] = {
                "order": "1",
                "description": _("OTP seed"),
                "value": "seed://%s" % otpkey,
                "img": create_img(otpkey, width=200),
            }
            try:
                p = {}
                p.update(params)
                p["otpkey"] = otpkey
                p["serial"] = self.getSerial()
                # label
                goo_url = create_google_authenticator(p, user=user)

                response_detail["googleurl"] = {
                    "order": "0",
                    "description": _("OTPAuth Url"),
                    "value": goo_url,
                    "img": create_img(goo_url, width=250),
                }

            except NoOtpAuthTokenException as exx:
                log.warning(exx)

            oath_support = getFromConfig("OATHTokenSupport", "False") == "True"
            if oath_support:
                if user is not None:
                    try:

                        oath_url = create_oathtoken_url(
                            user.login,
                            user.realm,
                            otpkey,
                            tok_type,
                            serial=self.getSerial(),
                        )
                        response_detail["oathurl"] = {
                            "order": "2",
                            "description": _("URL for OATH token"),
                            "value": oath_url,
                            "img": create_img(oath_url, width=250),
                        }
                    except Exception as ex:
                        log.info("failed to set oath or google url: %r", ex)

        return response_detail