omniauth-miil 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/Gemfile +12 -0
- data/Guardfile +10 -0
- data/README.md +43 -0
- data/Rakefile +8 -0
- data/circle.yml +6 -0
- data/lib/omniauth-miil.rb +2 -0
- data/lib/omniauth-miil/version.rb +5 -0
- data/lib/omniauth/strategies/miil.rb +52 -0
- data/omniauth-miil.gemspec +29 -0
- data/spec/omniauth/strategies/miil_spec.rb +41 -0
- data/spec/spec_helper.rb +12 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 943c51f6248b5677d192117fcab6eb27f6f1e361
|
4
|
+
data.tar.gz: 60f843653c68abd7efa276a58c7965d56c4de8be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63c0260f5ba66dd1c0f96180c45652fd8a26f4f1c219afba330b4d679951daedf56c4c8cb801af9611d42aac1217effa60b8638740cf356a5c3b8a4291bff012
|
7
|
+
data.tar.gz: 9fa891d94ce41321cdabd19401fb834b44017032e2fc2f6a6108613149e98b190532df5a139dd2a40f48019a002328f4f598a73314d32f525ba1c550ba45a995
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# OmniAuth Miil
|
2
|
+
|
3
|
+
This is the OmniAuth strategy for authenticating to Miil.
|
4
|
+
However Miil does not provide Open OAuth Service and API :(
|
5
|
+
|
6
|
+
It was created for internal service.
|
7
|
+
|
8
|
+
[![Circle CI](https://circleci.com/gh/xendoc/omniauth-miil.svg?style=svg)](https://circleci.com/gh/xendoc/omniauth-miil)
|
9
|
+
[![Code Climate](https://codeclimate.com/github/xendoc/omniauth-miil/badges/gpa.svg)](https://codeclimate.com/github/xendoc/omniauth-miil)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'omniauth-miil', github: 'https://github.com/xendoc/omniauth-miil'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ bundle install
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
You can integrate the strategy into your middleware in a config.ru:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
use OmniAuth::Builder do
|
31
|
+
provider :miil, ENV['MIIL_CLIENT_ID'], ENV['MIIL_CLIENT_SECRET']
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
In a devise config/initializers/devise.rb:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
config.omniauth :miil, ENV['MIIL_CLIENT_ID'], ENV['MIIL_CLIENT_SECRET']
|
39
|
+
```
|
40
|
+
|
41
|
+
### License
|
42
|
+
|
43
|
+
OmniAuth Miil is available under the MIT license.
|
data/Rakefile
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "omniauth/strategies/oauth2"
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Miil < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, "miil"
|
7
|
+
option :client_options, {
|
8
|
+
authorize_url: "https://miil.me/oauth/authorize",
|
9
|
+
token_url: "https://miil.me/oauth/token",
|
10
|
+
site: "https://miil.me"
|
11
|
+
}
|
12
|
+
|
13
|
+
def request_phase
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def authorize_params
|
18
|
+
super.tap do |params|
|
19
|
+
%w(scope client_options).each do |v|
|
20
|
+
if request.params[v]
|
21
|
+
params[v.to_sym] = request.params[v]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def callback_url
|
28
|
+
options[:redirect_uri] || super
|
29
|
+
end
|
30
|
+
|
31
|
+
uid { raw_info["user"]["user_id"].to_s }
|
32
|
+
|
33
|
+
info do
|
34
|
+
{
|
35
|
+
id: raw_info["user"]["user_id"],
|
36
|
+
name: raw_info["user"]["username"],
|
37
|
+
image: raw_info["user"]["user_icon_url"],
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
extra do
|
42
|
+
{ raw_info: raw_info }
|
43
|
+
end
|
44
|
+
|
45
|
+
def raw_info
|
46
|
+
@raw_info ||= access_token.get("/api/users/info").parsed
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
OmniAuth.config.add_camelization "miil", "Miil"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-miil/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-miil"
|
8
|
+
spec.version = OmniAuth::Miil::VERSION
|
9
|
+
spec.authors = ["xendoc"]
|
10
|
+
spec.email = ["xendoc@users.noreply.github.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{OmniAuth strategy for miil}
|
13
|
+
spec.description = %q{OmniAuth strategy for miil}
|
14
|
+
spec.homepage = "https://github.com/xendoc/omniauth-miil"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.test_files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "omniauth", "~> 1.0"
|
23
|
+
spec.add_dependency "omniauth-oauth2", "~> 1.1"
|
24
|
+
|
25
|
+
spec.add_development_dependency 'rspec', '~> 2.7'
|
26
|
+
spec.add_development_dependency 'rack-test'
|
27
|
+
spec.add_development_dependency 'simplecov'
|
28
|
+
spec.add_development_dependency 'webmock'
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Miil do
|
4
|
+
let(:access_token) { double('AccessToken', :options => {}) }
|
5
|
+
let(:parsed_response) { double('ParsedResponse') }
|
6
|
+
let(:response) { double('Response', :parsed => parsed_response) }
|
7
|
+
|
8
|
+
subject do
|
9
|
+
OmniAuth::Strategies::Miil.new({})
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
subject.stub(:access_token).and_return(access_token)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "client options" do
|
17
|
+
it 'should have correct site' do
|
18
|
+
subject.options.client_options.site.should eq("https://miil.me")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct authorize url' do
|
22
|
+
subject.options.client_options.authorize_url.should eq('https://miil.me/oauth/authorize')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have correct token url' do
|
26
|
+
subject.options.client_options.token_url.should eq('https://miil.me/oauth/token')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should allow users to override the default redirect_uri if provided" do
|
30
|
+
custom_client = OmniAuth::Strategies::Miil.new('MIIL_APP_KEY', 'MIIL_SECRET_KEY', client_options: { redirect_uri: "http://test.com/callback" })
|
31
|
+
custom_client.options.client_options.redirect_uri.should eq "http://test.com/callback"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "#raw_info" do
|
36
|
+
it "should use relative paths" do
|
37
|
+
access_token.should_receive(:get).with('/api/users/info').and_return(response)
|
38
|
+
subject.raw_info.should eq(parsed_response)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'rspec'
|
3
|
+
require 'rack/test'
|
4
|
+
require 'webmock/rspec'
|
5
|
+
require 'omniauth'
|
6
|
+
require 'omniauth-miil'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.include WebMock::API
|
10
|
+
config.include Rack::Test::Methods
|
11
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-miil
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- xendoc
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-05 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.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-test
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: OmniAuth strategy for miil
|
98
|
+
email:
|
99
|
+
- xendoc@users.noreply.github.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- Gemfile
|
107
|
+
- Guardfile
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- circle.yml
|
111
|
+
- lib/omniauth-miil.rb
|
112
|
+
- lib/omniauth-miil/version.rb
|
113
|
+
- lib/omniauth/strategies/miil.rb
|
114
|
+
- omniauth-miil.gemspec
|
115
|
+
- spec/omniauth/strategies/miil_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
homepage: https://github.com/xendoc/omniauth-miil
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.4.6
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: OmniAuth strategy for miil
|
141
|
+
test_files:
|
142
|
+
- spec/omniauth/strategies/miil_spec.rb
|
143
|
+
- spec/spec_helper.rb
|