rack-oauth2 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/example/server/oauth2_controller.rb +24 -0
- data/example/server/token.rb +0 -1
- data/lib/rack/oauth2/server/abstract/handler.rb +4 -5
- data/lib/rack/oauth2/server/abstract/request.rb +1 -1
- data/lib/rack/oauth2/server/authorization.rb +4 -7
- data/rack-oauth2.gemspec +2 -1
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Oauth2Controller < ApplicationController
|
2
|
+
|
3
|
+
def authorize
|
4
|
+
authorization_endpoint = Rack::OAuth2::Server::Authorization.new(self) do |req, res|
|
5
|
+
# TODO
|
6
|
+
end
|
7
|
+
status, header, body = authorization_endpoint.call(request.env)
|
8
|
+
case status
|
9
|
+
when 302
|
10
|
+
redirect_to header['Location']
|
11
|
+
else
|
12
|
+
render :status => status, :json => body
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def token
|
17
|
+
token_endpoint = Rack::OAuth2::Server::Token.new(self) do |req, res|
|
18
|
+
# TODO
|
19
|
+
end
|
20
|
+
status, header, body = token_endpoint.call(request.env)
|
21
|
+
render :status => status, :json => body
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/example/server/token.rb
CHANGED
@@ -7,7 +7,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../lib'))
|
|
7
7
|
require 'rack/oauth2'
|
8
8
|
|
9
9
|
use Rack::OAuth2::Server::Token do |request, response|
|
10
|
-
p request, request.required_params
|
11
10
|
# allow everything
|
12
11
|
response.access_token = 'access_token'
|
13
12
|
response.expires_in = 3600
|
@@ -1,14 +1,13 @@
|
|
1
|
-
require 'rack/auth/abstract/handler'
|
2
|
-
|
3
1
|
module Rack
|
4
2
|
module OAuth2
|
5
3
|
module Server
|
6
4
|
module Abstract
|
7
|
-
class Handler
|
8
|
-
attr_accessor :request, :response
|
5
|
+
class Handler
|
6
|
+
attr_accessor :realm, :authenticator, :request, :response
|
9
7
|
|
10
8
|
def initialize(realm = '', &authenticator)
|
11
|
-
|
9
|
+
@realm = realm
|
10
|
+
@authenticator = authenticator
|
12
11
|
end
|
13
12
|
|
14
13
|
def call(env)
|
@@ -11,19 +11,16 @@ module Rack
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class Request < Abstract::Request
|
14
|
-
attr_accessor :response_type, :
|
14
|
+
attr_accessor :response_type, :redirect_uri, :state
|
15
15
|
|
16
16
|
def initialize(env)
|
17
17
|
super
|
18
|
+
@state = params['state']
|
18
19
|
@redirect_uri = Util.parse_uri(params['redirect_uri']) if params['redirect_uri']
|
19
|
-
@state = params['state']
|
20
|
-
rescue URI::InvalidURIError
|
21
|
-
# NOTE: can't redirect in this case.
|
22
|
-
raise BadRequest.new(:invalid_request, 'Invalid redirect_uri format.')
|
23
20
|
end
|
24
21
|
|
25
22
|
def required_params
|
26
|
-
super + [:response_type
|
23
|
+
super + [:response_type]
|
27
24
|
end
|
28
25
|
|
29
26
|
def profile
|
@@ -44,8 +41,8 @@ module Rack
|
|
44
41
|
attr_accessor :redirect_uri, :state, :approved
|
45
42
|
|
46
43
|
def initialize(request)
|
44
|
+
@state = request.state
|
47
45
|
@redirect_uri = Util.parse_uri(request.redirect_uri) if request.redirect_uri
|
48
|
-
@state = request.state
|
49
46
|
super
|
50
47
|
end
|
51
48
|
|
data/rack-oauth2.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rack-oauth2}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["nov matake"]
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"example/server/authorize.rb",
|
27
|
+
"example/server/oauth2_controller.rb",
|
27
28
|
"example/server/token.rb",
|
28
29
|
"lib/rack/oauth2.rb",
|
29
30
|
"lib/rack/oauth2/server.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- nov matake
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- Rakefile
|
80
80
|
- VERSION
|
81
81
|
- example/server/authorize.rb
|
82
|
+
- example/server/oauth2_controller.rb
|
82
83
|
- example/server/token.rb
|
83
84
|
- lib/rack/oauth2.rb
|
84
85
|
- lib/rack/oauth2/server.rb
|