omniauth-visma 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +13 -0
- data/Guardfile +11 -0
- data/LICENSE +19 -0
- data/README.md +23 -0
- data/Rakefile +8 -0
- data/lib/omniauth-visma.rb +2 -0
- data/lib/omniauth-visma/version.rb +6 -0
- data/lib/omniauth/strategies/visma.rb +67 -0
- data/omniauth-visma.gemspec +25 -0
- data/spec/omniauth/strategies/visma_spec.rb +32 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/shared_examples.rb +40 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b69c471c4830c834a707552dfce31ab4fb116f7bd4e9287ce7d73ac17c8773fe
|
4
|
+
data.tar.gz: 5f3d357e8fcef707e5929b00f639abbf3afdaf7cac5281bbe021c36e51f5664a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb03b412910b81e49d9a2a5872fdae3cae547126fc6a42bbbafc0c57d759a94c806086e42916773daebe7407f6abfbe0dc22a765685f8d31aa6ffd20f1d6071d
|
7
|
+
data.tar.gz: c24e165eeef01c517c169e9795ad8eadf46ac9d127dc0047b54e72185ca27faa9ee1125fc03c4cba85a77770756c185002115c72a8b21310c346f7a1c90343d3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
guard 'rspec', :version => 2 do
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
3
|
+
watch(%r{^spec/support/.+\.rb$})
|
4
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
5
|
+
watch('spec/spec_helper.rb') { "spec" }
|
6
|
+
end
|
7
|
+
|
8
|
+
guard 'bundler' do
|
9
|
+
watch('Gemfile')
|
10
|
+
watch('omniauth-visma.gemspec')
|
11
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2017 Espen Antonsen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# OmniAuth Visma
|
2
|
+
|
3
|
+
This gem contains the unofficial Visma eAccounting strategy for OmniAuth.
|
4
|
+
|
5
|
+
See the [authorization documentation](https://developer.vismaonline.com/#eAccountingApiAuthorization) for Visma eAccounting.
|
6
|
+
|
7
|
+
For more information about the API see https://developer.vismaonline.com/.
|
8
|
+
|
9
|
+
## Basic Usage
|
10
|
+
|
11
|
+
use OmniAuth::Builder do
|
12
|
+
provider "visma", ENV['VISMA_CLIENT_ID'], ENV['VISMA_CLIENT_SECRET'], scope: 'offline_access ea:api', environment: 'production'
|
13
|
+
end
|
14
|
+
|
15
|
+
The default environment is 'sandbox'.
|
16
|
+
|
17
|
+
## Credits
|
18
|
+
|
19
|
+
Based on [omniauth-37signals](https://github.com/tallgreentree/omniauth-37signals) by [Will Barrett](https://github.com/willbarrett).
|
20
|
+
|
21
|
+
## License
|
22
|
+
|
23
|
+
Copyright (c) 2017 by Espen Antonsen. [MIT License](LICENSE)
|
data/Rakefile
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Visma < OmniAuth::Strategies::OAuth2
|
7
|
+
AUTH_URLS = {
|
8
|
+
:sandbox => {
|
9
|
+
:site => "https://eaccountingapi-sandbox.test.vismaonline.com/v2/",
|
10
|
+
:authorize_url => "https://identity-sandbox.test.vismaonline.com/connect/authorize",
|
11
|
+
:token_url => "https://identity-sandbox.test.vismaonline.com/connect/token"
|
12
|
+
},
|
13
|
+
:production => {
|
14
|
+
:site => "https://eaccountingapi.vismaonline.com/v2/",
|
15
|
+
:authorize_url => "https://identity.vismaonline.com/connect/authorize",
|
16
|
+
:token_url => "https://identity.vismaonline.com/connect/token"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
option :name, "visma"
|
21
|
+
option :environment, "sandbox"
|
22
|
+
option :client_options, AUTH_URLS[:sandbox]
|
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
|
+
credentials do
|
38
|
+
hash = {'token' => access_token.token}
|
39
|
+
hash.merge!('refresh_token' => access_token.refresh_token) if access_token.refresh_token
|
40
|
+
hash.merge!('expires_at' => access_token.expires_at ) if access_token.expires?
|
41
|
+
hash.merge!('expires' => access_token.expires?)
|
42
|
+
hash
|
43
|
+
end
|
44
|
+
|
45
|
+
def raw_info
|
46
|
+
@raw_info ||= access_token.get('/v2/companysettings').parsed
|
47
|
+
end
|
48
|
+
|
49
|
+
def request_phase
|
50
|
+
set_urls
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def set_urls
|
57
|
+
options.client_options = AUTH_URLS[options.environment].merge(options.client_options)
|
58
|
+
end
|
59
|
+
|
60
|
+
def callback_url
|
61
|
+
full_host + script_name + callback_path
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-visma/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Espen Antonsen"]
|
6
|
+
gem.email = ["espen@inspired.no"]
|
7
|
+
gem.description = %q{OmniAuth strategy for Visma eAccounting.}
|
8
|
+
gem.summary = %q{OmniAuth strategy for Visma eAccounting.}
|
9
|
+
gem.homepage = "https://github.com/espen/omniauth-visma"
|
10
|
+
gem.license = 'MIT'
|
11
|
+
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.name = "omniauth-visma"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = OmniAuth::Visma::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
20
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.0'
|
21
|
+
gem.add_development_dependency 'rspec'
|
22
|
+
gem.add_development_dependency 'rack-test'
|
23
|
+
gem.add_development_dependency 'webmock'
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-visma'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::Visma do
|
5
|
+
subject do
|
6
|
+
strategy = OmniAuth::Strategies::Visma.new(nil, @options || {})
|
7
|
+
strategy.stub(:session) { {} }
|
8
|
+
strategy
|
9
|
+
end
|
10
|
+
|
11
|
+
it_should_behave_like 'an oauth2 strategy'
|
12
|
+
|
13
|
+
describe '#client' do
|
14
|
+
it 'should have the correct Visma site' do
|
15
|
+
subject.client.site.should eq("https://eaccountingapi-sandbox.test.vismaonline.com/v2/")
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have the correct authorization url' do
|
19
|
+
subject.client.options[:authorize_url].should eq("https://identity-sandbox.test.vismaonline.com/connect/authorize")
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have the correct token url' do
|
23
|
+
subject.client.options[:token_url].should eq('https://identity-sandbox.test.vismaonline.com/connect/token')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#callback_path' do
|
28
|
+
it 'should have the correct callback path' do
|
29
|
+
subject.callback_path.should eq('/auth/visma/callback')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'rack/test'
|
6
|
+
require 'omniauth'
|
7
|
+
require 'omniauth-visma'
|
8
|
+
|
9
|
+
Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include Rack::Test::Methods
|
13
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# NOTE it would be useful if this lived in omniauth-oauth2 eventually
|
2
|
+
# Thanks to Josh Ellithorpe for this file -Will
|
3
|
+
|
4
|
+
shared_examples 'an oauth2 strategy' do
|
5
|
+
describe '#client' do
|
6
|
+
it 'should be initialized with symbolized client_options' do
|
7
|
+
@options = { :client_options => { 'authorize_url' => 'https://example.com' } }
|
8
|
+
subject.client.options[:authorize_url].should == 'https://example.com'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#authorize_params' do
|
13
|
+
it 'should include any authorize params passed in the :authorize_params option' do
|
14
|
+
@options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
|
15
|
+
subject.authorize_params['foo'].should eq('bar')
|
16
|
+
subject.authorize_params['baz'].should eq('zip')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should include top-level options that are marked as :authorize_options' do
|
20
|
+
@options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
21
|
+
subject.authorize_params['scope'].should eq('bar')
|
22
|
+
subject.authorize_params['foo'].should eq('baz')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#token_params' do
|
27
|
+
it 'should include any token params passed in the :token_params option' do
|
28
|
+
@options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
|
29
|
+
subject.token_params['foo'].should eq('bar')
|
30
|
+
subject.token_params['baz'].should eq('zip')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should include top-level options that are marked as :token_options' do
|
34
|
+
@options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
35
|
+
subject.token_params['scope'].should eq('bar')
|
36
|
+
subject.token_params['foo'].should eq('baz')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-visma
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Espen Antonsen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
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: rack-test
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: OmniAuth strategy for Visma eAccounting.
|
98
|
+
email:
|
99
|
+
- espen@inspired.no
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- Guardfile
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/omniauth-visma.rb
|
111
|
+
- lib/omniauth-visma/version.rb
|
112
|
+
- lib/omniauth/strategies/visma.rb
|
113
|
+
- omniauth-visma.gemspec
|
114
|
+
- spec/omniauth/strategies/visma_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- spec/support/shared_examples.rb
|
117
|
+
homepage: https://github.com/espen/omniauth-visma
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.7.3
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: OmniAuth strategy for Visma eAccounting.
|
141
|
+
test_files:
|
142
|
+
- spec/omniauth/strategies/visma_spec.rb
|
143
|
+
- spec/spec_helper.rb
|
144
|
+
- spec/support/shared_examples.rb
|