Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
49f1fc83
Commit
49f1fc83
authored
Jul 27, 2021
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor go class to stop referencing auth::result.actor directly
parent
718b30c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
lib/gitlab/auth/result.rb
lib/gitlab/auth/result.rb
+12
-0
lib/gitlab/middleware/go.rb
lib/gitlab/middleware/go.rb
+9
-7
No files found.
lib/gitlab/auth/result.rb
View file @
49f1fc83
...
...
@@ -29,6 +29,18 @@ module Gitlab
def
deploy_token
actor
.
is_a?
(
DeployToken
)
?
actor
:
nil
end
def
can?
(
action
)
actor
&
.
can?
(
action
)
end
def
can_perform_action_on_project?
(
action
,
given_project
)
Ability
.
allowed?
(
actor
,
action
,
given_project
)
end
def
authentication_abilities_include?
(
ability
)
authentication_abilities
.
include?
(
ability
)
end
end
end
end
...
...
lib/gitlab/middleware/go.rb
View file @
49f1fc83
...
...
@@ -127,23 +127,25 @@ module Gitlab
def
project_for_paths
(
paths
,
request
)
project
=
Project
.
where_full_path_in
(
paths
).
first
return
unless
Ability
.
allowed?
(
current_user
(
request
,
project
),
:read_project
,
project
)
return
unless
authentication_result
(
request
,
project
).
can_perform_action_on_project?
(
:read_project
,
project
)
project
end
def
current_user
(
request
,
project
)
return
unless
has_basic_credentials?
(
request
)
def
authentication_result
(
request
,
project
)
empty_result
=
Gitlab
::
Auth
::
Result
.
new
(
nil
,
nil
,
nil
,
nil
)
return
empty_result
unless
has_basic_credentials?
(
request
)
login
,
password
=
user_name_and_password
(
request
)
auth_result
=
Gitlab
::
Auth
.
find_for_git_client
(
login
,
password
,
project:
project
,
ip:
request
.
ip
)
return
unless
auth_result
.
success?
return
empty_result
unless
auth_result
.
success?
return
unless
auth_result
.
actor
&
.
can?
(
:access_git
)
return
empty_result
unless
auth_result
.
can?
(
:access_git
)
return
unless
auth_result
.
authentication_abilities
.
include?
(
:read_project
)
return
empty_result
unless
auth_result
.
authentication_abilities_
include?
(
:read_project
)
auth_result
.
actor
auth_result
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment