omniauth-signalwire 0.1.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: fe022a40564f239d9bf4a58592d184a6af7d313b98a78089327231c437ab3720
4
+ data.tar.gz: 05b024fdc96666498b9ac372249c71fcdb39f1888cf39d7d5d52097c35894448
5
+ SHA512:
6
+ metadata.gz: 53464d07e371b46b501fb6753d8cc540bda3d48cf6ff16bf27f4290e40398a80b7ca510a63386182ff0e2bb154648f6b51f7a8d7356e2c3170c09b9b5ba02a79
7
+ data.tar.gz: 7e549735681827a7ccc241c25209fc1dedacec9b4788981047329f6b450dbc2b1abd7144614c09cedca38923d7c6445e7492fb18ea9aed2118ad1403c2c6e7d1
@@ -0,0 +1,24 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Set up Ruby ${{ matrix.ruby-version }}
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ bundler-cache: true
23
+ - name: Build and test with Rake
24
+ 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
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Naming/FileName:
16
+ Enabled: false
17
+
18
+ Style/Documentation:
19
+ Enabled: false
20
+
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "rake", "~> 13.0"
8
+ gem "rspec", "~> 3.13"
9
+ gem "rubocop", "~> 1.21"
10
+ gem "rubocop-rake"
11
+ gem "rubocop-rspec"
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ [![Ruby](https://github.com/ryanwi/omniauth-signalwire/actions/workflows/ruby.yml/badge.svg)](https://github.com/ryanwi/omniauth-signalwire/actions/workflows/ruby.yml)
2
+
3
+ # OmniAuth SignalWire
4
+
5
+ This is an OmniAuth strategy for authenticating to SignalWire.
6
+
7
+ ## Installation
8
+
9
+ ```ruby
10
+ gem 'omniauth-signalwire', '~> 0.1'
11
+ ```
12
+
13
+ ## Basic Usage
14
+
15
+ ```ruby
16
+ use OmniAuth::Builder do
17
+ provider :signalwire, ENV['SIGNALWIRE_KEY'], ENV['SIGNALWIRE_SECRET']
18
+ end
19
+ ```
20
+
21
+ ## Basic Usage Rails
22
+
23
+ In `config/initializers/signalwire.rb`
24
+
25
+ ```ruby
26
+ Rails.application.config.middleware.use OmniAuth::Builder do
27
+ provider :signalwire, ENV['SIGNALWIRE_KEY'], ENV['SIGNALWIRE_SECRET']
28
+ end
29
+ ```
30
+
31
+ ## Authentication Hash
32
+ An example auth hash available in `request.env['omniauth.auth']`:
33
+
34
+ ```
35
+ {
36
+ :provider => "signalwire",
37
+ :uid => "4d1bcf6e-88ed-4cfa-87bb-b986cd65678e",
38
+ :info => {
39
+ :email => "user@example.com",
40
+ :first_name => "Jane",
41
+ :last_name => "Doe",
42
+ :display_name => "Jane Doe",
43
+ ...
44
+ },
45
+ :credentials => {
46
+ :token => "a1b2c3d4...", # The OAuth 2.0 access token
47
+ :refresh_token => "2QY...",
48
+ :expires_at => 1709194759,
49
+ :expires => true
50
+ },
51
+ :extra = {
52
+ :raw_info => {
53
+ ...
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ryanwi/omniauth-signalwire.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "omniauth/signalwire"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require "irb"
11
+ 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,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "omniauth-oauth2"
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class SignalWire < OmniAuth::Strategies::OAuth2
8
+ option :name, :signalwire
9
+
10
+ option :client_options, {
11
+ site: "https://fabric.signalwire.com",
12
+ authorize_url: "https://id.fabric.signalwire.com/login/oauth/authorize",
13
+ token_url: "https://id.fabric.signalwire.com/oauth/token"
14
+ }
15
+
16
+ option :pkce, true
17
+
18
+ uid { raw_info["id"] }
19
+
20
+ info do
21
+ {
22
+ email: raw_info["email"],
23
+ first_name: raw_info["first_name"],
24
+ last_name: raw_info["last_name"],
25
+ display_name: raw_info["display_name"],
26
+ job_title: raw_info["job_title"],
27
+ time_zone: raw_info["time_zone"],
28
+ country: raw_info["country"],
29
+ region: raw_info["region"],
30
+ company_name: raw_info["company_name"]
31
+ }
32
+ end
33
+
34
+ extra do
35
+ {
36
+ "raw_info" => raw_info
37
+ }
38
+ end
39
+
40
+ def raw_info
41
+ @raw_info ||= access_token.get("/subscriber/info").parsed
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ OmniAuth.config.add_camelization "signalwire", "SignalWire"
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module SignalWire
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "omniauth-signalwire/version"
4
+ require "omniauth/strategies/signalwire"
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("lib/omniauth-signalwire/version", __dir__)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.authors = ["SignalWire Team"]
7
+ spec.email = ["open.source@signalwire.com"]
8
+ spec.description = "Official OmniAuth strategy for SignalWire."
9
+ spec.summary = "Official OmniAuth strategy for SignalWire."
10
+ spec.homepage = "https://github.com/signalwire/omniauth-signalwire"
11
+ spec.name = "omniauth-signalwire"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split("\n")
15
+ spec.require_paths = ["lib"]
16
+ spec.version = OmniAuth::SignalWire::VERSION
17
+ spec.required_ruby_version = ">= 2.7"
18
+
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/signalwire/omniauth-signalwire"
22
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ # spec.files = Dir.chdir(__dir__) do
27
+ # `git ls-files -z`.split("\x0").reject do |f|
28
+ # (File.expand_path(f) == __FILE__) ||
29
+ # f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
30
+ # end
31
+ # end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
+
35
+ spec.add_dependency "omniauth", "~> 2.0"
36
+ spec.add_dependency "omniauth-oauth2", "~> 1.8"
37
+ spec.add_development_dependency "rack-test", "~> 2.1"
38
+ spec.add_development_dependency "rspec", "~> 3.13"
39
+ spec.add_development_dependency "webmock", "~> 3.23"
40
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe OmniAuth::Strategies::SignalWire do
6
+ subject(:strategy) { described_class.new({}) }
7
+
8
+ describe "#client" do
9
+ it "has the correct site" do
10
+ expect(strategy.client.site).to eq("https://fabric.signalwire.com")
11
+ end
12
+
13
+ it "has the correct authorization url" do
14
+ expect(strategy.client.options[:authorize_url]).to eq("https://id.fabric.signalwire.com/login/oauth/authorize")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path(__dir__)
4
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
5
+ require "rspec"
6
+ require "rack/test"
7
+ require "webmock/rspec"
8
+ require "omniauth"
9
+ require "omniauth-signalwire"
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
15
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-signalwire
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - SignalWire Team
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-02-29 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: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.1'
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.13'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.23'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.23'
83
+ description: Official OmniAuth strategy for SignalWire.
84
+ email:
85
+ - open.source@signalwire.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".github/workflows/ruby.yml"
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".rubocop.yml"
94
+ - Gemfile
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - lib/omniauth-signalwire.rb
100
+ - lib/omniauth-signalwire/version.rb
101
+ - lib/omniauth/strategies/signalwire.rb
102
+ - omniauth-signalwire.gemspec
103
+ - spec/omniauth/strategies/signalwire_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://github.com/signalwire/omniauth-signalwire
106
+ licenses:
107
+ - MIT
108
+ metadata:
109
+ homepage_uri: https://github.com/signalwire/omniauth-signalwire
110
+ source_code_uri: https://github.com/signalwire/omniauth-signalwire
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '2.7'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubygems_version: 3.5.3
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Official OmniAuth strategy for SignalWire.
130
+ test_files: []