omniauth-linnworks 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: 730618c18a2406af3f6d46a61677a757a38ddb15
4
+ data.tar.gz: adc4d8befe716dceb1ee1bd52d6c9cc1d46a202c
5
+ SHA512:
6
+ metadata.gz: e0440ed3f84c290c729516937fab322f04198b75743a7ea205ebb79d26cdffe728cf61952616be1e9b82404c8af4f0bc11c582ca1f4cb44fc66b7968dd34f650
7
+ data.tar.gz: 06688addf507602913561791017537f0129a4c29ecc3e6f09c5049b1c836924e1e14dcf05bc579bffca563c414472b15d5320635e87d8e95724ec2ee1be0991d
@@ -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 @@
1
+ omniauth-skubana
@@ -0,0 +1 @@
1
+ ruby-2.2.3
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-linnworks.gemspec
4
+ gemspec
@@ -0,0 +1,36 @@
1
+ # Omniauth::Linnworks
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/linnworks`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-linnworks'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-linnworks
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-linnworks.
36
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth-linnworks"
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,2 @@
1
+ require 'omniauth-linnworks/version'
2
+ require 'omniauth/strategies/linnworks'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Linnworks
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,67 @@
1
+ require 'omniauth'
2
+ require 'faraday'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Linnworks
7
+ include OmniAuth::Strategy
8
+
9
+ args [:application_id, :application_secret]
10
+ option :name, 'linnworks'
11
+ option :application_id, nil
12
+ option :application_secret, nil
13
+
14
+ option :client_options, {
15
+ :tracking => nil,
16
+ :authorize_url => '/Authorization/Authorize',
17
+ :site => 'http://apps.linnworks.net'
18
+ }
19
+
20
+ def request_phase # rubocop:disable MethodLength
21
+ authorize_url = "#{options.client_options.site}#{options.client_options.authorize_url}/#{options.application_id}"
22
+ authorize_url += "?tracking=#{options.client_options.tracking}" if options.client_options.tracking
23
+
24
+ redirect authorize_url
25
+ rescue ::Timeout::Error => e
26
+ fail!(:timeout, e)
27
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
28
+ fail!(:service_unavailable, e)
29
+ end
30
+
31
+ def callback_phase # rubocop:disable MethodLength
32
+ fail(OmniAuth::NoSessionError, "Session Expired") if session["oauth"].nil?
33
+
34
+ params = @env['omniauth.params']
35
+
36
+ @response = Faraday.post('https://api.linnworks.net//api/Auth/AuthorizeByApplication', {"applicationId" => options.application_id,
37
+ "applicationSecret" => options.application_secret,
38
+ "token" => params['token']})
39
+
40
+ fail!(:error, Exception.new(JSON.parse(@response.body))) unless @response.success?
41
+ rescue ::Timeout::Error => e
42
+ fail!(:timeout, e)
43
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
44
+ fail!(:service_unavailable, e)
45
+ rescue ::OAuth::Unauthorized => e
46
+ fail!(:invalid_credentials, e)
47
+ rescue ::OmniAuth::NoSessionError => e
48
+ fail!(:session_expired, e)
49
+ end
50
+
51
+ def raw_info
52
+ @raw_info ||= JSON.parse(response.body)
53
+ end
54
+
55
+ uid { raw_info['Id'].to_s }
56
+
57
+ credentials do
58
+ {"token" => raw_info['Token'] }
59
+ end
60
+
61
+ private
62
+
63
+ attr_reader :response
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-linnworks/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-linnworks"
8
+ spec.version = Omniauth::Linnworks::VERSION
9
+ spec.authors = ["Karl Falconer"]
10
+ spec.email = ["karl.falconer@falconerdevelopment.com"]
11
+
12
+ spec.summary = %q{OmniAuth strategy for Skubana}
13
+ spec.description = %q{In this gem you will find an OmniAuth Skubana strategy.}
14
+ spec.homepage = "https://github.com/dropstream/omniauth-linnworks"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_runtime_dependency 'omniauth', '>= 1.2.1'
30
+ spec.add_runtime_dependency 'faraday', '>= 0.8.11'
31
+ spec.add_runtime_dependency 'multi_json', '>= 1.0.2', '~> 1.0'
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.10"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec"
36
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-linnworks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Karl Falconer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-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.2.1
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.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.11
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.11
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.2
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '1.0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 1.0.2
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.10'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.10'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '10.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '10.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ description: In this gem you will find an OmniAuth Skubana strategy.
104
+ email:
105
+ - karl.falconer@falconerdevelopment.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - ".ruby-gemset"
113
+ - ".ruby-version"
114
+ - ".travis.yml"
115
+ - Gemfile
116
+ - README.md
117
+ - Rakefile
118
+ - bin/console
119
+ - bin/setup
120
+ - lib/omniauth-linnworks.rb
121
+ - lib/omniauth-linnworks/version.rb
122
+ - lib/omniauth/strategies/linnworks.rb
123
+ - omniauth-linnworks.gemspec
124
+ homepage: https://github.com/dropstream/omniauth-linnworks
125
+ licenses: []
126
+ metadata:
127
+ allowed_push_host: https://rubygems.org
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.4.5.1
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: OmniAuth strategy for Skubana
148
+ test_files: []