forked from doorkeeper-gem/doorkeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push common functionality into Doorkeeper::Request::Strategy
- Loading branch information
Showing
7 changed files
with
51 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
require 'doorkeeper/request/strategy' | ||
|
||
module Doorkeeper | ||
module Request | ||
class AuthorizationCode | ||
attr_accessor :grant, :client, :server | ||
class AuthorizationCode < Strategy | ||
attr_accessor :grant, :client | ||
|
||
def initialize(server) | ||
@grant, @client, @server = server.grant, server.client, server | ||
super | ||
@grant, @client = server.grant, server.client | ||
end | ||
|
||
def request | ||
@request ||= OAuth::AuthorizationCodeRequest.new(Doorkeeper.configuration, grant, client, server.parameters) | ||
end | ||
|
||
def authorize | ||
request.authorize | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
require 'doorkeeper/request/strategy' | ||
|
||
module Doorkeeper | ||
module Request | ||
class ClientCredentials | ||
attr_accessor :client, :server | ||
class ClientCredentials < Strategy | ||
attr_accessor :client | ||
|
||
def initialize(server) | ||
@client, @server = server.client, server | ||
super | ||
@client = server.client | ||
end | ||
|
||
def request | ||
@request ||= OAuth::ClientCredentialsRequest.new(Doorkeeper.configuration, client, server.parameters) | ||
end | ||
|
||
def authorize | ||
request.authorize | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
require 'doorkeeper/request/strategy' | ||
|
||
module Doorkeeper | ||
module Request | ||
class Code | ||
attr_accessor :pre_auth, :server | ||
class Code < Strategy | ||
attr_accessor :pre_auth | ||
|
||
def initialize(server) | ||
super | ||
@pre_auth = server.context.send(:pre_auth) | ||
@server = server | ||
end | ||
|
||
def request | ||
@request ||= OAuth::CodeRequest.new(pre_auth, server.current_resource_owner) | ||
end | ||
|
||
def authorize | ||
request.authorize | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
require 'doorkeeper/request/strategy' | ||
|
||
module Doorkeeper | ||
module Request | ||
class Password | ||
attr_accessor :credentials, :resource_owner, :server | ||
class Password < Strategy | ||
attr_accessor :credentials, :resource_owner | ||
|
||
def initialize(server) | ||
super | ||
@credentials = server.credentials | ||
@resource_owner = server.resource_owner | ||
@server = server | ||
end | ||
|
||
def request | ||
@request ||= OAuth::PasswordAccessTokenRequest.new(Doorkeeper.configuration, credentials, resource_owner, server.parameters) | ||
end | ||
|
||
def authorize | ||
request.authorize | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
require 'doorkeeper/request/strategy' | ||
|
||
module Doorkeeper | ||
module Request | ||
class RefreshToken | ||
attr_accessor :refresh_token, :credentials, :server | ||
class RefreshToken < Strategy | ||
attr_accessor :refresh_token, :credentials | ||
|
||
def initialize(server) | ||
super | ||
@refresh_token = server.current_refresh_token | ||
@credentials = server.credentials | ||
@server = server | ||
end | ||
|
||
def request | ||
@request ||= OAuth::RefreshTokenRequest.new(Doorkeeper.configuration, refresh_token, credentials, server.parameters) | ||
end | ||
|
||
def authorize | ||
request.authorize | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Doorkeeper | ||
module Request | ||
class Strategy | ||
attr_accessor :server | ||
|
||
def initialize(server) | ||
self.server = server | ||
end | ||
|
||
def request | ||
raise NotImplementedError, "request strategies must define #request" | ||
end | ||
|
||
def authorize | ||
request.authorize | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
require 'doorkeeper/request/strategy' | ||
|
||
module Doorkeeper | ||
module Request | ||
class Token | ||
attr_accessor :pre_auth, :server | ||
class Token < Strategy | ||
attr_accessor :pre_auth | ||
|
||
def initialize(server) | ||
super | ||
@pre_auth = server.context.send(:pre_auth) | ||
@server = server | ||
end | ||
|
||
def request | ||
@request ||= OAuth::TokenRequest.new(pre_auth, server.current_resource_owner) | ||
end | ||
|
||
def authorize | ||
request.authorize | ||
end | ||
end | ||
end | ||
end |