omniauth-ibmid 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 40e1380c599d8e9836448319861572d8afa5a43db54d8b36109f47d40e014a89
4
+ data.tar.gz: 425535704cab737039715d7c8ac35d62c37f60f61be4b3e8d85b21da1bd571c1
5
+ SHA512:
6
+ metadata.gz: be15d2f555a969bc0ec677599202077a86f75764c0b64cef5248d3c28a3547adceb4cba548e5dcb0ee6bf64b32dc0841c1b537a8a32c35557c534d755d344ceb
7
+ data.tar.gz: 9f0730b3a94dbe5cc1c1d5c3b2ad10a1f4dbba1cefd5c95c577cf690479f8e29acf8191999ba4937d4840b49e41cb41a9f78d5451f734476200d5beecdf2d9a3
data/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ indent_size = 2
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = true
@@ -0,0 +1,32 @@
1
+ name: validate
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ style:
10
+ name: code style
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 2.7
17
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
18
+ - run: bundle exec rbprettier --check .
19
+
20
+ test:
21
+ name: test
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby: ["2.4", "2.5", "2.6", "2.7"]
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+ - uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
32
+ - run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+ *.gem
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.prettierignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /pkg/
6
+ /spec/reports/
7
+ /tmp/
8
+ /vendor/
9
+ Gemfile.lock
data/.prettierrc.yml ADDED
@@ -0,0 +1 @@
1
+ rubySingleQuote: false
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ inherit_gem:
2
+ prettier: rubocop.yml
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-ibmid.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) International Business Machines Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # OmniAuth IBMid
2
+
3
+ This is the OmniAuth stragegy for authenticaing to IBMid
4
+
5
+ ## Installation
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem "omniauth-ibmid"
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ use OmniAuth::Builder do
17
+ provider :ibmid, ENV["IBMID_OIDC_CLIENT_ID"], ENV["IBMID_OIDC_CLIENT_SECRET"]
18
+ end
19
+ ```
20
+
21
+ ## License
22
+
23
+ [MIT License](./LICENSE).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth-ibmid"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gem "sinatra", ">= 2.0"
6
+ gem "omniauth", ">= 2.0"
7
+ gem "omniauth-ibmid", path: "../../"
@@ -0,0 +1,38 @@
1
+ begin
2
+ require "sinatra"
3
+ require "securerandom"
4
+ require "omniauth"
5
+ require "omniauth-ibmid"
6
+ rescue LoadError
7
+ require "rubygems"
8
+ require "securerandom"
9
+ require "sinatra"
10
+ require "omniauth"
11
+ require "omniauth-ibmid"
12
+ end
13
+
14
+ set sessions: true
15
+ set :session_secret, ENV.fetch("SESSION_SECRET") { SecureRandom.hex(64) }
16
+
17
+ use Rack::Session::Cookie
18
+ use OmniAuth::Builder do
19
+ provider :ibmid, ENV["IBMID_OIDC_CLIENT_ID"], ENV["IBMID_OIDC_CLIENT_SECRET"]
20
+ end
21
+
22
+ get "/" do
23
+ <<-HTML
24
+ <form method='post' action='/auth/ibmid'>
25
+ <input type="hidden" name="authenticity_token" value='#{request.env["rack.session"]["csrf"]}'>
26
+ <button type='submit'>Sign in with IBMid</button>
27
+ </form>
28
+ HTML
29
+ end
30
+
31
+ get "/auth/:name/callback" do
32
+ auth = request.env["omniauth.auth"]
33
+ <<-HTML
34
+ <h1>You are logged in as #{auth["info"]["email"]}</h1>
35
+ <div>OmniAuth::AuthHash::InfoHash</div>
36
+ <span>#{auth["info"].to_json}</span>
37
+ HTML
38
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-ibmid/version"
2
+ require "omniauth/strategies/ibmid"
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Ibmid
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,49 @@
1
+ require "omniauth-oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Ibmid < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = "openid".freeze
7
+
8
+ option :name, "ibmid"
9
+ option :client_options,
10
+ {
11
+ site: "https://login.ibm.com",
12
+ authorize_url:
13
+ "https://login.ibm.com/oidc/endpoint/default/authorize",
14
+ token_url: "https://login.ibm.com/oidc/endpoint/default/token",
15
+ user_info_url:
16
+ "https://login.ibm.com/oidc/endpoint/default/userinfo",
17
+ response_type: "id_token"
18
+ }
19
+ option :scope, DEFAULT_SCOPE
20
+ option :provider_ignores_state, true
21
+
22
+ uid { raw_info["uniqueSecurityName"] }
23
+
24
+ info do
25
+ {
26
+ name: "#{raw_info["given_name"]} #{raw_info["family_name"]}",
27
+ first_name: raw_info["given_name"],
28
+ last_name: raw_info["family_name"],
29
+ email: raw_info["email"]
30
+ }
31
+ end
32
+
33
+ extra { { "raw_info" => raw_info } }
34
+
35
+ def client_options
36
+ options.fetch(:client_options)
37
+ end
38
+
39
+ def raw_info
40
+ @raw_info ||=
41
+ access_token.get(client_options.fetch(:user_info_url)).parsed
42
+ end
43
+
44
+ def callback_url
45
+ full_host + script_name + callback_path
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,41 @@
1
+ require_relative "lib/omniauth-ibmid/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "omniauth-ibmid"
5
+ spec.version = OmniAuth::Ibmid::VERSION
6
+ spec.authors = ["Michael Lin"]
7
+ spec.email = ["mlzc@hey.com"]
8
+
9
+ spec.summary = "IBMid strategy for OmniAuth"
10
+ spec.description = "IBMid strategy for OmniAuth"
11
+ spec.homepage = "https://github.com/ibm/omniauth-ibmid"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] =
17
+ "https://github.com/ibm-skills-network/omniauth-ibmid"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files =
22
+ Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|spec|features)/})
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "omniauth", [">= 1.9", "< 3"]
32
+ spec.add_dependency "omniauth-oauth2", ">= 1.4"
33
+
34
+ spec.add_development_dependency "bundler", ">= 2.0"
35
+ spec.add_development_dependency "prettier", ">= 1.5.5"
36
+ spec.add_development_dependency "rack-test"
37
+ spec.add_development_dependency "rake"
38
+ spec.add_development_dependency "rspec", ">= 3.0"
39
+ spec.add_development_dependency "simplecov"
40
+ spec.add_development_dependency "webmock"
41
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-ibmid
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Lin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-04-28 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.9'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.9'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
33
+ - !ruby/object:Gem::Dependency
34
+ name: omniauth-oauth2
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '1.4'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '1.4'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: prettier
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.5.5
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.5.5
75
+ - !ruby/object:Gem::Dependency
76
+ name: rack-test
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '3.0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: simplecov
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: webmock
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ description: IBMid strategy for OmniAuth
146
+ email:
147
+ - mlzc@hey.com
148
+ executables: []
149
+ extensions: []
150
+ extra_rdoc_files: []
151
+ files:
152
+ - ".editorconfig"
153
+ - ".github/workflows/validate.yml"
154
+ - ".gitignore"
155
+ - ".prettierignore"
156
+ - ".prettierrc.yml"
157
+ - ".rspec"
158
+ - ".rubocop.yml"
159
+ - Gemfile
160
+ - LICENSE
161
+ - README.md
162
+ - Rakefile
163
+ - bin/console
164
+ - bin/setup
165
+ - examples/sinatra/Gemfile
166
+ - examples/sinatra/app.rb
167
+ - lib/omniauth-ibmid.rb
168
+ - lib/omniauth-ibmid/version.rb
169
+ - lib/omniauth/strategies/ibmid.rb
170
+ - omniauth-ibmid.gemspec
171
+ homepage: https://github.com/ibm/omniauth-ibmid
172
+ licenses:
173
+ - MIT
174
+ metadata:
175
+ homepage_uri: https://github.com/ibm/omniauth-ibmid
176
+ source_code_uri: https://github.com/ibm-skills-network/omniauth-ibmid
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: 2.3.0
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubygems_version: 3.1.2
193
+ signing_key:
194
+ specification_version: 4
195
+ summary: IBMid strategy for OmniAuth
196
+ test_files: []