Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
common-web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
protokollsystem
common-web
Commits
4c0c16f0
Commit
4c0c16f0
authored
Apr 04, 2018
by
Robin Sonnabend
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove obsoletion feature
parent
b6a8aa25
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
21 deletions
+11
-21
auth.py
auth.py
+11
-21
No files found.
auth.py
View file @
4c0c16f0
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment