Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
0
Merge Requests
0
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-shell
Commits
d27a22a2
Commit
d27a22a2
authored
Feb 04, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
validate access via api
parent
d554bd90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+14
-1
No files found.
lib/gitlab_shell.rb
View file @
d27a22a2
require
'open3'
require
'net/http'
require_relative
'gitlab_config'
class
GitlabShell
...
...
@@ -17,7 +19,9 @@ class GitlabShell
if
git_cmds
.
include?
(
@git_cmd
)
ENV
[
'GL_USER'
]
=
@username
process_cmd
if
validate_access
process_cmd
end
else
puts
'Not allowed command'
end
...
...
@@ -42,4 +46,13 @@ class GitlabShell
repo_full_path
=
File
.
join
(
repos_path
,
repo_name
)
system
(
"
#{
@git_cmd
}
#{
repo_full_path
}
"
)
end
def
validate_access
@ref_name
=
'master'
# just hardcode it cause we dont know ref
project_name
=
@repo_name
.
gsub
(
"'"
,
""
)
project_name
=
project_name
.
gsub
(
/\.git$/
,
""
)
url
=
"http://127.0.0.1:3000/api/v3/allowed?project=
#{
project_name
}
&username=
#{
@username
}
&action=
#{
@git_cmd
}
&ref=
#{
@ref_name
}
"
resp
=
Net
::
HTTP
.
get_response
(
URI
.
parse
(
url
))
resp
.
code
==
'200'
&&
resp
.
body
==
'true'
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