from ..handler.ldap_password import LdapPasswordHandler
from ..handler.ldap_password import HAS_CRACKLIB
-__version__ = '0.7.1'
+__version__ = '0.7.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
res = super(SetLdapPasswordApplication, self).as_dict(short=short)
- res['available_schemes'] = self.available_schemes
- res['default_schema'] = self.passlib_context.default_scheme()
- res['schema_ids'] = self.schema_ids
if self.current_password and self.verbose < 5:
res['current_password'] = '******'
if self.new_password and self.verbose < 5:
def do_set_password(self):
print()
- msg = _("Setting password of {dn!r} with hashing schema {schema!r}.").format(
- dn=self.user_dn, schema=self.schema_id)
msg = _("Setting password of '{dn}' with hashing schema '{schema}' ...").format(
- dn=self.colored(self.user_dn, 'CYAN'), schema=self.colored(self.schema_id, 'CYAN'))
+ dn=self.colored(self.user_dn, 'CYAN'),
+ schema=self.colored(self.pwd_handler.schema_id, 'CYAN'))
print(msg)
if self.current_password_hash:
self.colored(self.user_dn, 'CYAN'))
print(msg)
- LOG.debug(_("Used schema: {!r}.").format(self.schema))
- hashed_passwd = self.pwd_handler.get_hash(self.new_password, self.schema)
+ LOG.debug(_("Used schema: {!r}.").format(self.pwd_handler.schema))
+ hashed_passwd = self.pwd_handler.get_hash(self.new_password, self.pwd_handler.schema)
msg = _("New password hash: '{}'.").format(self.colored(hashed_passwd, 'CYAN'))
print(msg)
_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.2.1'
+__version__ = '0.2.2'
# =============================================================================
if initialized:
self.initialized = True
+ # -------------------------------------------------------------------------
+ @property
+ def salt_len(self):
+ """Gives the valid length of a salt string in dependency to the current schema."""
+ if hasattr(self, 'schema') and self.schema == 'ldap_des_crypt':
+ return 2
+ return 8
+
+ # -------------------------------------------------------------------------
+ @property
+ def salt(self):
+ """The salt of the current schema."""
+ if not hasattr(self.__class__, 'passlib_context'):
+ return None
+ return self.passlib_context.salt()
+
# -------------------------------------------------------------------------
def as_dict(self, short=True):
"""
res = super(LdapPasswordHandler, self).as_dict(short=short)
res['available_schemes'] = self.available_schemes
+ res['passlib_context'] = self.passlib_context.to_dict(True)
res['default_schema'] = self.passlib_context.default_scheme()
+ # res['salt'] = self.salt
+ res['salt_len'] = self.salt_len
res['schema_ids'] = self.schema_ids
return res