本文整理汇总了Python中privacyidea.lib.policy.PolicyClass.get_tokenlabel方法的典型用法代码示例。如果您正苦于以下问题:Python PolicyClass.get_tokenlabel方法的具体用法?Python PolicyClass.get_tokenlabel怎么用?Python PolicyClass.get_tokenlabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类privacyidea.lib.policy.PolicyClass
的用法示例。
在下文中一共展示了PolicyClass.get_tokenlabel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_google_authenticator_url
# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import get_tokenlabel [as 别名]
def create_google_authenticator_url(user, realm, key, type="hmac", serial=""):
'''
This creates the google authenticator URL.
This url may only be 119 characters long.
Otherwise we qrcode.js can not create the qrcode.
If the URL would be longer, we shorten the username
We expect the key to be hexlified!
'''
# policy depends on some lib.util
if "hmac" == type.lower():
type = "hotp"
key_bin = binascii.unhexlify(key)
# also strip the padding =, as it will get problems with the google app.
otpkey = base64.b32encode(key_bin).strip('=')
#'url' : "otpauth://hotp/%s?secret=%s&counter=0" % ( [email protected], otpkey )
base_len = len("otpauth://%s/?secret=%s&counter=0" % (type, otpkey))
max_len = 119
allowed_label_len = max_len - base_len
log.debug("we have got %s characters left for the token label" % str(allowed_label_len))
Policy = PolicyClass(request, config, c,
get_privacyIDEA_config())
label = Policy.get_tokenlabel(user, realm, serial)
label = label[0:allowed_label_len]
url_label = quote(label)
return "otpauth://%s/%s?secret=%s&counter=0" % (type, url_label, otpkey)
示例2: create_motp_url
# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import get_tokenlabel [as 别名]
def create_motp_url(user, realm, key, serial=""):
'''
This creates the motp url as described at
http://huseynov.com/index.php?post=motp-vs-google-authenticator-and-a-new-otp-app
The format is:
motp://SecureSite:[email protected]?secret=JBSWY3DPEHPK3PXP
'''
# For Token2 the OTPKEY is hexencoded, not base32!
otpkey = key
Policy = PolicyClass(request, config, c,
get_privacyIDEA_config())
label = Policy.get_tokenlabel(user, realm, serial)
allowed_label_len = 20
label = label[0:allowed_label_len]
url_label = quote(label)
return "motp://privacyidea:%s?secret=%s" % (url_label, otpkey)
示例3: create_oathtoken_url
# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import get_tokenlabel [as 别名]
def create_oathtoken_url(user, realm, otpkey, type="hmac", serial=""):
#'url' : 'oathtoken:///addToken?name='+serial +
# '&key='+otpkey+
# '&timeBased=false&counter=0&numDigites=6&lockdown=true',
timebased = ""
if "totp" == type.lower():
timebased = "&timeBased=true"
Policy = PolicyClass(request, config, c,
get_privacyIDEA_config())
label = Policy.get_tokenlabel(user, realm, serial)
url_label = quote(label)
url = "oathtoken:///addToken?name=%s&lockdown=true&key=%s%s" % (
url_label,
otpkey,
timebased
)
return url