"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "linotpd/src/linotp/model/__init__.py" between
LinOTP-release-2.11.2.tar.gz and LinOTP-release-2.12.tar.gz

About: LinOTP is a flexible and versatile OTP-platform for strong user authentication (two-factor authentication with one time passwords).

__init__.py  (LinOTP-release-2.11.2):__init__.py  (LinOTP-release-2.12)
skipping to change at line 50 skipping to change at line 50
4. Keep the names meaningful, but in the same time don't use 4. Keep the names meaningful, but in the same time don't use
long_names_describing_every_single_detail_of_particular_object. long_names_describing_every_single_detail_of_particular_object.
""" """
import binascii import binascii
import logging import logging
import traceback import traceback
from datetime import datetime from datetime import datetime
from linotp.lib.type_utils import DEFAULT_TIMEFORMAT
try: try:
import json import json
except ImportError: except ImportError:
import simplejson as json import simplejson as json
"""The application's model objects""" """The application's model objects"""
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
from sqlalchemy import ForeignKey from sqlalchemy import ForeignKey
skipping to change at line 146 skipping to change at line 148
sa.Column( sa.Column(
'LinOtpOtpLen', sa.types.Integer(), default=6), 'LinOtpOtpLen', sa.types.Integer(), default=6),
# # hashed # # hashed
sa.Column( sa.Column(
'LinOtpPinHash', sa.types.Unicode(512), default=u''), 'LinOtpPinHash', sa.types.Unicode(512), default=u''),
# # encrypt # # encrypt
sa.Column( sa.Column(
'LinOtpKeyEnc', sa.types.Unicode(1024), default=u''), 'LinOtpKeyEnc', sa.types.Unicode(1024), default=u''),
sa.Column( sa.Column(
'LinOtpKeyIV', sa.types.Unicode(32), default=u''), 'LinOtpKeyIV', sa.types.Unicode(32), default=u''),
sa.Column( sa.Column(
'LinOtpMaxFail', sa.types.Integer(), default=10), 'LinOtpMaxFail', sa.types.Integer(), default=10),
sa.Column( sa.Column(
'LinOtpIsactive', sa.types.Boolean(), default=True), 'LinOtpIsactive', sa.types.Boolean(), default=True),
sa.Column( sa.Column(
'LinOtpFailCount', sa.types.Integer(), default=0), 'LinOtpFailCount', sa.types.Integer(), default=0),
sa.Column('LinOtpCount', sa.types.Integer(), default=0), sa.Column('LinOtpCount', sa.types.Integer(), default=0),
sa.Column( sa.Column(
'LinOtpCountWindow', sa.types.Integer(), default=10), 'LinOtpCountWindow', sa.types.Integer(), default=10),
sa.Column( sa.Column(
'LinOtpSyncWindow', sa.types.Integer(), default=1000) , 'LinOtpSyncWindow', sa.types.Integer(), default=1000) ,
sa.Column('LinOtpCreationDate', sa.types.DateTime, index=
True,
default=datetime.now().replace(microsecond=0)),
sa.Column('LinOtpLastAuthSuccess', sa.types.DateTime, ind
ex=True,
default=None),
sa.Column('LinOtpLastAuthMatch', sa.types.DateTime, index
=True,
default=None),
implicit_returning=implicit_returning, implicit_returning=implicit_returning,
) )
TOKEN_ENCODE = ["LinOtpTokenDesc", "LinOtpTokenSerialnumber", TOKEN_ENCODE = ["LinOtpTokenDesc", "LinOtpTokenSerialnumber",
"LinOtpTokenInfo", "LinOtpUserid", "LinOtpIdResClass", "LinOtpTokenInfo", "LinOtpUserid", "LinOtpIdResClass",
"LinOtpIdResolver"] "LinOtpIdResolver"]
class Token(object): class Token(object):
def __init__(self, serial): def __init__(self, serial):
skipping to change at line 187 skipping to change at line 195
self.LinOtpMaxFail = 10 self.LinOtpMaxFail = 10
self.LinOtpIsactive = True self.LinOtpIsactive = True
self.LinOtpCountWindow = 10 self.LinOtpCountWindow = 10
self.LinOtpOtpLen = 6 self.LinOtpOtpLen = 6
self.LinOtpSeed = u'' self.LinOtpSeed = u''
self.LinOtpIdResolver = None self.LinOtpIdResolver = None
self.LinOtpIdResClass = None self.LinOtpIdResClass = None
self.LinOtpUserid = None self.LinOtpUserid = None
# will be assigned automaticaly # when the token is created all time stamps are set to utc now
# self.LinOtpTokenId = 0
self.LinOtpCreationDate = datetime.utcnow().replace(microsecond=0)
self.LinOtpLastAuthMatch = None
self.LinOtpLastAuthSuccess = None
def __setattr__(self, name, value): def __setattr__(self, name, value):
""" """
to support unicode on all backends, we use the json encoder with to support unicode on all backends, we use the json encoder with
the ASCII encode default the ASCII encode default
:param name: db column name or class member :param name: db column name or class member
:param value: the corresponding value :param value: the corresponding value
:return: - nothing - :return: - nothing -
skipping to change at line 418 skipping to change at line 429
ret['LinOtp.Userid'] = self.LinOtpUserid or '' ret['LinOtp.Userid'] = self.LinOtpUserid or ''
ret['LinOtp.OtpLen'] = self.LinOtpOtpLen or 6 ret['LinOtp.OtpLen'] = self.LinOtpOtpLen or 6
# ret['LinOtp.PinHash'] = self.LinOtpPinHash # ret['LinOtp.PinHash'] = self.LinOtpPinHash
ret['LinOtp.MaxFail'] = self.LinOtpMaxFail ret['LinOtp.MaxFail'] = self.LinOtpMaxFail
ret['LinOtp.Isactive'] = self.LinOtpIsactive ret['LinOtp.Isactive'] = self.LinOtpIsactive
ret['LinOtp.FailCount'] = self.LinOtpFailCount ret['LinOtp.FailCount'] = self.LinOtpFailCount
ret['LinOtp.Count'] = self.LinOtpCount ret['LinOtp.Count'] = self.LinOtpCount
ret['LinOtp.CountWindow'] = self.LinOtpCountWindow ret['LinOtp.CountWindow'] = self.LinOtpCountWindow
ret['LinOtp.SyncWindow'] = self.LinOtpSyncWindow ret['LinOtp.SyncWindow'] = self.LinOtpSyncWindow
# ------------------------------------------------------------------ --
# handle representation of created, accessed and verified:
# - could be None, if not (newly) created / accessed / verified
# - if type is datetime it must be converted to a string as the result
# will be used as part of a json output
created = ''
if self.LinOtpCreationDate is not None:
created = self.LinOtpCreationDate.strftime(DEFAULT_TIMEFORMAT)
ret['LinOtp.CreationDate'] = created
verified = ''
if self.LinOtpLastAuthSuccess is not None:
verified = self.LinOtpLastAuthSuccess.strftime(DEFAULT_TIMEFORMAT)
ret['LinOtp.LastAuthSuccess'] = verified
accessed = ''
if self.LinOtpLastAuthMatch is not None:
accessed = self.LinOtpLastAuthMatch.strftime(DEFAULT_TIMEFORMAT)
ret['LinOtp.LastAuthMatch'] = accessed
# list of Realm names # list of Realm names
ret['LinOtp.RealmNames'] = self.getRealmNames() ret['LinOtp.RealmNames'] = self.getRealmNames()
return ret return ret
__str__ = __unicode__ __str__ = __unicode__
def __repr__(self): def __repr__(self):
''' '''
return the token state as text return the token state as text
 End of changes. 6 change blocks. 
3 lines changed or deleted 41 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)