omniauth-segment 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b06e729d1ca614c735be1f0d39eb983cefcda1d9bc15aecfd8e48c04d38794eb
4
+ data.tar.gz: 7c15a82a4fc12b9b8d76c1d648481a652ccb84b3a44f55ea8a9f80c6ea2a7a23
5
+ SHA512:
6
+ metadata.gz: 4943f62e98ef3dd016307b36fc7056211c9fc811a47ee061d58fb910d51738b7520646f9f6e19ab00df38279d42320878337ced459ccbe49deb7373e37ddc954
7
+ data.tar.gz: 63b480fde67ee4c0fda2ac57f7d4fa508e32d582b9e098bc61752566de3858b05817b872a1ea5e42394d4be00ef641ad019bd00f362c977654e9cd1153aae5dc
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ .rspec_status
4
+ Gemfile.lock
5
+ pkg/*
6
+ coverage
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in omniauth-segment.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Ferruccio Balestreri
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.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Anmol Arora
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ # Omniauth::Segment
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/omniauth-segment.svg)](https://badge.fury.io/rb/omniauth-segment)
4
+
5
+ This gem contains the Segment strategy for OmniAuth.
6
+
7
+ For more information about the Segment Api authentication: https://segment.com/docs/partners/enable-with-segment/
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'omniauth-segment'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install omniauth-segment
24
+
25
+ ## Usage
26
+
27
+ If you are using rails, you need to add the gem to your Gemfile:
28
+
29
+ ```ruby
30
+ gem 'omniauth-segment'
31
+ ```
32
+ You can pull them in directly from github e.g.:
33
+
34
+ ```ruby
35
+ gem "omniauth-segment", :git => "git://github.com/ferrucc-io/omniauth-segment.git"
36
+ ```
37
+
38
+ Add provider in omniauth.rb along with CLIENT_ID and CLIENT_SECRET
39
+
40
+ e.g.
41
+ ```ruby
42
+ provider :segment, SEGMENT_CLIENT_ID, SEGMENT_CLIENT_SECRET, callback_url: SEGMENT_CALLBACK_URL
43
+ ```
44
+
45
+ Obtain your CLIENT_ID/CLIENT_SECRET by registering your app on: https://segment.com/partners/integration/
46
+
47
+ After you have the gem running and the configuration is done, you can get to the follow url to log the user in:
48
+
49
+ http://localhost:3000/auth/segment
50
+
51
+ Now just follow the README at: https://github.com/omniauth/omniauth
52
+
53
+ ### Questions
54
+ For any question, fell free to send me a tweet [@0xferruccio](https://twitter.com/0xferruccio)
55
+
56
+ ## Contributing
57
+
58
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ferrucc-io/omniauth-segment.
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/segment"
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__)
@@ -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,2 @@
1
+ require "omniauth/strategies/omniauth-segment"
2
+ require "omniauth-segment/version"
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Segment
3
+ VERSION = "0.1"
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ # Segment Omniauth Strategy
6
+ class Segment < OmniAuth::Strategies::OAuth2
7
+ option :name, 'segment'
8
+
9
+ option :client_options, \
10
+ site: 'https://id.segmentapis.com',
11
+ authorize_url: 'https://id.segmentapis.com/oauth2/auth',
12
+ token_url: 'https://id.segmentapis.com/oauth2/token'
13
+
14
+ def scope
15
+ options[:scope]
16
+ end
17
+
18
+ def build_access_token
19
+ options.token_params.merge!(:headers => {'Authorization' => basic_auth_header })
20
+ super
21
+ end
22
+
23
+ def basic_auth_header
24
+ "Basic " + Base64.strict_encode64("#{options[:client_id]}:#{options[:client_secret]}")
25
+ end
26
+
27
+ def callback_url
28
+ return options[:redirect_uri] unless options[:redirect_uri].nil?
29
+ full_host + script_name + callback_path
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "omniauth-segment/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-segment"
8
+ spec.version = OmniAuth::Segment::VERSION
9
+ spec.authors = ["Ferruccio Balestreri"]
10
+ spec.email = ["hi@ferrucc.io"]
11
+
12
+ spec.summary = %q{OmniAuth strategy for Segment}
13
+ spec.description = %q{OmniAuth strategy for Segment}
14
+ spec.homepage = "https://github.com/ferrucc-io/omniauth-segment"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.6'
25
+ spec.add_development_dependency "bundler", "~> 2.0.2"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-segment
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Ferruccio Balestreri
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.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.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: OmniAuth strategy for Segment
70
+ email:
71
+ - hi@ferrucc.io
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitattributes"
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - Gemfile
80
+ - LICENSE
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/omniauth-segment.rb
87
+ - lib/omniauth-segment/version.rb
88
+ - lib/omniauth/strategies/omniauth-segment.rb
89
+ - omniauth-segment.gemspec
90
+ homepage: https://github.com/ferrucc-io/omniauth-segment
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubygems_version: 3.0.6
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: OmniAuth strategy for Segment
113
+ test_files: []