Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProxyIdP GUI
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
Perun
Perun ProxyIdP
ProxyIdP GUI
Commits
9d51ca1e
Commit
9d51ca1e
authored
2 years ago
by
Rastislav Kruták
Browse files
Options
Downloads
Patches
Plain Diff
feat: upgrade sqlalchemy usage to v2
parent
c5c8c95e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!26
feat: migrate sqlalchemy to v2
Pipeline
#299469
passed
2 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
perun/proxygui/user_manager.py
+23
-20
23 additions, 20 deletions
perun/proxygui/user_manager.py
with
23 additions
and
20 deletions
perun/proxygui/user_manager.py
+
23
−
20
View file @
9d51ca1e
...
@@ -8,6 +8,7 @@ from pymongo.collection import Collection
...
@@ -8,6 +8,7 @@ from pymongo.collection import Collection
from
sqlalchemy
import
delete
,
select
from
sqlalchemy
import
delete
,
select
from
sqlalchemy.engine
import
Engine
from
sqlalchemy.engine
import
Engine
from
sqlalchemy.orm.session
import
Session
from
sqlalchemy.orm.session
import
Session
from
sqlalchemy
import
MetaData
from
perun.utils.ConfigStore
import
ConfigStore
from
perun.utils.ConfigStore
import
ConfigStore
...
@@ -78,8 +79,8 @@ class UserManager:
...
@@ -78,8 +79,8 @@ class UserManager:
session_id
:
str
=
None
,
session_id
:
str
=
None
,
include_refresh_tokens
=
False
,
include_refresh_tokens
=
False
,
)
->
list
[
Any
]:
)
->
list
[
Any
]:
meta_data
=
sqlalchemy
.
MetaData
(
bind
=
engine
)
meta_data
=
MetaData
(
)
sqlalchemy
.
M
eta
D
ata
.
reflect
(
meta_data
)
m
eta
_d
ata
.
reflect
(
engine
)
session
=
Session
(
bind
=
engine
)
session
=
Session
(
bind
=
engine
)
# tables holding general auth data
# tables holding general auth data
...
@@ -145,10 +146,11 @@ class UserManager:
...
@@ -145,10 +146,11 @@ class UserManager:
statements
=
self
.
_get_mitre_delete_statements
(
statements
=
self
.
_get_mitre_delete_statements
(
engine
,
user_id
,
session_id
,
include_refresh_tokens
engine
,
user_id
,
session_id
,
include_refresh_tokens
)
)
with
engine
.
connect
()
as
cnxn
:
for
stmt
in
statements
:
for
stmt
in
statements
:
result
=
engine
.
execute
(
stmt
)
with
cnxn
.
begin
():
deleted_mitre_tokens_count
+=
result
.
rowcount
result
=
cnxn
.
execute
(
stmt
)
deleted_mitre_tokens_count
+=
result
.
rowcount
return
deleted_mitre_tokens_count
return
deleted_mitre_tokens_count
...
@@ -228,8 +230,8 @@ class UserManager:
...
@@ -228,8 +230,8 @@ class UserManager:
def
_get_mitre_client_ids
(
self
,
user_id
:
str
)
->
list
[
str
]:
def
_get_mitre_client_ids
(
self
,
user_id
:
str
)
->
list
[
str
]:
engine
=
self
.
_get_postgres_engine
()
engine
=
self
.
_get_postgres_engine
()
meta_data
=
sqlalchemy
.
MetaData
(
bind
=
engine
)
meta_data
=
MetaData
(
)
sqlalchemy
.
M
eta
D
ata
.
reflect
(
meta_data
)
m
eta
_d
ata
.
reflect
(
engine
)
session
=
Session
(
bind
=
engine
)
session
=
Session
(
bind
=
engine
)
AUTH_HOLDER_TBL
=
meta_data
.
tables
[
"
authentication_holder
"
]
AUTH_HOLDER_TBL
=
meta_data
.
tables
[
"
authentication_holder
"
]
...
@@ -237,23 +239,24 @@ class UserManager:
...
@@ -237,23 +239,24 @@ class UserManager:
ACCESS_TOKEN_TBL
=
meta_data
.
tables
[
"
access_token
"
]
ACCESS_TOKEN_TBL
=
meta_data
.
tables
[
"
access_token
"
]
CLIENT_DETAILS_TBL
=
meta_data
.
tables
[
"
client_details
"
]
CLIENT_DETAILS_TBL
=
meta_data
.
tables
[
"
client_details
"
]
stmt
=
select
(
CLIENT_DETAILS_TBL
.
c
.
client_id
).
where
(
with
engine
.
connect
()
as
cnxn
:
CLIENT_DETAILS_TBL
.
c
.
id
.
in_
(
with
cnxn
.
begin
():
session
.
query
(
ACCESS_TOKEN_TBL
.
c
.
client_id
).
filter
(
stmt
=
select
(
CLIENT_DETAILS_TBL
.
c
.
client_id
).
where
(
ACCESS_TOKEN_TBL
.
c
.
auth_holder_id
.
in_
(
CLIENT_DETAILS_TBL
.
c
.
id
.
in_
(
session
.
query
(
AUTH_HOLDER_TBL
.
c
.
id
).
filter
(
session
.
query
(
ACCESS_TOKEN_TBL
.
c
.
client_id
).
filter
(
AUTH_HOLDER_TBL
.
c
.
user_auth_id
.
in_
(
ACCESS_TOKEN_TBL
.
c
.
auth_holder_id
.
in_
(
session
.
query
(
SAVED_USER_AUTH_TBL
.
c
.
id
).
filter
(
session
.
query
(
AUTH_HOLDER_TBL
.
c
.
id
).
filter
(
SAVED_USER_AUTH_TBL
.
c
.
name
==
user_id
AUTH_HOLDER_TBL
.
c
.
user_auth_id
.
in_
(
session
.
query
(
SAVED_USER_AUTH_TBL
.
c
.
id
).
filter
(
SAVED_USER_AUTH_TBL
.
c
.
name
==
user_id
)
)
)
)
)
)
)
)
)
)
)
)
)
result
=
cnxn
.
execute
(
stmt
)
)
result
=
engine
.
execute
(
stmt
)
return
[
r
[
0
]
for
r
in
result
]
return
[
r
[
0
]
for
r
in
result
]
def
_get_ssp_entity_ids_by_user
(
self
,
sub
:
str
):
def
_get_ssp_entity_ids_by_user
(
self
,
sub
:
str
):
...
...
This diff is collapsed.
Click to expand it.
Jednotné přihlášení test
@9008807
mentioned in commit
32cd3bbf
·
2 years ago
mentioned in commit
32cd3bbf
mentioned in commit 32cd3bbff81c08f5ca5ceeac15bbd75b5ad2966f
Toggle commit list
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