omniauth-aid 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 +35 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +38 -0
- data/README.md +53 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/example/config.ru +11 -0
- data/lib/omniauth/aid/version.rb +5 -0
- data/lib/omniauth/aid.rb +2 -0
- data/lib/omniauth/strategies/aid.rb +26 -0
- data/lib/omniauth-aid.rb +1 -0
- data/omniauth-aid.gemspec +23 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 55868809ab0259b17ba70a6a94891272b23750a8
|
4
|
+
data.tar.gz: a64ddcd0286bca003198965948cf657f150606ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba48fb11312488195f5b6017131eadd65cea71cdf1e774f8c9b032f390c65229bfd9b5637094b99bd31ad0bf8c64bb35dec859cb311ec03e785e3c6e60e4d95d
|
7
|
+
data.tar.gz: b42b289d7b4b250d36326e44a26f041b0db10de06ab920b7470600d5ff07d054deab01d71e7071e10e9d75218656965a7c9b80c93cfe5236b573cc85d08b760a
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-aid (0.1.0)
|
5
|
+
omniauth-oauth2 (~> 1.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
faraday (0.9.1)
|
11
|
+
multipart-post (>= 1.2, < 3)
|
12
|
+
hashie (3.4.2)
|
13
|
+
jwt (1.5.1)
|
14
|
+
multi_json (1.11.2)
|
15
|
+
multi_xml (0.5.5)
|
16
|
+
multipart-post (2.0.0)
|
17
|
+
oauth2 (1.0.0)
|
18
|
+
faraday (>= 0.8, < 0.10)
|
19
|
+
jwt (~> 1.0)
|
20
|
+
multi_json (~> 1.3)
|
21
|
+
multi_xml (~> 0.5)
|
22
|
+
rack (~> 1.2)
|
23
|
+
omniauth (1.2.2)
|
24
|
+
hashie (>= 1.2, < 4)
|
25
|
+
rack (~> 1.0)
|
26
|
+
omniauth-oauth2 (1.3.1)
|
27
|
+
oauth2 (~> 1.0)
|
28
|
+
omniauth (~> 1.2)
|
29
|
+
rack (1.6.4)
|
30
|
+
rake (10.4.2)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
bundler (~> 1.9)
|
37
|
+
omniauth-aid!
|
38
|
+
rake (~> 10.0)
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Omniauth::Aid
|
2
|
+
|
3
|
+
This gem provides an OmniAuth strategy for using aID as an Oauth2-provider in your app.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-aid'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install omniauth-aid
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
`OmniAuth::Strategies::Aid` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.
|
24
|
+
|
25
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
29
|
+
provider :aid, ENV['AID_KEY'], ENV['AID_SECRET']
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
For using the strategy with a straight up rack app, look at the [example Sinatra app](https://github.com/amedia/omniauth-aid/blob/master/example/config.ru)
|
34
|
+
|
35
|
+
## Configuring
|
36
|
+
|
37
|
+
You can configure several options, which you pass in to the `provider` method via a `Option`:
|
38
|
+
|
39
|
+
Hash name | Default | Explanation
|
40
|
+
--- | --- | ---
|
41
|
+
`scope`, `name` | A space-separated list of permissions you want to request from the user. Optional scopes are: `email`, `phone`, `birth_date`, `tracking_key`, `access`, `external_accounts`, `customer`, `avatar`
|
42
|
+
|
43
|
+
For example, to request `name`, `birth_date` and `email` permissions and display the authentication page:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
47
|
+
provider :aid, ENV['AID_APP_KEY'], ENV['AID_APP_SECRET'],
|
48
|
+
:scope => 'name birth_date email'
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
## Test-driving the gem
|
53
|
+
A simple way to test if the aID-strategy is working is to install the [Omniauth-test-harness rails app](https://github.com/PracticallyGreen/omniauth-test-harness) and provide it with the scopes and app-configuration provided for using aID as an Omniauth-provider.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "omniauth/aid/plugin"
|
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
|
data/bin/setup
ADDED
data/example/config.ru
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'omniauth-aid'
|
3
|
+
require './app.rb'
|
4
|
+
|
5
|
+
use Rack::Session::Cookie, :secret => 'my-secret-string'
|
6
|
+
|
7
|
+
use OmniAuth::Builder do
|
8
|
+
provider :aid, ENV['AID_APP_ID'], ENV['AID_APP_SECRET'], :scope => 'name, email'
|
9
|
+
end
|
10
|
+
|
11
|
+
run Sinatra::Application
|
data/lib/omniauth/aid.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Aid < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, :aid
|
7
|
+
option :authorize_options, [:scope]
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
site: "https://www.aid.no",
|
11
|
+
authorize_url: "/api/portunus/v1/oauth/authorize",
|
12
|
+
token_url: "/api/portunus/v1/oauth/token"
|
13
|
+
}
|
14
|
+
|
15
|
+
uid { raw_info.fetch("data"){ {} }["id"] }
|
16
|
+
|
17
|
+
info do
|
18
|
+
raw_info.fetch("data"){ {} }.fetch("attributes"){ {} }.to_h
|
19
|
+
end
|
20
|
+
|
21
|
+
def raw_info
|
22
|
+
@raw_info ||= access_token.get('/api/mercury/v2/users/me').parsed || {}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/omniauth-aid.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/aid'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/aid/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-aid"
|
8
|
+
spec.version = Omniauth::Aid::VERSION
|
9
|
+
spec.authors = ["Jonas Helgemo"]
|
10
|
+
spec.email = ["jonas.helgemo@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Omniauth-strategy for using aID as an OAuth2-provider}
|
13
|
+
spec.homepage = "https://github.com/amedia/omniauth-aid"
|
14
|
+
spec.licenses = ['MIT']
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-aid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonas Helgemo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-12 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.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: omniauth-oauth2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.2'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- jonas.helgemo@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- example/config.ru
|
71
|
+
- lib/omniauth-aid.rb
|
72
|
+
- lib/omniauth/aid.rb
|
73
|
+
- lib/omniauth/aid/version.rb
|
74
|
+
- lib/omniauth/strategies/aid.rb
|
75
|
+
- omniauth-aid.gemspec
|
76
|
+
homepage: https://github.com/amedia/omniauth-aid
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.4.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Omniauth-strategy for using aID as an OAuth2-provider
|
100
|
+
test_files: []
|