omniauth-klarna 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ .powenv
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :example do
6
+ gem 'sinatra'
7
+ end
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-klarna (0.3.2.3)
5
+ omniauth (~> 1.0)
6
+ omniauth-oauth2
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ addressable (2.2.7)
12
+ diff-lcs (1.1.3)
13
+ faraday (0.7.6)
14
+ addressable (~> 2.2)
15
+ multipart-post (~> 1.1)
16
+ rack (~> 1.1)
17
+ hashie (1.2.0)
18
+ multi_json (1.2.0)
19
+ multipart-post (1.1.5)
20
+ oauth2 (0.5.2)
21
+ faraday (~> 0.7)
22
+ multi_json (~> 1.0)
23
+ omniauth (1.0.3)
24
+ hashie (~> 1.2)
25
+ rack
26
+ omniauth-oauth2 (1.0.0)
27
+ oauth2 (~> 0.5.0)
28
+ omniauth (~> 1.0)
29
+ rack (1.4.1)
30
+ rack-protection (1.2.0)
31
+ rack
32
+ rake (0.9.2.2)
33
+ rspec (2.6.0)
34
+ rspec-core (~> 2.6.0)
35
+ rspec-expectations (~> 2.6.0)
36
+ rspec-mocks (~> 2.6.0)
37
+ rspec-core (2.6.4)
38
+ rspec-expectations (2.6.0)
39
+ diff-lcs (~> 1.1.2)
40
+ rspec-mocks (2.6.0)
41
+ sinatra (1.3.2)
42
+ rack (~> 1.3, >= 1.3.6)
43
+ rack-protection (~> 1.2)
44
+ tilt (~> 1.3, >= 1.3.3)
45
+ tilt (1.3.3)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ omniauth-klarna!
52
+ rake
53
+ rspec (~> 2.6.0)
54
+ sinatra
@@ -0,0 +1,21 @@
1
+ # OmniAuth Klarna
2
+
3
+ This is the official OmniAuth strategy to authenticate with Klarna via OAuth2.
4
+
5
+ In order to use this strategy you will need to register for an API key and secret. You can do this over at http://some.link.com.
6
+
7
+ ## Basic Usage
8
+
9
+ use OmniAuth::Builder do
10
+ provider :klarna, ENV['KLARNA_KEY'], ENV['KLARNA_SECRET']
11
+ end
12
+
13
+ ## License
14
+
15
+ Copyright (c) 2012 Klarna AB.
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,39 @@
1
+ # Sample app for Klarna's OAuth2 Strategy
2
+ # Make sure to setup the ENV variables KLARNA_KEY and KLARNA_SECRET
3
+ # Run with "bundle exec rackup"
4
+
5
+ require 'rubygems'
6
+ require 'bundler'
7
+ require 'sinatra'
8
+ require 'omniauth-klarna'
9
+
10
+ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
11
+
12
+ class App < Sinatra::Base
13
+ get '/' do
14
+ <<-HTML
15
+ <ul>
16
+ <li><a href='/auth/klarna'>Sign in with Klarna</a></li>
17
+ </ul>
18
+ HTML
19
+ end
20
+
21
+ get '/auth/:provider/callback' do
22
+ content_type 'text/plain'
23
+ request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
24
+ end
25
+
26
+ get '/auth/failure' do
27
+ content_type 'text/plain'
28
+ request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
29
+ end
30
+ end
31
+
32
+ use Rack::Session::Cookie, :secret => ENV['RACK_COOKIE_SECRET']
33
+
34
+ use OmniAuth::Builder do
35
+ # Regular usage
36
+ provider :klarna, ENV['KLARNA_KEY'], ENV['KLARNA_SECRET'], {}
37
+ end
38
+
39
+ run App.new
@@ -0,0 +1,3 @@
1
+ Rails.application.config.middleware.use OmniAuth::Builder do
2
+ provider :klarna, ENV['KLARNA_KEY'], ENV['KLARNA_SECRET']
3
+ end
@@ -0,0 +1 @@
1
+ require "omniauth/klarna"
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/klarna'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Klarna
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ require 'hashie/mash'
2
+ require 'omniauth/strategies/oauth2'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Klarna < OmniAuth::Strategies::OAuth2
7
+ PROVIDER_URL = 'https://merchants.klarna.com'
8
+ CLIENT_OPTIONS = { site: PROVIDER_URL, authorize_url: '/oauth/authorize', token_url: '/oauth/access_token' }
9
+
10
+ option :name, 'klarna'
11
+
12
+ option :client_options, CLIENT_OPTIONS
13
+
14
+ uid do
15
+ raw_info['user']['id'] || raw_info['user']['email']
16
+ end
17
+
18
+ info do
19
+ {
20
+ name: raw_info['user']['id'],
21
+ email: raw_info['user']['id']
22
+ }
23
+ end
24
+
25
+ extra do
26
+ { 'raw_info' => raw_info }
27
+ end
28
+
29
+ def raw_info
30
+ @raw_info ||= access_token.get('/oauth/token').parsed
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth/klarna/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_dependency 'omniauth', '~> 1.0'
6
+
7
+ gem.authors = ["Guy Rozen"]
8
+ gem.email = ["guy.rozen@klarna.com"]
9
+ gem.description = %q{An OmniAuth 1.0 oauth2 strategy for Klarna}
10
+ gem.summary = %q{This gem will simplify authenticating with Klarna using OAuth 2.0}
11
+ gem.homepage = ""
12
+
13
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ gem.name = "omniauth-klarna"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = OmniAuth::Klarna::VERSION
19
+
20
+ gem.add_runtime_dependency 'omniauth-oauth2'
21
+
22
+ gem.add_development_dependency 'rspec', '~> 2.6.0'
23
+ gem.add_development_dependency 'rake'
24
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-klarna'
3
+
4
+ describe OmniAuth::Strategies::Klarna do
5
+ subject do
6
+ OmniAuth::Strategies::Klarna.new(nil, @options || {})
7
+ end
8
+
9
+ it_should_behave_like 'an oauth2 strategy'
10
+
11
+ describe '#client' do
12
+ it 'has correct site' do
13
+ subject.client.site.should eq('https://omg.I.dont.know')
14
+ end
15
+ end
16
+
17
+ describe '#callback_path' do
18
+ it "has the correct callback path" do
19
+ subject.callback_path.should eq('/auth/klarna/callback')
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ require 'bundler/setup'
2
+ require 'rspec'
3
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
4
+
5
+ RSpec.configure do |config|
6
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-klarna
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Guy Rozen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &70287997993260 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70287997993260
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &70287997988060 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70287997988060
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70287997986680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.6.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70287997986680
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &70287997985800 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70287997985800
58
+ description: An OmniAuth 1.0 oauth2 strategy for Klarna
59
+ email:
60
+ - guy.rozen@klarna.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - README.md
69
+ - Rakefile
70
+ - examples/config.ru
71
+ - examples/omni_auth.rb
72
+ - lib/omniauth-klarna.rb
73
+ - lib/omniauth/klarna.rb
74
+ - lib/omniauth/klarna/version.rb
75
+ - lib/omniauth/strategies/klarna.rb
76
+ - omniauth-contrib.gemspec
77
+ - spec/omniauth/strategies/klarna_spec.rb
78
+ - spec/spec_helper.rb
79
+ homepage: ''
80
+ licenses: []
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.10
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: This gem will simplify authenticating with Klarna using OAuth 2.0
103
+ test_files:
104
+ - spec/omniauth/strategies/klarna_spec.rb
105
+ - spec/spec_helper.rb