6.1.1.3.1.5.1.8. linotp.lib.tokens.smstoken module¶
This file containes the dynamic sms token implementation: - SMSTokenClass (sms)
- class linotp.lib.tokens.smstoken.SmsTokenClass(aToken)[source]¶
Bases: linotp.lib.tokens.hmactoken.HmacTokenClass
implementation of the sms token class
- checkOtp(anOtpVal, counter, window, options=None)[source]¶
checkOtp - check the otpval of a token against a given counter in the + window range
Parameters: passw (string) – the to be verified passw/pin Returns: counter if found, -1 if not found Return type: int
- checkResponse4Challenge(user, passw, options=None, challenges=None)[source]¶
verify the response of a previous challenge
Parameters: - user – the requesting user
- passw – the to be checked pass (pin+otp)
- options – options an additional argument, which could be token specific
- challenges – the list of challenges, where each challenge is described as dict
Returns: tuple of (otpcounter and the list of matching challenges)
do the standard check for the response of the challenge + change the tokeninfo data of the last challenge
- createChallenge(transactionid, options=None)[source]¶
create a challenge, which is submitted to the user
Parameters: - transactionid – the id of this challenge
- options – the request context parameters / data
Returns: tuple of (bool, message and data) bool, if submit was successful message is submitted to the user data is preserved in the challenge attributes - additional attributes, which are displayed in the
output
- classmethod getClassInfo(key=None, ret='all')[source]¶
getClassInfo - returns all or a subtree of the token definition
Parameters: - key (string) – subsection identifier
- ret (user defined) – default return value, if nothing is found
Returns: subsection if key exists or user defined
:rtype : s.o.
- getSMSInfo()[source]¶
retrieve the phone number and the validity scope
Returns: tuple of phone number and validity time in unix lifetime sec
- getUntil()[source]¶
getter for the until time definition
Returns: until time definition of unix time sec Return type: int
- initChallenge(transactionid, challenges=None, options=None)[source]¶
initialize the challenge - in the linotp server a challenge object has been allocated and this method is called to confirm the need of a new challenge or if for the challenge request, there is an already outstanding challenge to which then could be referred (s. ticket #2986)
Parameters: - transactionid – the id of the new challenge
- options – the request parameters
Returns: tuple of success - bool transid - the best transaction id for this request context message - which is shown to the user attributes - further info (dict) shown to the user
- is_challenge_request(passw, user, options=None)[source]¶
check, if the request would start a challenge
- default: if the passw contains only the pin, this request would
trigger a challenge
- in this place as well the policy for a token is checked
Parameters: - passw – password, which might be pin or pin+otp
- options – dictionary of additional request parameters
Retrun : returns true or false
- is_challenge_response(passw, user, options=None, challenges=None)[source]¶
check, if the request contains the result of a challenge
Parameters: - passw – password, which might be pin or pin+otp
- user – the requesting user
- options – dictionary of additional request parameters
Returns: returns true or false
- loadLinOtpSMSProvider()[source]¶
get the SMS Provider class definition
Returns: tuple of SMSProvider and Provider Class as string Return type: tuple of (string, string)
- loadLinOtpSMSProviderConfig()[source]¶
load the defined sms provider config definition
Returns: dict of the sms provider definition Return type: dict
- loadLinOtpSMSValidTime()[source]¶
get the challenge time is in the specified range
Returns: the defined validation timeout in seconds Return type: int
- sendSMS(message='<otp>')[source]¶
send sms
Parameters: message (string) – the sms submit message - could contain placeholders like <otp> or <serial> Returns: submitted message Return type: string
- setPhone(phone)[source]¶
setter for the phone number
Parameters: phone (string) – phone number Returns: nothing
- setSMSInfo(key, value)[source]¶
generic method to set the sms infos like phone or validity in the tokeninfo (json) entry
Parameters: - key (string) – name of the hash key
- value (any) – value of the entry
Returns: nothing
- setUntil(until)[source]¶
- This is the time the sent OTP value is valid/can be used.
- (internal function)
Parameters: until (int) – until time in unix time sec Returns: nothing