Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Galaxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
NDIP
Galaxy
Merge requests
!83
Add ability to get api key with oauth token
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add ability to get api key with oauth token
api-token-auth
into
dev
Overview
2
Commits
2
Pipelines
2
Changes
1
Merged
Cage, Gregory
requested to merge
api-token-auth
into
dev
8 months ago
Overview
2
Commits
2
Pipelines
2
Changes
1
Expand
Closes
#110 (closed)
0
0
Merge request reports
Compare
dev
version 3
d3bae042
8 months ago
version 2
d3bae042
8 months ago
version 1
d3bae042
8 months ago
dev (base)
and
latest version
latest version
3b08caab
2 commits,
8 months ago
version 3
d3bae042
1 commit,
8 months ago
version 2
d3bae042
4332 commits,
8 months ago
version 1
d3bae042
1 commit,
8 months ago
1 file
+
17
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
lib/galaxy/webapps/galaxy/services/authenticate.py
+
17
−
6
Options
@@ -36,17 +36,28 @@ class AuthenticationService:
def
get_api_key
(
self
,
environ
:
Dict
[
str
,
Any
],
request
:
Request
)
->
APIKeyResponse
:
auth_header
=
environ
.
get
(
"
HTTP_AUTHORIZATION
"
)
identity
,
password
=
self
.
_decode_baseauth
(
auth_header
)
# check if this is an email address or username
user
=
self
.
_user_manager
.
get_user_by_identity
(
identity
)
oauth_auth
=
False
if
"
Bearer
"
in
auth_header
:
oidc_access_token
=
auth_header
.
replace
(
"
Bearer
"
,
""
)
user
=
self
.
_user_manager
.
by_oidc_access_token
(
oidc_access_token
)
oauth_auth
=
True
else
:
identity
,
password
=
self
.
_decode_baseauth
(
auth_header
)
# check if this is an email address or username
user
=
self
.
_user_manager
.
get_user_by_identity
(
identity
)
if
not
user
:
raise
exceptions
.
ObjectNotFound
(
"
The user does not exist.
"
)
is_valid_user
=
self
.
_auth_manager
.
check_password
(
user
,
password
,
request
)
if
is_valid_user
:
if
oauth_auth
:
key
=
self
.
_api_keys_manager
.
get_or_create_api_key
(
user
)
return
APIKeyResponse
(
api_key
=
key
)
else
:
raise
exceptions
.
AuthenticationFailed
(
"
Invalid password.
"
)
is_valid_user
=
self
.
_auth_manager
.
check_password
(
user
,
password
,
request
)
if
is_valid_user
:
key
=
self
.
_api_keys_manager
.
get_or_create_api_key
(
user
)
return
APIKeyResponse
(
api_key
=
key
)
else
:
raise
exceptions
.
AuthenticationFailed
(
"
Invalid password.
"
)
def
_decode_baseauth
(
self
,
encoded_str
:
Optional
[
Any
])
->
Tuple
[
str
,
str
]:
"""
Loading