omniauth-kona 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: 570d25af43dac608793a7264388ff898969ecc8b
4
+ data.tar.gz: 363b7854c1b6a01ef6f523079ff4da5365c477cd
5
+ SHA512:
6
+ metadata.gz: c276786745b5b8c487e79b111e4c637114617903a4072c85652b50936b0cb1d2be12c1e1efa76a035c64e9acd74011d0f73e953e515204119f3ddac6cc00cd11
7
+ data.tar.gz: 18037b9e05f506ac920eaf1e6df2aafc17f119668dbd76ccea9ca65529ba61edf3974fc95c1fecebba3d91958b1e809d6208825e344393663ae0fd52e8753511
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
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -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-kona.gemspec
4
+ gemspec
data/History.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Version 0.1.0
2
+ ### Added
3
+ * Initial pass
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ronald Salas
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,98 @@
1
+ # OmniAuth Kona
2
+
3
+ OmniAuth strategy for authenticating your users using Kona.
4
+
5
+ [ ![Codeship Status for ronaldsalas/omniauth-kona](https://codeship.com/projects/4bb85690-450f-0133-7583-6641cf1712e7/status?branch=master)](https://codeship.com/projects/104599)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-kona'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-kona
22
+
23
+ ## Usage
24
+
25
+ In your Kona Business account administration, register your application to get the Client ID and Client secret. Make sure that you put `http://YOURSERVER/auth/kona/callback` in the redirect URI field, with `YOURSERVER` is your application's server name (and port number if any). Kona matches exactly the redirect URI passed by the gem to the URI it has on record to authenticate the user, so make sure that you put in the correct URI.
26
+
27
+ Afterwards you can add the middleware in your Rails app in `config/initializers/omniauth.rb`
28
+
29
+ ```ruby
30
+ Rails.application.config.middleware.use OmniAuth::Builder do
31
+ provider :kona, "ClientID", "ClientSecret"
32
+ end
33
+ ```
34
+
35
+ You can check out the Sinatra example included.
36
+
37
+ ### Connecting to the sandbox environment
38
+
39
+ You can connect your app to Kona's sandbox environment for testing purposes. First, get a KB account in their sandbox environment so that you can register your app. Then add the following hash to the middleware configuration:
40
+
41
+ ```ruby
42
+ Rails.application.config.middleware.use OmniAuth::Builder do
43
+ provider :kona, "ClientID", "ClientSecret",
44
+ {
45
+ :client_options => {
46
+ :site => 'https://sandbox.kona.com',
47
+ :authorize_url => 'https://sandbox.kona.com/oauth/authorize',
48
+ :token_url => 'https://sandbox.kona.com/oauth/token'
49
+ }
50
+ }
51
+ end
52
+ ```
53
+
54
+ ## Auto Hash schema
55
+
56
+ The Kona OmniAuth strategy returns the following information
57
+
58
+ ```
59
+ {
60
+ "provider":"kona",
61
+ "uid":integer,
62
+ "info":{
63
+ "email":string,
64
+ "name":string,
65
+ "image":string, url
66
+ },
67
+ "credentials":{
68
+ "token":string,
69
+ "refresh_token":string,
70
+ "expires_at":datetime,
71
+ "expires":true},
72
+ "extra":{
73
+ "raw_info":{
74
+ "id":integer,
75
+ "email":string,
76
+ "name":string,
77
+ "picture_thumb":string, url,
78
+ "updated_at":datetime, ,
79
+ "href":string, url,
80
+ "current_account":{
81
+ "id":integer,
82
+ "member":boolean}
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ ### Guest Members
89
+
90
+ We have provided the key `member` under the `extra` hash to identify if user is a member of the Kona Business account or not
91
+
92
+ ## Contributing
93
+
94
+ 1. Fork it ( https://github.com/ronaldsalas/omniauth-kona/fork )
95
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
96
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
97
+ 4. Push to the branch (`git push origin my-new-feature`)
98
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
data/example/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'omniauth-kona', :path => ".."
data/example/config.ru ADDED
@@ -0,0 +1,32 @@
1
+ # Sample app for Kona OAuth2 Strategy
2
+ # Make sure to setup the ENV variables CLIENT_ID and CLIENT_SECRET
3
+ # Run with "bundle exec rackup"
4
+ # On your browser, visit http://localhost:9292
5
+
6
+ require 'bundler/setup'
7
+ require 'sinatra/base'
8
+ require 'omniauth-kona'
9
+
10
+ class App < Sinatra::Base
11
+ get '/' do
12
+ "<a href='/auth/kona'>Log in with Kona</a>"
13
+ end
14
+
15
+ get '/auth/kona/callback' do
16
+ content_type 'application/json'
17
+ MultiJson.encode(request.env['omniauth.auth'])
18
+ end
19
+
20
+ get '/auth/failure' do
21
+ content_type 'application/json'
22
+ MultiJson.encode(request.env)
23
+ end
24
+ end
25
+
26
+ use Rack::Session::Cookie, :secret => 'iduf93ub9sdhfusdhf' # replace this with your own secret
27
+
28
+ use OmniAuth::Builder do
29
+ provider :kona, ENV['CLIENT_ID'], ENV['CLIENT_SECRET']
30
+ end
31
+
32
+ run App.new
@@ -0,0 +1,38 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Kona < OmniAuth::Strategies::OAuth2
6
+ option :name, "kona"
7
+ option :client_options, {
8
+ :site => 'https://io.kona.com',
9
+ :authorize_url => 'https://io.kona.com/oauth/authorize',
10
+ :token_url => 'https://io.kona.com/oauth/token'
11
+ }
12
+
13
+ def request_phase
14
+ super
15
+ end
16
+
17
+ uid { raw_info['id']}
18
+
19
+ info do
20
+ {
21
+ 'email' => raw_info['email'],
22
+ 'name' => raw_info['name'],
23
+ 'image' => raw_info['picture_thumb']
24
+ }
25
+ end
26
+
27
+ extra do
28
+ { 'raw_info' => raw_info }
29
+ end
30
+
31
+ def raw_info
32
+ @userinfo = access_token.get('/api/userinfo').parsed
33
+ @raw_info ||= @userinfo['users'][0]
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Kona
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-kona/version'
2
+ require 'omniauth/strategies/kona'
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-kona/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-kona"
8
+ spec.version = Omniauth::Kona::VERSION
9
+ spec.authors = ["Ronald Salas"]
10
+ spec.email = ["ronaldsalas@deltek.com"]
11
+
12
+ spec.summary = 'Kona OAuth2 strategy for Omniauth'
13
+ spec.homepage = 'https://github.com/ronaldsalas/omniauth-kona'
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
+
21
+ spec.add_runtime_dependency 'omniauth-oauth2'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.9"
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-kona
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ronald Salas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '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: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - ronaldsalas@deltek.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - History.md
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - example/Gemfile
85
+ - example/config.ru
86
+ - lib/omniauth-kona.rb
87
+ - lib/omniauth-kona/version.rb
88
+ - lib/omniauth/strategies/kona.rb
89
+ - omniauth-kona.gemspec
90
+ homepage: https://github.com/ronaldsalas/omniauth-kona
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
+ rubyforge_project:
110
+ rubygems_version: 2.4.6
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Kona OAuth2 strategy for Omniauth
114
+ test_files: []