auth0 2.1.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/.gitignore +5 -2
- data/.rspec +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +68 -0
- data/auth0.gemspec +11 -10
- data/doc/Auth0/AccessDenied.html +142 -0
- data/doc/Auth0/Api/AuthenticationEndpoints.html +592 -0
- data/doc/Auth0/Api/V1/Clients.html +440 -0
- data/doc/Auth0/Api/V1/Connections.html +506 -0
- data/doc/Auth0/Api/V1/Logs.html +366 -0
- data/doc/Auth0/Api/V1/Rules.html +439 -0
- data/doc/Auth0/Api/V1/Users.html +1617 -0
- data/doc/Auth0/Api/V1.html +188 -0
- data/doc/Auth0/Api/V2/Blacklists.html +268 -0
- data/doc/Auth0/Api/V2/Clients.html +477 -0
- data/doc/Auth0/Api/V2/Jobs.html +277 -0
- data/doc/Auth0/Api/V2/Router.html +109 -0
- data/doc/Auth0/Api/V2/Stats.html +268 -0
- data/doc/Auth0/Api/V2/Users.html +652 -0
- data/doc/Auth0/Api/V2.html +193 -0
- data/doc/Auth0/Api.html +128 -0
- data/doc/Auth0/BadRequest.html +142 -0
- data/doc/Auth0/Client.html +164 -0
- data/doc/Auth0/Exception.html +140 -0
- data/doc/Auth0/InvalidParameter.html +142 -0
- data/doc/Auth0/Mixins/HTTPartyProxy.html +121 -0
- data/doc/Auth0/Mixins/Initializer.html +312 -0
- data/doc/Auth0/Mixins.html +153 -0
- data/doc/Auth0/NotFound.html +143 -0
- data/doc/Auth0/ServerError.html +142 -0
- data/doc/Auth0/Unauthorized.html +143 -0
- data/doc/Auth0/Unsupported.html +142 -0
- data/doc/Auth0/UserIdIsBlank.html +143 -0
- data/doc/Auth0.html +153 -0
- data/doc/Auth0Client.html +163 -0
- data/doc/_index.html +418 -0
- data/doc/class_list.html +58 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +103 -0
- data/doc/file_list.html +60 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +103 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +181 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +435 -0
- data/doc/top-level-namespace.html +114 -0
- data/lib/auth0/api/authentication_endpoints.rb +71 -0
- data/lib/auth0/api/v1/clients.rb +48 -0
- data/lib/auth0/api/v1/connections.rb +51 -0
- data/lib/auth0/api/v1/logs.rb +41 -0
- data/lib/auth0/api/v1/rules.rb +44 -0
- data/lib/auth0/api/v1/users.rb +163 -0
- data/lib/auth0/api/v1.rb +19 -0
- data/lib/auth0/api/v2/blacklists.rb +24 -0
- data/lib/auth0/api/v2/clients.rb +41 -0
- data/lib/auth0/api/v2/jobs.rb +20 -0
- data/lib/auth0/api/v2/stats.rb +24 -0
- data/lib/auth0/api/v2/users.rb +67 -0
- data/lib/auth0/api/v2.rb +17 -0
- data/lib/auth0/client.rb +5 -48
- data/lib/auth0/exception.rb +22 -0
- data/lib/auth0/mixins/httparty_proxy.rb +35 -0
- data/lib/auth0/mixins/initializer.rb +34 -0
- data/lib/auth0/mixins.rb +12 -0
- data/lib/auth0/version.rb +3 -2
- data/lib/auth0.rb +6 -1
- data/lib/auth0_client.rb +3 -0
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +56 -0
- data/spec/lib/auth0/api/v1/clients_spec.rb +62 -0
- data/spec/lib/auth0/api/v1/connections_spec.rb +62 -0
- data/spec/lib/auth0/api/v1/logs_spec.rb +46 -0
- data/spec/lib/auth0/api/v1/rules_spec.rb +40 -0
- data/spec/lib/auth0/api/v1/users_spec.rb +217 -0
- data/spec/lib/auth0/api/v2/blacklists_spec.rb +24 -0
- data/spec/lib/auth0/api/v2/clients_spec.rb +54 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +21 -0
- data/spec/lib/auth0/api/v2/stats_spec.rb +22 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +72 -0
- data/spec/lib/auth0/client_spec.rb +47 -0
- data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +119 -0
- data/spec/lib/auth0_client_spec.rb +8 -0
- data/spec/spec_helper.rb +8 -7
- data/spec/support/dummy_class.rb +7 -0
- data/spec/support/dummy_class_for_proxy.rb +4 -0
- data/spec/support/stub_response.rb +2 -0
- metadata +159 -28
- data/lib/omniauth/strategies/auth0.rb +0 -62
- data/spec/omniauth/strategies/auth0_spec.rb +0 -149
@@ -1,149 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe OmniAuth::Strategies::Auth0 do
|
4
|
-
let(:app){ Rack::Builder.new do |b|
|
5
|
-
b.use Rack::Session::Cookie, {:secret => "abc123"}
|
6
|
-
b.run lambda{|env| [200, {}, ['Not Found']]}
|
7
|
-
end.to_app }
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
OmniAuth.config.test_mode = true
|
11
|
-
@request = double('Request')
|
12
|
-
@request.stub(:params) { {} }
|
13
|
-
@request.stub(:cookies) { {} }
|
14
|
-
@request.stub(:env) { {} }
|
15
|
-
|
16
|
-
@session = double('Session')
|
17
|
-
@session.stub(:delete).with('omniauth.state').and_return('state')
|
18
|
-
end
|
19
|
-
|
20
|
-
after do
|
21
|
-
OmniAuth.config.test_mode = false
|
22
|
-
end
|
23
|
-
|
24
|
-
subject do
|
25
|
-
OmniAuth::Strategies::Auth0.new(app,
|
26
|
-
"client_id", "client_secret", "tenny.auth0.com:3000").tap do |strategy|
|
27
|
-
strategy.stub(:request) { @request }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "initiation" do
|
32
|
-
it "uses the correct site" do
|
33
|
-
subject.options.client_options.site.
|
34
|
-
should == "https://tenny.auth0.com:3000"
|
35
|
-
end
|
36
|
-
|
37
|
-
it "uses the correct authorize_url" do
|
38
|
-
subject.options.client_options.authorize_url.
|
39
|
-
should == "https://tenny.auth0.com:3000/authorize"
|
40
|
-
end
|
41
|
-
|
42
|
-
it "uses the correct token_url" do
|
43
|
-
subject.options.client_options.token_url.
|
44
|
-
should == "https://tenny.auth0.com:3000/oauth/token"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "request phase" do
|
49
|
-
before(:each){ get '/auth/auth0' }
|
50
|
-
|
51
|
-
it "authenticate" do
|
52
|
-
expect(last_response.status).to eq(200)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "authorize params" do
|
56
|
-
subject.stub(:request) { double('Request', {:params => {
|
57
|
-
"connection" => "google-oauth2", "redirect_uri" => "redirect_uri" }, :env => {}}) }
|
58
|
-
subject.authorize_params.include?("connection").should == true
|
59
|
-
subject.authorize_params.include?("state").should == true
|
60
|
-
subject.authorize_params.include?("redirect_uri").should == true
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "callback phase" do
|
65
|
-
before :each do
|
66
|
-
@raw_info = {
|
67
|
-
"_id" => "165dabb5140ee2cc66b5137912ccd760",
|
68
|
-
"email" => "user@mail.com",
|
69
|
-
"family_name" => "LastName",
|
70
|
-
"gender" => "male",
|
71
|
-
"given_name" => "FirstName",
|
72
|
-
"identities" => [
|
73
|
-
{
|
74
|
-
"access_token" => "ya29.AHES6ZRPK1Skc_rtB30Em_5RkZlKez3FkktcmJ_0RX5fIkCbkOCrXA",
|
75
|
-
"provider" => "google-oauth2",
|
76
|
-
"user_id" => "102835921788417079450",
|
77
|
-
"connection" => "google-oauth2",
|
78
|
-
"isSocial" => true
|
79
|
-
}
|
80
|
-
],
|
81
|
-
"locale" => "en",
|
82
|
-
"name" => "FirstName LastName",
|
83
|
-
"nickname" => "nick",
|
84
|
-
"picture" => "pic",
|
85
|
-
"user_id" => "google-oauth2|102835921788417079450"
|
86
|
-
}
|
87
|
-
subject.stub(:raw_info) { @raw_info }
|
88
|
-
end
|
89
|
-
|
90
|
-
context "info" do
|
91
|
-
it 'returns the uid (required)' do
|
92
|
-
subject.uid.should eq('google-oauth2|102835921788417079450')
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'returns the name (required)' do
|
96
|
-
subject.info[:name].should eq('FirstName LastName')
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'returns the email' do
|
100
|
-
subject.info[:email].should eq('user@mail.com')
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'returns the nickname' do
|
104
|
-
subject.info[:nickname].should eq('nick')
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'returns the last name' do
|
108
|
-
subject.info[:last_name].should eq('LastName')
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'returns the first name' do
|
112
|
-
subject.info[:first_name].should eq('FirstName')
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'returns the location' do
|
116
|
-
subject.info[:location].should eq('en')
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'returns the image' do
|
120
|
-
subject.info[:image].should eq('pic')
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context "get token" do
|
125
|
-
before :each do
|
126
|
-
@access_token = double('OAuth2::AccessToken')
|
127
|
-
@access_token.stub(:token)
|
128
|
-
@access_token.stub(:expires?)
|
129
|
-
@access_token.stub(:expires_at)
|
130
|
-
@access_token.stub(:refresh_token)
|
131
|
-
subject.stub(:access_token) { @access_token }
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'returns a Hash' do
|
135
|
-
subject.credentials.should be_a(Hash)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'returns the token' do
|
139
|
-
@access_token.stub(:token) {
|
140
|
-
{
|
141
|
-
:access_token => "OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI",
|
142
|
-
:token_type => "bearer"
|
143
|
-
} }
|
144
|
-
subject.credentials['token'][:access_token].should eq('OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI')
|
145
|
-
subject.credentials['token'][:token_type].should eq('bearer')
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|