Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
common-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
protokollsystem
common-web
Commits
4c0c16f0
Commit
4c0c16f0
authored
7 years ago
by
Robin Sonnabend
Browse files
Options
Downloads
Patches
Plain Diff
Remove obsoletion feature
parent
b6a8aa25
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
auth.py
+11
-21
11 additions, 21 deletions
auth.py
with
11 additions
and
21 deletions
auth.py
+
11
−
21
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment