Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
soctools-user-mgmt-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
gn4-3-wp8-t3.1 SOC
soctools-user-mgmt-ui
Commits
134bc228
Commit
134bc228
authored
2 years ago
by
Václav Bartoš
Browse files
Options
Downloads
Patches
Plain Diff
user cert is now revoked when user is deleted
parent
4097f905
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
certificates.py
+11
-5
11 additions, 5 deletions
certificates.py
main.py
+6
-4
6 additions, 4 deletions
main.py
with
17 additions
and
9 deletions
certificates.py
+
11
−
5
View file @
134bc228
...
...
@@ -123,11 +123,17 @@ def revoke_certificate(cn: str):
:param cn: CN (common name) identifying the certificate
"""
_check_cn
(
cn
)
raise
NotImplementedError
# cmd = [{EASYRSA}, "TODO", cn]
# result = subprocess.run(cmd, env=EASYRSA_ENV, stderr=subprocess.PIPE)
# if result.returncode != 0:
# raise CertError(f"Can't revoke the certificate for '{cn}': {result.stderr[:500]}")
# Revoke the certificate
cmd
=
[
EASYRSA
,
"
revoke
"
,
cn
]
result
=
subprocess
.
run
(
cmd
,
env
=
EASYRSA_ENV
,
stderr
=
subprocess
.
PIPE
)
if
result
.
returncode
!=
0
:
raise
CertError
(
f
"
Can
'
t revoke the certificate for
'
{
cn
}
'
:
{
result
.
stderr
[
:
500
]
}
"
)
# Refresh the CRL list
cmd
=
[
EASYRSA
,
"
gen-crl
"
]
result
=
subprocess
.
run
(
cmd
,
env
=
EASYRSA_ENV
,
stderr
=
subprocess
.
PIPE
)
if
result
.
returncode
!=
0
:
raise
CertError
(
f
"
Certificate revoked, but there was an error during generating CRL:
{
result
.
stderr
[
:
500
]
}
"
)
# TODO check that Keycloak really looks into the CRL during user authentication
def
get_pem_files
(
cn
:
str
):
...
...
This diff is collapsed.
Click to expand it.
main.py
+
6
−
4
View file @
134bc228
...
...
@@ -374,8 +374,6 @@ def add_user():
try
:
certificates
.
generate_certificate
(
user
.
cn
)
flash
(
f
'
Certificate for user
"
{
user
.
username
}
"
was successfully created.
'
,
"
success
"
)
except
certificates
.
CertError
as
e
:
flash
(
str
(
e
),
"
error
"
)
return
redirect_to_main_page
()
# don't continue creating user accounts in services
...
...
@@ -531,12 +529,16 @@ def delete_user(username: str):
flash
(
f
"
Error: Can
'
t get user info from KeyCloak:
{
e
}
"
,
"
error
"
)
return
redirect_to_main_page
()
# TODO revoke certificate
try
:
certificates
.
revoke_certificate
(
user_spec
.
cn
)
flash
(
f
'
Certificate for
"
{
user_spec
.
cn
}
"
revoked.
'
,
"
success
"
)
except
certificates
.
CertError
as
e
:
flash
(
f
"
Error:
{
e
}
"
,
"
error
"
)
# Keycloak
try
:
kc_delete_user
(
user_spec
.
kcid
)
flash
(
'
User successfully deleted from KeyCloak.
'
,
"
success
"
)
flash
(
f
'
User
"
{
user_spec
.
username
}
"
successfully deleted from KeyCloak.
'
,
"
success
"
)
except
KeycloakError
as
e
:
flash
(
f
'
Error when deleting user from KeyCloak:
{
e
}
'
,
"
error
"
)
...
...
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