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
af617386
Commit
af617386
authored
Aug 16, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial addition to mimic Github OAuth calls for Jira
parent
965d87a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
app/controllers/oauth/jira/authorizations_controller.rb
app/controllers/oauth/jira/authorizations_controller.rb
+37
-0
config/routes.rb
config/routes.rb
+13
-0
No files found.
app/controllers/oauth/jira/authorizations_controller.rb
0 → 100644
View file @
af617386
class
Oauth::Jira::AuthorizationsController
<
Doorkeeper
::
AuthorizationsController
skip_before_action
:authenticate_resource_owner!
,
only: :access_token
skip_before_action
:verify_authenticity_token
,
only: :access_token
# Overriden from Doorkeeper::AuthorizationsController to
# include the call to session.delete
def
new
session
[
:redirect_uri
]
=
params
[
'redirect_uri'
]
redirect_to
oauth_authorization_path
(
client_id:
params
[
'client_id'
],
response_type:
'code'
,
redirect_uri:
'http://glgh-api-proxy.ngrok.io/jira/login/oauth/authorize_callback'
)
end
def
callback
redirect_uri
=
session
[
:redirect_uri
]
session
[
:redirect_uri
]
=
nil
redirect_to
(
redirect_uri
+
'&code='
+
params
[
:code
])
end
def
access_token
req_params
=
{
client_id:
params
[
:client_id
],
client_secret:
params
[
:client_secret
],
code:
params
[
:code
],
grant_type:
'authorization_code'
,
redirect_uri:
'http://glgh-api-proxy.ngrok.io/jira/login/oauth/authorize_callback'
}
Rails
.
logger
.
info
(
"------
#{
req_params
}
"
)
response
=
HTTParty
.
post
(
'http://glgh-api-proxy.ngrok.io/jira/login/oauth/token'
,
body:
req_params
)
token
=
"access_token="
+
response
[
'access_token'
]
+
"&scope="
+
response
[
'scope'
]
+
"&token_type="
+
response
[
'token_type'
]
render
text:
token
end
end
config/routes.rb
View file @
af617386
...
...
@@ -19,6 +19,19 @@ Rails.application.routes.draw do
controllers
applications:
'oauth/applications'
,
authorized_applications:
'oauth/authorized_applications'
,
authorizations:
'oauth/authorizations'
end
# TODO: find a :only sort of option to generate only the routes we need
scope
path:
'/jira/login'
do
use_doorkeeper
do
controllers
authorizations:
'oauth/jira/authorizations'
as
authorizations: :jira_authorization
end
# Making the role of Github for Jira
get
'/oauth/authorize_callback'
=>
'oauth/jira/authorizations#callback'
,
as: :oauth_jira_callback
post
'/oauth/access_token'
=>
'oauth/jira/authorizations#access_token'
end
namespace
:oauth
do
...
...
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