omniauth-seaconlogistics 1.0.0
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 +22 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +2 -0
- data/lib/omniauth/seaconlogistics/version.rb +5 -0
- data/lib/omniauth/seaconlogistics.rb +2 -0
- data/lib/omniauth/strategies/seaconlogistics.rb +55 -0
- data/lib/omniauth-seaconlogistics.rb +1 -0
- data/omniauth-seaconlogistics.gemspec +25 -0
- data/spec/omniauth/strategies/seaconlogistics_spec.rb +34 -0
- data/spec/spec_helper.rb +14 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d956859d099d1eb939a48f7d582372180f2cba41
|
4
|
+
data.tar.gz: 5b46469adab5ad830ad91549887b4a4d63538cd6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fbe132cf812a650d90395e81ff2f2483dadfdb29b23e143adc69e92f98494689c8ebc1ca8ff1868c1752db17de9167ad6869c1f567a2846bfcaa61d68fd2e2c8
|
7
|
+
data.tar.gz: c5ec156b7b0c622a932eaae68721d06c410460f5dc609fc1f7428d430e7be76d7d5767a9d11cc1b280b50b5b3b6f125ae900205bba57a9728c517bbef6961c98
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ralph Rooding
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
[](https://travis-ci.org/kabisaict/omniauth-seaconlogistics)
|
2
|
+
|
3
|
+
# Omniauth::SeaconLogistics
|
4
|
+
|
5
|
+
OmniAuth OAuth2 authentication strategy for Seacon Logistics
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'omniauth-seaconlogistics'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install omniauth-seaconlogistics
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Put the provided key and secret in your config/secrets.yml
|
24
|
+
|
25
|
+
development:
|
26
|
+
omniauth_provider_key: <key here>
|
27
|
+
omniauth_provider_secret: <secret here>
|
28
|
+
|
29
|
+
For production use do the following (in config/initializers/omniauth.rb):
|
30
|
+
|
31
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
32
|
+
provider :seaconlogistics,
|
33
|
+
Rails.application.secrets.omniauth_provider_key,
|
34
|
+
Rails.application.secrets.omniauth_provider_secret
|
35
|
+
end
|
36
|
+
|
37
|
+
For staging or local use, you can override the authentication endpoint the following way:
|
38
|
+
|
39
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
40
|
+
provider :seaconlogistics,
|
41
|
+
Rails.application.secrets.omniauth_provider_key,
|
42
|
+
Rails.application.secrets.omniauth_provider_secret,
|
43
|
+
setup: lambda { |env|
|
44
|
+
env['omniauth.strategy'].options[:client_options].site = 'http://<url>/'
|
45
|
+
env['omniauth.strategy'].options[:client_options].authorize_url = 'http://<url>/authorize'
|
46
|
+
env['omniauth.strategy'].options[:client_options].token_url = 'http://<url>/accessToken'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it ( https://github.com/kabisaict/omniauth-seaconlogistics/fork )
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class SeaconLogistics < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, :seaconlogistics
|
7
|
+
|
8
|
+
option :client_options, {
|
9
|
+
site: 'https://cas.seaconlogistics.com',
|
10
|
+
authorize_url: 'https://cas.seaconlogistics.com/oauth2.0/authorize',
|
11
|
+
token_url: 'https://cas.seaconlogistics.com/oauth2.0/accessToken',
|
12
|
+
token_method: :get
|
13
|
+
}
|
14
|
+
|
15
|
+
option :token_params, {
|
16
|
+
parse: :query
|
17
|
+
}
|
18
|
+
|
19
|
+
uid { raw_info['id'] }
|
20
|
+
|
21
|
+
info do
|
22
|
+
{
|
23
|
+
name: full_name,
|
24
|
+
first_name: attributes['first_name'],
|
25
|
+
last_name: attributes['last_name'],
|
26
|
+
email: attributes['email'],
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
extra do
|
31
|
+
{
|
32
|
+
applications: attributes['applications']
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def raw_info
|
37
|
+
access_token.options[:mode] = :query
|
38
|
+
access_token.options[:param_name] = :access_token
|
39
|
+
@raw_info ||= access_token.get('oauth2.0/profile').parsed
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def full_name
|
45
|
+
[attributes['first_name'], attributes['last_name']].join(' ')
|
46
|
+
end
|
47
|
+
|
48
|
+
def attributes
|
49
|
+
raw_info['attributes'].reduce Hash.new, :merge
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
OmniAuth.config.add_camelization 'seaconlogistics', 'SeaconLogistics'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/seaconlogistics'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/seaconlogistics/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'omniauth-seaconlogistics'
|
8
|
+
spec.version = Omniauth::SeaconLogistics::VERSION
|
9
|
+
spec.authors = ['Ralph Rooding']
|
10
|
+
spec.email = ['ralph@ralphrooding.com']
|
11
|
+
spec.summary = %q{Seacon Logistics OAuth2 Strategy for OmniAuth}
|
12
|
+
spec.homepage = 'https://github.com/kabisaict/omniauth-seaconlogistics'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::SeaconLogistics do
|
4
|
+
subject { described_class.new({}) }
|
5
|
+
let(:access_token) { double('AccessToken', options: {}) }
|
6
|
+
let(:parsed_response) { double('ParsedResponse') }
|
7
|
+
let(:response) { double('Response', parsed: parsed_response) }
|
8
|
+
|
9
|
+
before do
|
10
|
+
allow(subject).to receive(:access_token).and_return(access_token)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'options' do
|
14
|
+
let(:options) { subject.options }
|
15
|
+
|
16
|
+
it { expect(options.name).to eq(:seaconlogistics) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'client options' do
|
20
|
+
let(:options) { subject.options.client_options }
|
21
|
+
|
22
|
+
it { expect(options.site).to eq('https://cas.seaconlogistics.com') }
|
23
|
+
it { expect(options.authorize_url).to eq('https://cas.seaconlogistics.com/oauth2.0/authorize') }
|
24
|
+
it { expect(options.token_url).to eq('https://cas.seaconlogistics.com/oauth2.0/accessToken') }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#raw_info' do
|
28
|
+
it 'makes a call to /oauth2.0/profile' do
|
29
|
+
expect(access_token).to receive(:get).with('oauth2.0/profile').and_return(response)
|
30
|
+
|
31
|
+
expect(subject.raw_info).to eq(parsed_response)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'omniauth-seaconlogistics'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.extend OmniAuth::Test::StrategyMacros, type: :strategy
|
8
|
+
|
9
|
+
# Run specs in random order to surface order dependencies. If you find an
|
10
|
+
# order dependency and want to debug it, you can fix the order by providing
|
11
|
+
# the seed, which is printed after each run.
|
12
|
+
# --seed 1234
|
13
|
+
config.order = 'random'
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-seaconlogistics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ralph Rooding
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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: 3.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: omniauth-oauth2
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.2'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- ralph@ralphrooding.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/omniauth-seaconlogistics.rb
|
83
|
+
- lib/omniauth/seaconlogistics.rb
|
84
|
+
- lib/omniauth/seaconlogistics/version.rb
|
85
|
+
- lib/omniauth/strategies/seaconlogistics.rb
|
86
|
+
- omniauth-seaconlogistics.gemspec
|
87
|
+
- spec/omniauth/strategies/seaconlogistics_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: https://github.com/kabisaict/omniauth-seaconlogistics
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.0
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Seacon Logistics OAuth2 Strategy for OmniAuth
|
113
|
+
test_files:
|
114
|
+
- spec/omniauth/strategies/seaconlogistics_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
has_rdoc:
|