omniauth-nettoken 0.1.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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/lib/omniauth-nettoken.rb +32 -0
- data/lib/omniauth-nettoken/version.rb +5 -0
- data/omniauth-nettoken.gemspec +20 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f7edde97069a11629eb3e96909d7c37457fe6212
|
4
|
+
data.tar.gz: eeb2194ff59c1449faf23018b71083b4fc58ea64
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ade7c81fbfae346a9e78044f10f20acdbd5d36d9550518085cf9fffd954f32359299ba1604b4ba38d65714aecb90ca9b8c41d1d91d5e42b1849bb1cdb97af3a9
|
7
|
+
data.tar.gz: 6e6f46b6f9ddc7bada8d404da2528a852562073ad953628c08976629f19302a7077af213f9cf1e620cc1837864ad8996aadc11a55f2bb633d1036c1372576ac8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Claudio Poli
|
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,66 @@
|
|
1
|
+
# Nettoken OmniAuth Strategy
|
2
|
+
|
3
|
+
This gem provides a simple way to authenticate to Nettoken Web API using OmniAuth with OAuth2.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'omniauth-nettoken'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install omniauth-nettoken
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You'll need to register an app on Nettoken, you can do this here - https://www.nettoken.co.uk/developers/apps
|
22
|
+
|
23
|
+
Usage of the gem is very similar to other OmniAuth strategies.
|
24
|
+
You'll need to add your app credentials to `config/initializers/omniauth.rb`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
28
|
+
provider :nettoken, 'app_id', 'app_secret'
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
Or with Devise in `config/initializers/devise.rb`:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
config.omniauth :nettoken, 'app_id', 'app_secret'
|
36
|
+
```
|
37
|
+
|
38
|
+
## Auth Hash
|
39
|
+
|
40
|
+
Sample *Auth Hash* from `request.env['omniauth.auth']`:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
{
|
44
|
+
"provider" => "nettoken",
|
45
|
+
"uid" => 2,
|
46
|
+
"info"=> {
|
47
|
+
"email "=> "jwbradley87@gmail.com"
|
48
|
+
},
|
49
|
+
"credentials"=> {
|
50
|
+
"token" => "fa703d7c5a205db6ef273bd8985bb29608c1123d956c7c273a2f3bbb37eb4bd6",
|
51
|
+
"expires_at" => 1468263959,
|
52
|
+
"expires"=>true
|
53
|
+
},
|
54
|
+
"extra"=> {}
|
55
|
+
}
|
56
|
+
```
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
Copyright (c) 2016 Nettoken Limited
|
61
|
+
|
62
|
+
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:
|
63
|
+
|
64
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
65
|
+
|
66
|
+
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.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Nettoken < OmniAuth::Strategies::OAuth2
|
6
|
+
# change the class name and the :name option to match your application name
|
7
|
+
option :name, 'nettoken'
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
:site => "http://www.nettoken-dev.com",
|
11
|
+
:authorize_url => "/oauth/authorize"
|
12
|
+
}
|
13
|
+
|
14
|
+
uid { raw_info["id"] }
|
15
|
+
|
16
|
+
info do
|
17
|
+
{
|
18
|
+
:email => raw_info["email"]
|
19
|
+
# and anything else you want to return to your API consumers
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def callback_url
|
24
|
+
full_host + script_name + callback_path
|
25
|
+
end
|
26
|
+
|
27
|
+
def raw_info
|
28
|
+
@raw_info ||= access_token.get('/api/me.json').parsed
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-nettoken/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "omniauth-nettoken"
|
8
|
+
gem.version = Omniauth::Nettoken::VERSION
|
9
|
+
gem.authors = ["James Bradley"]
|
10
|
+
gem.email = ["root@jbrew.co.uk"]
|
11
|
+
gem.description = %q{OmniAuth strategy for Nettoken}
|
12
|
+
gem.summary = %q{OmniAuth strategy for Nettoken}
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.1'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-nettoken
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Bradley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-11 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: '1.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.1'
|
27
|
+
description: OmniAuth strategy for Nettoken
|
28
|
+
email:
|
29
|
+
- root@jbrew.co.uk
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE.txt
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/omniauth-nettoken.rb
|
40
|
+
- lib/omniauth-nettoken/version.rb
|
41
|
+
- omniauth-nettoken.gemspec
|
42
|
+
homepage:
|
43
|
+
licenses: []
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.5.1
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: OmniAuth strategy for Nettoken
|
65
|
+
test_files: []
|