Skip to content
Browse files

Authorization Code is now configurable

  • Loading branch information...
1 parent 4cfa964 commit eb7d1c9812b74c06877852213e932d44cd6a53b1 @felipeelias felipeelias committed Jun 5, 2012
View
1 CHANGELOG.md
@@ -4,6 +4,7 @@
- enhancements
- Configure the way access token is retrieved from request (default to bearer header)
+ - Authorization Code expiration time is now configurable
## 0.4.2
View
1 lib/doorkeeper/config.rb
@@ -117,6 +117,7 @@ def extended(base)
option :admin_authenticator, :as => :authenticate_admin
option :resource_owner_from_credentials
option :access_token_expires_in, :default => 7200
+ option :authorization_code_expires_in,:default => 600
option :orm
def refresh_token_enabled?
View
9 lib/doorkeeper/oauth/authorization/code.rb
@@ -4,9 +4,6 @@ module Authorization
class Code
include URIBuilder
- # TODO: make this configurable
- DEFAULT_EXPIRATION_TIME = 600
-
attr_accessor :authorization, :grant
def initialize(authorization)
@@ -17,7 +14,7 @@ def issue_token
@grant ||= AccessGrant.create!(
:application_id => authorization.client.id,
:resource_owner_id => authorization.resource_owner.id,
- :expires_in => DEFAULT_EXPIRATION_TIME,
+ :expires_in => configuration.authorization_code_expires_in,
:redirect_uri => authorization.redirect_uri,
:scopes => authorization.scopes.to_s
)
@@ -29,6 +26,10 @@ def callback
:state => authorization.state
})
end
+
+ def configuration
+ Doorkeeper.configuration
+ end
end
end
end
View
3 lib/generators/doorkeeper/templates/initializer.rb
@@ -25,6 +25,9 @@
# Admin.find_by_id(session[:admin_id]) || redirect_to(routes.new_admin_session_url)
# end
+ # Authorization Code expiration time (default 10 minutes).
+ # access_token_expires_in 10.minutes
+
# Access token expiration time (default 2 hours).
# If you want to disable expiration, set this to nil.
# access_token_expires_in 2.hours
View
3 spec/dummy/config/initializers/doorkeeper.rb
@@ -25,6 +25,9 @@
# Admin.find_by_id(session[:admin_id]) || redirect_to(routes.new_admin_session_url)
# end
+ # Authorization Code expiration time (default 10 minutes).
+ # access_token_expires_in 10.minutes
+
# Access token expiration time (default 2 hours)
# If you want to disable expiration, set this to nil.
# access_token_expires_in 2.hours

0 comments on commit eb7d1c9

Please sign in to comment.
Something went wrong with that request. Please try again.