omniauth-telphin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5428594038e67609cfb97640b035c3da0d26e17
4
+ data.tar.gz: e4c685472e97615c1b355429b94498656551594e
5
+ SHA512:
6
+ metadata.gz: 02e893d5f98d5ed0c748b90fbe2eb3675435b5f2b9a10a27818d500bd542435ae4841cb13d4b6b59c2e5dd60b4ea36ad7dde580c7039d5499fc36074c7a1579e
7
+ data.tar.gz: 10b9b4223b5fd32034544310ecaaa72c9ed12f5f3f4e3af3adc8f6701a68a90b48bf0ad786f8d75b64d9d44cdaef400e7a6943fb5ff0aa64c0955f75a6d99d3c
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea
11
+ omniauth-telphin.iml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-telphin.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Konstantin Tyutyunnikov
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,41 @@
1
+ # Omniauth Telphin
2
+
3
+ This gem contains the [Telphin](https://www.telphin.ru/) strategy for OmniAuth.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-telphin'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-telphin
20
+
21
+
22
+ ## Usage
23
+
24
+ Be sure to define callback URL in application version settings at [partner control panel](https://pbx.telphin.ru), for example 'https://127.0.0.1:4567/auth/telphin/callback'.
25
+
26
+ ```ruby
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :telphin, '<<<client_id>>>', '<<<client_secret>>>'
29
+ end
30
+ ```
31
+
32
+ Also you can see dead-simple example in *example* directory
33
+
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/[my-github-username]/omniauth-telphin/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new
7
+
8
+ desc 'Default: run specs.'
9
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/telphin"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'sinatra-reloader'
5
+ gem 'omniauth-telphin', :path => '../'
6
+
7
+
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ omniauth-telphin (0.1.0)
5
+ omniauth-oauth2 (~> 1.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ backports (3.6.5)
11
+ faraday (0.9.1)
12
+ multipart-post (>= 1.2, < 3)
13
+ hashie (3.4.2)
14
+ jwt (1.5.1)
15
+ multi_json (1.11.2)
16
+ multi_xml (0.5.5)
17
+ multipart-post (2.0.0)
18
+ oauth2 (1.0.0)
19
+ faraday (>= 0.8, < 0.10)
20
+ jwt (~> 1.0)
21
+ multi_json (~> 1.3)
22
+ multi_xml (~> 0.5)
23
+ rack (~> 1.2)
24
+ omniauth (1.2.2)
25
+ hashie (>= 1.2, < 4)
26
+ rack (~> 1.0)
27
+ omniauth-oauth2 (1.3.1)
28
+ oauth2 (~> 1.0)
29
+ omniauth (~> 1.2)
30
+ rack (1.6.4)
31
+ rack-protection (1.5.3)
32
+ rack
33
+ rack-test (0.6.3)
34
+ rack (>= 1.0)
35
+ sinatra (1.4.6)
36
+ rack (~> 1.4)
37
+ rack-protection (~> 1.4)
38
+ tilt (>= 1.3, < 3)
39
+ sinatra-contrib (1.4.6)
40
+ backports (>= 2.0)
41
+ multi_json
42
+ rack-protection
43
+ rack-test
44
+ sinatra (~> 1.4.0)
45
+ tilt (>= 1.3, < 3)
46
+ sinatra-reloader (1.0)
47
+ sinatra-contrib
48
+ tilt (2.0.1)
49
+
50
+ PLATFORMS
51
+ ruby
52
+ x64-mingw32
53
+
54
+ DEPENDENCIES
55
+ omniauth-telphin!
56
+ sinatra
57
+ sinatra-reloader
58
+
59
+ BUNDLED WITH
60
+ 1.10.6
@@ -0,0 +1,28 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra'
3
+ require 'omniauth-telphin'
4
+
5
+ class OmniTelphinDemo < Sinatra::Base
6
+ use Rack::Session::Cookie
7
+ use OmniAuth::Builder do
8
+ # provider :telphin, '<<telphin_Ключ клиента>>', '<<telphin_Секрет клиента>>', :provider_ignores_state => true, :debug => true
9
+ provider :telphin, 'F~PUJXc8X5_2vUy7W5B~IBjXm6Hv~dRT', 'x~X1r206MB~ckpYhb6c.W4ch4OLx_9If', :provider_ignores_state => true
10
+ end
11
+
12
+ get '/' do
13
+ <<-HTML
14
+ <a href='/auth/telphin'>Sign in</a>
15
+ HTML
16
+ end
17
+
18
+ get '/auth/telphin/callback' do
19
+ @auth = request.env['omniauth.auth']
20
+ @auth.to_json
21
+ end
22
+
23
+ get '/auth/failure' do
24
+ "Sorry, but something went wrong :("
25
+ end
26
+ end
27
+
28
+ OmniTelphinDemo.run!
@@ -0,0 +1 @@
1
+ require 'omniauth/telphin'
@@ -0,0 +1,13 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OAuth2
4
+ module Strategy
5
+ class ClientCredentials < Base
6
+ def get_token(params = {}, opts = {})
7
+ params.merge!('grant_type' => 'client_credentials')
8
+ params.merge! client_params
9
+ @client.get_token(params, opts.merge('refresh_token' => nil))
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Telphin < OmniAuth::Strategies::OAuth2
6
+ option :name, 'telphin'
7
+
8
+ args [:client_id, :client_secret]
9
+ option :client_options, {
10
+ :site => 'https://pbx.telphin.ru',
11
+ :token_url => '/oauth/token.php'
12
+ }
13
+
14
+ def request_phase
15
+ redirect callback_url
16
+ end
17
+
18
+ def callback_phase
19
+ self.access_token = client.client_credentials.get_token
20
+ env['omniauth.auth'] = auth_hash
21
+ call_app!
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ OmniAuth.config.add_camelization "telphin", "Telphin"
@@ -0,0 +1,3 @@
1
+ require 'omniauth/telphin/version'
2
+ require 'omniauth/strategies/client_credentials'
3
+ require 'omniauth/strategies/telphin'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Telphin
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/telphin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-telphin"
8
+ spec.version = OmniAuth::Telphin::VERSION
9
+ spec.authors = ["Konstantin Tyutyunnikov"]
10
+ spec.email = ["mrootooz@gmail.com"]
11
+
12
+ # if spec.respond_to?(:metadata)
13
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
+ # end
15
+
16
+ spec.summary = %q{Telphin OAuth2 strategy for OmniAuth}
17
+ spec.homepage = "https://github.com/rootooz/omniauth-telphin"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.8"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.3"
30
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-telphin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Konstantin Tyutyunnikov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-24 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.8'
34
+ type: :development
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: 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.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.3'
69
+ description:
70
+ email:
71
+ - mrootooz@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - example/Gemfile
87
+ - example/Gemfile.lock
88
+ - example/app.rb
89
+ - lib/omniauth-telphin.rb
90
+ - lib/omniauth/strategies/client_credentials.rb
91
+ - lib/omniauth/strategies/telphin.rb
92
+ - lib/omniauth/telphin.rb
93
+ - lib/omniauth/telphin/version.rb
94
+ - omniauth-telphin.gemspec
95
+ homepage: https://github.com/rootooz/omniauth-telphin
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.4.8
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Telphin OAuth2 strategy for OmniAuth
119
+ test_files: []