make allowed_targets an option

This commit is contained in:
Konstantin Haase 2012-10-29 18:51:27 +01:00
parent a31d15ddf1
commit 6c911407f0
2 changed files with 6 additions and 6 deletions

View File

@ -62,7 +62,7 @@ GIT
GIT
remote: git://github.com/travis-ci/travis-support.git
revision: a350d17b705e3240ff4eae7973266ba36549acaa
revision: f78d9161369f574f12b9c0c0dbfe13b997766bdd
specs:
travis-support (0.0.1)

View File

@ -39,8 +39,11 @@ class Travis::Api::App
#
# The entry point is [/auth/post_message](#/auth/post_message).
class Authorization < Endpoint
set prefix: '/auth'
enable :inline_templates
set prefix: '/auth', allowed_targets: %r{
^ http:// (localhost|127\.0\.0\.1)(:\d+)? $ |
^ https:// ([\w\-_]+\.)?travis-ci\.(org|com) $
}x
# Endpoint for retrieving an authorization code, which in turn can be used
# to generate an access token.
@ -222,10 +225,7 @@ class Travis::Api::App
end
def target_ok?(target_origin)
target_origin =~ %r{
^ http:// (localhost|127\.0\.0\.1)(:\d+)? $ |
^ https:// ([\w\-_]+\.)?travis-ci\.(org|com) $
}x
target_origin =~ settings.allowed_targets
end
end
end