omniauth-intercom 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
+ SHA1:
3
+ metadata.gz: 9db0767314f658f4a3edbbfa8a378877c95f6e26
4
+ data.tar.gz: d799638a2712b3ddfcf817479c7477c3f0bfa8ee
5
+ SHA512:
6
+ metadata.gz: 54bba5243a083f4bc7b36a378b736a06192c1289bcceaabd4daba13e2b56112490bcf651ec87eef1626472f7d33ff0bffbbe39db535eda02a14c1be3427ed057
7
+ data.tar.gz: 828e403a165adedd6e135d81da5eb554cf11cd94cfaf5c2fec25176bdbf80cc60f21b60353c61fe2c0673a61fadc655309bf6b28eae5a08a370601ac0b4e4a67
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ omniauth-intercom-*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.7
5
+ before_install: gem install bundler -v 1.12.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 0.1.0 (2016-05-03)
2
+
3
+ Features:
4
+
5
+ - Omniauth2 basic auth (@Skaelv)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-intercom.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Skaelv
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.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+
2
+ # OmniAuth Intercom
3
+
4
+ Intercom OAuth2 Strategy for OmniAuth.
5
+
6
+ Supports the OAuth 2.0 server-side and client-side flows. Read the [Intercom OAuth docs](https://developers.intercom.io/reference#oauth) for more details:
7
+
8
+ ## Installing
9
+
10
+ Add to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem 'omniauth-intercom'
14
+ ```
15
+
16
+ Then `bundle install`.
17
+
18
+ ## Usage
19
+
20
+ `OmniAuth::Strategies::Intercom` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.
21
+
22
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
23
+
24
+ ```ruby
25
+ Rails.application.config.middleware.use OmniAuth::Builder do
26
+ provider :intercom, ENV['INTERCOM_KEY'], ENV['INTERCOM_SECRET']
27
+ end
28
+ ```
29
+ To start the authentication process with Intercom you simply need to access `/auth/intercom` route.
30
+
31
+ **Important** You need the `read_admins` permissions to use this middleware.
32
+ **Important** Your `redirect_url` should be `/auth/intercom/callback`
33
+
34
+ ## Auth Hash
35
+
36
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
37
+
38
+ ```ruby
39
+ {
40
+ :provider => 'intercom',
41
+ :uid => '342324',
42
+ :info => {
43
+ :email => 'kevin.antoine@intercom.io',
44
+ :name => 'Kevin Antoine'
45
+ },
46
+ :credentials => {
47
+ :token => 'dG9rOmNdrWt0ZjtgzzE0MDdfNGM5YVe4MzsmXzFmOGd2MDhiMfJmYTrxOtA=', # OAuth 2.0 access_token, which you may wish to store
48
+ :expires => false
49
+ },
50
+ :extra => {
51
+ :raw_info => {
52
+ :name => 'Kevin Antoine',
53
+ :email => 'kevin.antoine@intercom.io',
54
+ :type => 'admin',
55
+ :id => '342324',
56
+ :app => {
57
+ :id_code => 'abc123', # Company app_id
58
+ :type: 'app'
59
+ }
60
+ :avatar => {
61
+ :image_url => "https://static.intercomassets.com/avatars/343616/square_128/me.jpg?1454165491"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ ```
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/intercom"
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
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 @@
1
+ require 'omniauth/intercom'
@@ -0,0 +1,2 @@
1
+ require 'omniauth/intercom/version'
2
+ require 'omniauth/strategies/intercom'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Intercom
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,51 @@
1
+ require 'omniauth-oauth2'
2
+ module OmniAuth
3
+ module Strategies
4
+ class Intercom < OmniAuth::Strategies::OAuth2
5
+ # Give your strategy a name.
6
+ option :name, "intercom"
7
+
8
+ # This is where you pass the options you would pass when
9
+ # initializing your consumer from the OAuth gem.
10
+ option :client_options, {
11
+ :site => 'https://api.intercom.io',
12
+ # :site => 'http://localhost:4000',
13
+ :authorize_url => 'https://app.intercom.io/oauth',
14
+ :token_url => 'https://api.intercom.io/auth/eagle/token'
15
+ }
16
+
17
+ # These are called after authentication has succeeded. If
18
+ # possible, you should try to set the UID without making
19
+ # additional calls (if the user id is returned with the token
20
+ # or as a URI parameter). This may not be possible with all
21
+ # providers.
22
+ uid{ raw_info['id'] }
23
+
24
+ info do
25
+ {
26
+ :name => raw_info['name'],
27
+ :email => raw_info['email']
28
+ }
29
+ end
30
+
31
+ extra do
32
+ {
33
+ 'raw_info' => raw_info
34
+ }
35
+ end
36
+
37
+ def raw_info
38
+ accept_headers
39
+ access_token.options[:mode] = :body
40
+ @raw_info ||= access_token.get('/me').parsed
41
+ end
42
+
43
+ protected
44
+ def accept_headers
45
+ access_token.client.connection.headers['Authorization'] = access_token.client.connection.basic_auth(access_token.token, '')
46
+ access_token.client.connection.headers['Accept'] = "application/vnd.intercom.3+json"
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/intercom/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-intercom"
8
+ spec.version = OmniAuth::Intercom::VERSION
9
+ spec.authors = ["Kevin Antoine"]
10
+ spec.email = ["kevin.antoine@intercom.io"]
11
+
12
+ spec.summary = 'Intercom OAuth2 Strategy for OmniAuth'
13
+ spec.homepage = 'https://github.com/intercom/omniauth-intercom'
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-intercom
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Antoine
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-03 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.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
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:
70
+ email:
71
+ - kevin.antoine@intercom.io
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CHANGELOG.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/omniauth-intercom.rb
87
+ - lib/omniauth/intercom.rb
88
+ - lib/omniauth/intercom/version.rb
89
+ - lib/omniauth/strategies/intercom.rb
90
+ - omniauth-intercom.gemspec
91
+ homepage: https://github.com/intercom/omniauth-intercom
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.8
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Intercom OAuth2 Strategy for OmniAuth
115
+ test_files: []
116
+ has_rdoc: