registrar 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/registrar/adapter/omni_auth.rb +66 -0
- data/lib/registrar/adapter.rb +6 -0
- data/lib/registrar/debug.rb +38 -0
- data/lib/registrar/profile_builder.rb +22 -0
- data/lib/registrar/profile_gateway_stub.rb +27 -0
- data/lib/registrar/version.rb +3 -0
- data/lib/registrar.rb +8 -0
- data/registrar.gemspec +23 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1aaaffc536d54dfded534286d5d7f0520f2e293f
|
4
|
+
data.tar.gz: 8018ff192a4cceccc8d5340a3f8d3c1ff296f34e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bcd8c5426ae1b9181a26e9895e638111d3ad4c89b4edf8087b8b640620615ed752f24f90cd6ac57e9529082502fcabff9e808773a76c169e3bd69a0c25ec751
|
7
|
+
data.tar.gz: ab2cb5cecbb5f1c1736ab80cfce3cddceed39bb1411fb479b302760cd1c4dbdaa5650467fc2e30161d473514cbbe502241e7c101f6bade5859c668aef5b45b06
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Jan Owiesniak
|
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,31 @@
|
|
1
|
+
# Registrar
|
2
|
+
|
3
|
+
Registrar standardizes Authentication Responses through Rack Middleware and works well with common authentication mechanisms like OmniAuth.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'registrar'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install registrar
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/registrar/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module Registrar
|
2
|
+
module Adapter
|
3
|
+
class OmniAuth
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
try_to_normalize_auth(env)
|
10
|
+
@app.call(env)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def try_to_normalize_auth(env)
|
16
|
+
if env["omniauth.auth"]
|
17
|
+
env['registrar.auth'] = AuthNormalizer.normalized(env)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class AuthNormalizer
|
22
|
+
def self.normalized(env)
|
23
|
+
normalizer = new(env)
|
24
|
+
normalizer.send(:normalize)
|
25
|
+
normalizer.send(:normalized)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :auth, :normalized
|
31
|
+
|
32
|
+
def initialize(env)
|
33
|
+
@auth = env["omniauth.auth"]
|
34
|
+
@normalized = {}
|
35
|
+
end
|
36
|
+
|
37
|
+
def normalize
|
38
|
+
normalize_provider
|
39
|
+
normalize_profile
|
40
|
+
end
|
41
|
+
|
42
|
+
def normalize_provider
|
43
|
+
provider_name = auth["provider"]
|
44
|
+
provider_uid = auth["uid"]
|
45
|
+
|
46
|
+
normalized.merge!(
|
47
|
+
'provider' => {
|
48
|
+
'name' => provider_name,
|
49
|
+
'uid' => provider_uid
|
50
|
+
}
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def normalize_profile
|
55
|
+
normalized.merge!(
|
56
|
+
'profile' => {}
|
57
|
+
)
|
58
|
+
|
59
|
+
auth["info"].to_hash.each_pair do |k, v|
|
60
|
+
normalized['profile'][k] = v
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Registrar
|
2
|
+
class Debug
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
add_debug_info(env)
|
9
|
+
@app.call(env)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def add_debug_info(env)
|
15
|
+
debug = {
|
16
|
+
'registrar.auth' => env['registrar.auth'],
|
17
|
+
'registrar.profile' => env['registrar.profile']
|
18
|
+
}
|
19
|
+
|
20
|
+
env['registrar.debug'] = to_html(debug)
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_html(debug)
|
24
|
+
"
|
25
|
+
<!DOCTYPE html>
|
26
|
+
<html>
|
27
|
+
<head>
|
28
|
+
<title>My App</title>
|
29
|
+
</head>
|
30
|
+
|
31
|
+
<body>
|
32
|
+
<pre style='white-space:pre-wrap;'>#{debug}</pre>
|
33
|
+
</body>
|
34
|
+
</html>
|
35
|
+
".gsub(/\s{2,}/,' ')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Registrar
|
2
|
+
class ProfileBuilder
|
3
|
+
def initialize(app, callable)
|
4
|
+
@app = app
|
5
|
+
@callable = callable
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
try_to_call(env)
|
10
|
+
@app.call(env)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def try_to_call(env)
|
16
|
+
if auth_hash = env['registrar.auth']
|
17
|
+
profile = @callable.call(auth_hash)
|
18
|
+
env['registrar.profile'] = profile.to_hash
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Registrar
|
2
|
+
class ProfileGatewayStub
|
3
|
+
def call(auth_hash)
|
4
|
+
Profile.new(auth_hash)
|
5
|
+
end
|
6
|
+
|
7
|
+
class Profile
|
8
|
+
def initialize(auth_hash)
|
9
|
+
provider_name = auth_hash['provider']['name']
|
10
|
+
uid = auth_hash['provider']['uid']
|
11
|
+
|
12
|
+
@internal_uid = 1
|
13
|
+
@external_uid = "#{provider_name}_#{uid}"
|
14
|
+
@name = auth_hash['profile']['name']
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
{
|
19
|
+
:internal_uid => @internal_uid,
|
20
|
+
:external_uid => @external_uid,
|
21
|
+
:access_token => 'verified',
|
22
|
+
:name => @name
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/registrar.rb
ADDED
data/registrar.gemspec
ADDED
@@ -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 'registrar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "registrar"
|
8
|
+
spec.version = Registrar::VERSION
|
9
|
+
spec.authors = ["Jan Owiesniak"]
|
10
|
+
spec.email = ["jan@featurefabrik.de"]
|
11
|
+
spec.summary = %q{Registrar: Standardized Multi-Provider Registration}
|
12
|
+
spec.description = %q{Registrar standardizes Authentication Responses through Rack Middleware and works well with common authentication mechanisms like OmniAuth.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: registrar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Owiesniak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-09 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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
|
+
description: Registrar standardizes Authentication Responses through Rack Middleware
|
42
|
+
and works well with common authentication mechanisms like OmniAuth.
|
43
|
+
email:
|
44
|
+
- jan@featurefabrik.de
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/registrar.rb
|
55
|
+
- lib/registrar/adapter.rb
|
56
|
+
- lib/registrar/adapter/omni_auth.rb
|
57
|
+
- lib/registrar/debug.rb
|
58
|
+
- lib/registrar/profile_builder.rb
|
59
|
+
- lib/registrar/profile_gateway_stub.rb
|
60
|
+
- lib/registrar/version.rb
|
61
|
+
- registrar.gemspec
|
62
|
+
homepage: ''
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.3.1
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.2.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: 'Registrar: Standardized Multi-Provider Registration'
|
86
|
+
test_files: []
|