omniauth-bitrix24 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: 04166228a1b0c457968ed33e4e5d3cbde18ce9e2
4
+ data.tar.gz: ac66530b0eb61449ce9083532c38324083f9292d
5
+ SHA512:
6
+ metadata.gz: 48fd74d23ad98e855701298458ba24eb8c6eb1d5969f33147600e1cdddcca3ae79758296aaa83d6eb448b39e72e296e923a02bf2a433f99ab0e3edd8f32877e0
7
+ data.tar.gz: e010c5f0b867781ae8cbde9fa9a015c4856c234a4e314023463b18ccb09e6ce431b08527e1d595a62c335d344a27c6d7e097cb78cedf0bed79b2368d65946e93
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
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-bitrix24.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Alexandr Prokopenko
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 Bitrix24
2
+
3
+ This gem contains the [Bitrix24](https://www.bitrix24.ru/) strategy for OmniAuth.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-bitrix24'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-bitrix24
20
+
21
+
22
+ ## Usage
23
+
24
+ Be sure to define callback URL in application version settings at [partner control panel](http://partners.1c-bitrix.ru/personal/b24marketplace/index.php), for example 'http://127.0.0.1:4567/auth/bitrix24/callback'.
25
+
26
+ ```ruby
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :bitrix24, 'https://myportal.bitrix24.ru', '<<<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-bitrix24/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/bitrix24"
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-bitrix24', :path => '../'
6
+
7
+
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ omniauth-bitrix24 (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
+ x64-mingw32
52
+
53
+ DEPENDENCIES
54
+ omniauth-bitrix24!
55
+ sinatra
56
+ sinatra-reloader
@@ -0,0 +1,29 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra'
3
+ require 'omniauth-bitrix24'
4
+
5
+ class OmniBitrixDemo < Sinatra::Base
6
+ use Rack::Session::Cookie
7
+ use OmniAuth::Builder do
8
+ provider :bitrix24, 'https://myportal.bitrix24.ru', '<<<client_id>>>', '<<<client_secret>>>'
9
+ end
10
+
11
+ get '/' do
12
+ <<-HTML
13
+ <a href='/auth/bitrix24'>Sign in</a>
14
+ HTML
15
+ end
16
+
17
+ get '/auth/bitrix24/callback' do
18
+ <<-HTML
19
+ <img src="#{request.env['omniauth.auth'].info.image}" width=64></img>
20
+ Hello, <strong>#{request.env['omniauth.auth'].info.name}!</strong>
21
+ HTML
22
+ end
23
+
24
+ get '/auth/bitrix24/failure' do
25
+ "Sorry, but something went wrong :("
26
+ end
27
+ end
28
+
29
+ OmniBitrixDemo.run!
@@ -0,0 +1 @@
1
+ require 'omniauth/bitrix24'
@@ -0,0 +1,2 @@
1
+ require 'omniauth/bitrix24/version'
2
+ require 'omniauth/strategies/bitrix24'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Bitrix24
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,53 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Bitrix24 < OmniAuth::Strategies::OAuth2
6
+ args [:site, :client_id, :client_secret]
7
+ option :site, nil
8
+
9
+ option :token_params, {scope: 'user'}
10
+
11
+ uid{ raw_info['ID'] }
12
+
13
+ info do
14
+ {
15
+ name: "#{raw_info['NAME']} #{raw_info['LAST_NAME']}",
16
+ email: raw_info['EMAIL'] ,
17
+ first_name: raw_info['NAME'],
18
+ last_name: raw_info['LAST_NAME'],
19
+ image: raw_info['PERSONAL_PHOTO'],
20
+ phone: raw_info['PERSONAL_PHONE']
21
+ }
22
+ end
23
+
24
+ extra do
25
+ {
26
+ 'raw_info' => raw_info
27
+ }
28
+ end
29
+
30
+ def raw_info
31
+ @raw_info ||= get('/rest/user.current').parsed['result']
32
+ end
33
+
34
+ def get(method)
35
+ access_token.get(method, info_options)
36
+ end
37
+
38
+ def info_options
39
+ {
40
+ params: {
41
+ auth: access_token.token
42
+ }
43
+ }
44
+ end
45
+
46
+ def client
47
+ ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize({site: options.site}).merge({token_method: :get}))
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ OmniAuth.config.add_camelization "bitrix24", "Bitrix24"
@@ -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/bitrix24/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-bitrix24"
8
+ spec.version = OmniAuth::Bitrix24::VERSION
9
+ spec.authors = ["Alexandr Prokopenko"]
10
+ spec.email = ["prokopneko@igc.ru"]
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{Bitrix24 OAuth2 strategy for OmniAuth}
17
+ spec.homepage = "https://github.com/crsde/omniauth-bitrix24"
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,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-bitrix24
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexandr Prokopenko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-16 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
+ - prokopneko@igc.ru
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-bitrix24.rb
90
+ - lib/omniauth/bitrix24.rb
91
+ - lib/omniauth/bitrix24/version.rb
92
+ - lib/omniauth/strategies/bitrix24.rb
93
+ - omniauth-bitrix24.gemspec
94
+ homepage: https://github.com/crsde/omniauth-bitrix24
95
+ licenses:
96
+ - MIT
97
+ metadata:
98
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'' to prevent pushes to
99
+ rubygems.org, or delete to allow pushes to any server.'
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.2.2
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Bitrix24 OAuth2 strategy for OmniAuth
120
+ test_files: []