forked from puppetlabs/puppet
-
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.
Merge pull request puppetlabs#3430 from rlinehan/feature/master/PUP-3…
…644-move-urls-to-v3 (PUP-3644) Move urls to v3
- Loading branch information
Showing
28 changed files
with
367 additions
and
133 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
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
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
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
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
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
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
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
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
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
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
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
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,22 @@ | ||
class Puppet::Network::HTTP::API::V3 | ||
require 'puppet/network/http/api/v3/authorization' | ||
require 'puppet/network/http/api/v3/environments' | ||
require 'puppet/network/http/api/v3/indirected_routes' | ||
|
||
AUTHZ = Authorization.new | ||
|
||
INDIRECTED = Puppet::Network::HTTP::Route. | ||
path(/.*/). | ||
any(Puppet::Network::HTTP::API::V3::IndirectedRoutes.new) | ||
|
||
ENVIRONMENTS = Puppet::Network::HTTP::Route. | ||
path(%r{^/environments$}).get(AUTHZ.wrap do | ||
Environments.new(Puppet.lookup(:environments)) | ||
end) | ||
|
||
def self.routes | ||
Puppet::Network::HTTP::Route.path(%r{/v3}). | ||
any. | ||
chain(ENVIRONMENTS, INDIRECTED) | ||
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,18 @@ | ||
require 'puppet/network/authorization' | ||
|
||
class Puppet::Network::HTTP::API::V3::Authorization | ||
include Puppet::Network::Authorization | ||
|
||
def wrap(&block) | ||
lambda do |request, response| | ||
begin | ||
authconfig.check_authorization(:find, request.path, request.params) | ||
rescue Puppet::Network::AuthorizationError => e | ||
raise Puppet::Network::HTTP::Error::HTTPNotAuthorizedError.new(e.message, Puppet::Network::HTTP::Issues::FAILED_AUTHORIZATION) | ||
end | ||
|
||
block.call.call(request, response) | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.