Commit 4c0c16f0 authored by Robin Sonnabend's avatar Robin Sonnabend

Remove obsoletion feature

parent b6a8aa25
......@@ -6,7 +6,7 @@ from datetime import datetime
class User:
def __init__(self, username, groups, all_groups, timestamp=None,
obsolete=False, permanent=False):
permanent=False):
self.username = username
self.groups = groups
self.all_groups = all_groups
......@@ -14,7 +14,6 @@ class User:
self.timestamp = timestamp
else:
self.timestamp = datetime.now()
self.obsolete = obsolete
self.permanent = permanent
def __repr__(self):
......@@ -23,22 +22,19 @@ class User:
def summarize(self):
return ":".join((
self.username, ",".join(self.groups), ",".join(self.all_groups),
str(self.timestamp.timestamp()), str(self.obsolete),
str(self.permanent)))
str(self.timestamp.timestamp()), str(self.permanent)))
@staticmethod
def from_summary(summary):
parts = summary.split(":", 5)
if len(parts) != 6:
parts = summary.split(":", 4)
if len(parts) != 5:
return None
(name, group_str, all_group_str, timestamp_str, obsolete_str,
permanent_str) = parts
(name, group_str, all_group_str, timestamp_str, permanent_str) = parts
timestamp = datetime.fromtimestamp(float(timestamp_str))
obsolete = obsolete_str == "True"
groups = group_str.split(",")
all_groups = all_group_str.split(",")
permanent = permanent_str == "True"
return User(name, groups, all_groups, timestamp, obsolete, permanent)
return User(name, groups, all_groups, timestamp, permanent)
@staticmethod
def from_hashstring(secure_string):
......@@ -57,8 +53,7 @@ class UserManager:
all_groups = sorted(list(set(backend.all_groups(
username, password))))
return User(
username, groups, all_groups, obsolete=backend.obsolete,
permanent=permanent)
username, groups, all_groups, permanent=permanent)
return None
......@@ -92,7 +87,7 @@ class SecurityManager:
class StaticUserManager:
def __init__(self, users, obsolete=False):
def __init__(self, users):
self.passwords = {
username: password
for (username, password, groups) in users
......@@ -101,7 +96,6 @@ class StaticUserManager:
username: groups
for (username, password, groups) in users
}
self.obsolete = obsolete
def authenticate(self, username, password):
return (username in self.passwords
......@@ -119,12 +113,10 @@ try:
import ldap3
class LdapManager:
def __init__(self, host, user_dn, group_dn, port=636, use_ssl=True,
obsolete=False):
def __init__(self, host, user_dn, group_dn, port=636, use_ssl=True):
self.server = ldap3.Server(host, port=port, use_ssl=use_ssl)
self.user_dn = user_dn
self.group_dn = group_dn
self.obsolete = obsolete
def authenticate(self, username, password):
try:
......@@ -153,7 +145,7 @@ try:
class ADManager:
def __init__(self, host, domain, user_dn, group_dn,
port=636, use_ssl=True, ca_cert=None, obsolete=False):
port=636, use_ssl=True, ca_cert=None):
tls_config = ldap3.Tls(validate=ssl.CERT_REQUIRED)
if ca_cert is not None:
tls_config = ldap3.Tls(
......@@ -171,7 +163,6 @@ try:
self.domain = domain
self.user_dn = user_dn
self.group_dn = group_dn
self.obsolete = obsolete
def prepare_connection(self, username=None, password=None):
if username is not None and password is not None:
......@@ -235,9 +226,8 @@ try:
import pam
class PAMManager:
def __init__(self, obsolete=False):
def __init__(self):
self.pam = pam.pam()
self.obsolete = obsolete
def authenticate(self, username, password):
return self.pam.authenticate(username, password)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment