Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
key_auth
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
key_auth
Merge requests
!18
Add more permissions for managing auth key access.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add more permissions for managing auth key access.
issue/key_auth-3261708:3261708-a-separate-permission-
into
2.x
Overview
0
Commits
2
Pipelines
3
Changes
3
Merged
Roman Gudev
requested to merge
issue/key_auth-3261708:3261708-a-separate-permission-
into
2.x
8 months ago
Overview
0
Commits
2
Pipelines
3
Changes
3
Expand
Closes
#3261708
0
0
Merge request reports
Compare
2.x
version 3
760ca825
1 month ago
version 2
760ca825
1 month ago
version 1
432f8720
8 months ago
2.x (base)
and
latest version
latest version
760ca825
2 commits,
1 month ago
version 3
760ca825
2 commits,
1 month ago
version 2
760ca825
2 commits,
1 month ago
version 1
432f8720
1 commit,
8 months ago
3 files
+
28
−
15
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/Form/UserKeyAuthForm.php
+
17
−
14
Options
@@ -134,18 +134,21 @@ class UserKeyAuthForm extends FormBase {
];
}
$form
[
'actions'
]
=
[
'new'
=>
[
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'Generate new key'
),
],
'delete'
=>
[
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'Delete current key'
),
'#access'
=>
(
bool
)
$key
,
'#submit'
=>
[
'::deleteKey'
],
],
];
if
(
$user
->
id
()
==
$this
->
currentUser
()
->
id
()
&&
$this
->
currentUser
()
->
hasPermission
(
'manage own auth keys'
)
||
$this
->
currentUser
()
->
hasPermission
(
'manage any auth keys'
))
{
$form
[
'actions'
]
=
[
'new'
=>
[
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'Generate new key'
),
],
'delete'
=>
[
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'Delete current key'
),
'#access'
=>
(
bool
)
$key
,
'#submit'
=>
[
'::deleteKey'
],
],
];
}
return
$form
;
}
@@ -192,10 +195,10 @@ class UserKeyAuthForm extends FormBase {
// Check if the user being edited is not the current user.
if
(
$user
->
id
()
!=
$current_user
->
id
())
{
// Check admin-access.
$access
=
AccessResult
::
allowedIfHasPermission
(
$current_user
,
'administer users
'
);
$access
=
AccessResult
::
allowedIfHasPermission
s
(
$current_user
,
[
'manage any auth keys'
],
'OR
'
);
}
else
{
$access
=
AccessResult
::
allowedIf
(
$this
->
keyAuth
->
access
(
$current_user
)
);
$access
=
AccessResult
::
allowedIf
HasPermissions
(
$current_user
,
[
'manage any auth keys'
,
'view own auth keys'
],
'OR'
);
}
// Add caching.
Loading