omniauth-atlassian-oauth2 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0d5da77bbadf763c528ca165d95e52edf69f4f7d
4
+ data.tar.gz: 28a8ccaedfe43675126e1149342a6f796ce1c603
5
+ SHA512:
6
+ metadata.gz: 7a5e34412396381b0c86c12981212537728e293d2a8858690fe3ea5b6e05ee665e6fe2cc3f89e997aa244ed7e37584051c6dc854cc4350c164ecfd538e002e33
7
+ data.tar.gz: f7e47d664ac5506c322922f8224dafaa61be7a11370963db6b7dbcba08dc59910b51e255c4f610dea398cc8cec3c93e19b49caab657227ea3b4355a132d983a5
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ ClassLength:
2
+ Enabled: false
3
+ Layout/IndentHeredoc:
4
+ Enabled: false
5
+ Metrics/AbcSize:
6
+ Enabled: false
7
+ Metrics/BlockLength:
8
+ ExcludedMethods: ['describe', 'context']
9
+ Metrics/CyclomaticComplexity:
10
+ Enabled: false
11
+ Metrics/LineLength:
12
+ Enabled: false
13
+ Metrics/MethodLength:
14
+ Enabled: false
15
+ Metrics/PerceivedComplexity:
16
+ Enabled: false
17
+ Naming:
18
+ Enabled: false
19
+ Style/MutableConstant:
20
+ Enabled: false
21
+ Gemspec/RequiredRubyVersion:
22
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. Follows the
4
+ religion set forth in https://keepachangelog.com/en/1.0.0/
5
+
6
+ ## 0.1.0 - 2018-03-01
7
+
8
+ ### Added
9
+ - First commit.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-atlassian-oauth2 (0.1.0)
5
+ omniauth (>= 1.1.1)
6
+ omniauth-oauth2 (>= 1.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.0)
12
+ diff-lcs (1.3)
13
+ faraday (0.15.4)
14
+ multipart-post (>= 1.2, < 3)
15
+ hashie (3.6.0)
16
+ jaro_winkler (1.5.2)
17
+ jwt (2.1.0)
18
+ multi_json (1.13.1)
19
+ multi_xml (0.6.0)
20
+ multipart-post (2.0.0)
21
+ oauth2 (1.4.1)
22
+ faraday (>= 0.8, < 0.16.0)
23
+ jwt (>= 1.0, < 3.0)
24
+ multi_json (~> 1.3)
25
+ multi_xml (~> 0.5)
26
+ rack (>= 1.2, < 3)
27
+ omniauth (1.9.0)
28
+ hashie (>= 3.4.6, < 3.7.0)
29
+ rack (>= 1.6.2, < 3)
30
+ omniauth-oauth2 (1.6.0)
31
+ oauth2 (~> 1.1)
32
+ omniauth (~> 1.9)
33
+ parallel (1.14.0)
34
+ parser (2.6.0.0)
35
+ ast (~> 2.4.0)
36
+ powerpack (0.1.2)
37
+ psych (3.1.0)
38
+ rack (2.0.6)
39
+ rainbow (3.0.0)
40
+ rake (12.3.2)
41
+ rspec (3.8.0)
42
+ rspec-core (~> 3.8.0)
43
+ rspec-expectations (~> 3.8.0)
44
+ rspec-mocks (~> 3.8.0)
45
+ rspec-core (3.8.0)
46
+ rspec-support (~> 3.8.0)
47
+ rspec-expectations (3.8.2)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.8.0)
50
+ rspec-mocks (3.8.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.8.0)
53
+ rspec-support (3.8.0)
54
+ rubocop (0.65.0)
55
+ jaro_winkler (~> 1.5.1)
56
+ parallel (~> 1.10)
57
+ parser (>= 2.5, != 2.5.1.1)
58
+ powerpack (~> 0.1)
59
+ psych (>= 3.1.0)
60
+ rainbow (>= 2.2.2, < 4.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (~> 1.4.0)
63
+ ruby-progressbar (1.10.0)
64
+ unicode-display_width (1.4.1)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ omniauth-atlassian-oauth2!
71
+ rake (~> 12.0)
72
+ rspec (~> 3.6)
73
+ rubocop (~> 0.49)
74
+
75
+ BUNDLED WITH
76
+ 1.17.1
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # OmniAuth Google OAuth2 Strategy
2
+
3
+ Strategy to authenticate with Atlassian via OAuth2 in OmniAuth.
4
+
5
+ Get your API key at: https://developer.atlassian.com/apps/ Note the Client ID and the Client Secret.
6
+
7
+ For more details, read the Atlassian docs: https://developer.atlassian.com/cloud/jira/platform/security-for-other-integrations/
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/atlassian_oauth2'
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/strategies/atlassian_oauth2'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module AtlassianOauth2
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/strategies/oauth2'
4
+ require 'uri'
5
+
6
+ # NOTE: %3A in scope is a colon
7
+ #
8
+ # https://auth.atlassian.com/authorize?
9
+ # audience=api.atlassian.com
10
+ # client_id=7v6ghRsOM5BIHj4jmCxEmxyL743hwTEq
11
+ # scope=read%3Ajira-user
12
+ # redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fatlassian%2Fcallback
13
+ # state=${YOUR_USER_BOUND_VALUE}
14
+ # response_type=code
15
+ # prompt=consent
16
+
17
+ # Scopes: https://developer.atlassian.com/cloud/jira/platform/scopes/
18
+ # read:jira-user
19
+ # read:jira-work
20
+ # write:jira-work
21
+ # manage:jira-project
22
+ # manage:jira-configuration
23
+ # Separate scopes with a space (%20)
24
+ # https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/
25
+
26
+ module OmniAuth
27
+ module Strategies
28
+ # Omniauth strategy for Atlassian
29
+ class AtlassianOauth2 < OmniAuth::Strategies::OAuth2
30
+ option :name, 'atlassian_oauth2'
31
+ option :client_options,
32
+ site: 'https://auth.atlassian.com',
33
+ authorize_url: 'https://auth.atlassian.com/authorize',
34
+ token_url: 'https://auth.atlassian.com/oauth/token',
35
+ audience: 'api.atlassian.com'
36
+ option :authorize_params,
37
+ prompt: 'consent',
38
+ audience: 'api.atlassian.com'
39
+
40
+ uid do
41
+ raw_info['myself']['accountId']
42
+ end
43
+
44
+ info do
45
+ {
46
+ name: raw_info['myself']['displayName'],
47
+ email: raw_info['myself']['emailAddress'],
48
+ nickname: raw_info['myself']['name'],
49
+ location: raw_info['myself']['timeZone'],
50
+ image: raw_info['myself']['avatarUrls']['48x48']
51
+ }
52
+ end
53
+
54
+ extra do
55
+ {
56
+ 'raw_info' => raw_info
57
+ }
58
+ end
59
+
60
+ def raw_info
61
+ # NOTE: api.atlassian.com, not auth.atlassian.com!
62
+ accessible_resources_url = 'https://api.atlassian.com/oauth/token/accessible-resources'
63
+ sites = JSON.parse(access_token.get(accessible_resources_url).body)
64
+
65
+ # Jira's OAuth gives us many potential sites. To request information
66
+ # about the user for the OmniAuth hash, pick the first one that has the
67
+ # necessary 'read:jira-user' scope.
68
+
69
+ jira_user_scope = 'read:jira-user'
70
+ site = sites.find do |candidate_site|
71
+ candidate_site['scopes'].include?(jira_user_scope)
72
+ end
73
+ unless site
74
+ raise "No site found with scope #{jira_user_scope}, please ensure the scope ${jira_user_scope} is added to your OmniAuth config"
75
+ end
76
+
77
+ cloud_id = site['id']
78
+ base_url = "https://api.atlassian.com/ex/jira/#{cloud_id}"
79
+ myself_url = "#{base_url}/rest/api/3/myself"
80
+
81
+ myself = JSON.parse(access_token.get(myself_url).body)
82
+
83
+ @raw_info ||= {
84
+ 'site' => site,
85
+ 'sites' => sites,
86
+ 'myself' => myself
87
+ }
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(
4
+ File.join('..', 'lib', 'omniauth', 'atlassian_oauth2', 'version'),
5
+ __FILE__
6
+ )
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = 'omniauth-atlassian-oauth2'
10
+ gem.version = OmniAuth::AtlassianOauth2::VERSION
11
+ gem.license = 'MIT'
12
+ gem.summary = %(An Atlassian OAuth2 strategy for OmniAuth 1.x)
13
+ gem.description = %(An Atlassian OAuth2 strategy for OmniAuth 1.x. This allows you to login to Atlassian with your ruby app.)
14
+ gem.authors = ['Ben Standefer']
15
+ gem.email = ['benstandefer@gmail.com']
16
+ gem.homepage = 'https://github.com/aguynamedben/omniauth-atlassian-oauth2'
17
+
18
+ gem.files = `git ls-files`.split("\n")
19
+ gem.require_paths = ['lib']
20
+
21
+ gem.required_ruby_version = '>= 2.1'
22
+
23
+ gem.add_runtime_dependency 'omniauth', '>= 1.1.1'
24
+ gem.add_runtime_dependency 'omniauth-oauth2', '>= 1.5'
25
+
26
+ gem.add_development_dependency 'rake', '~> 12.0'
27
+ gem.add_development_dependency 'rspec', '~> 3.6'
28
+ gem.add_development_dependency 'rubocop', '~> 0.49'
29
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-atlassian-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Standefer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.49'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.49'
83
+ description: An Atlassian OAuth2 strategy for OmniAuth 1.x. This allows you to login
84
+ to Atlassian with your ruby app.
85
+ email:
86
+ - benstandefer@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".rubocop.yml"
92
+ - CHANGELOG.md
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - README.md
96
+ - lib/omniauth-atlassian-oauth2.rb
97
+ - lib/omniauth/atlassian_oauth2.rb
98
+ - lib/omniauth/atlassian_oauth2/version.rb
99
+ - lib/omniauth/strategies/atlassian_oauth2.rb
100
+ - omniauth-atlassian-oauth2.gemspec
101
+ homepage: https://github.com/aguynamedben/omniauth-atlassian-oauth2
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '2.1'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.5.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: An Atlassian OAuth2 strategy for OmniAuth 1.x
125
+ test_files: []