This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 474
Fixed the registry client #259
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8163bb6
Fixed the Portus user for the RegisterClient class
mssola b5cdbd4
Added documentation for some of the classes dealing with authentication
mssola 0ad7754
Added the `catalog` method
mssola 2e1c76b
Fix the creation of admins and the listing of users after introducing…
mssola c05112e
Extended and improved the test suite regarding the Registry client
mssola d05dad9
spec: adding more tests for the `add_tags` method
mssola 15e92e6
Use rake db:seed instead of portus:create when provisioning Vagrant a…
mssola 195f55a
Moved code from the namespace & registry auth_scope's to a common bas…
mssola 68e8c51
Cleaning up
mssola 580876d
Allow all admin users to access the Catalog API
mssola f55413d
Merge remote-tracking branch 'upstream/master' into client
mssola b3ee18f
spec: added tests for the namespace auth_scope class
mssola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -45,4 +45,4 @@ AllCops: | |
- db/migrate/* | ||
- bin/* | ||
- vendor/**/* | ||
|
||
- tmp/**/* |
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 |
---|---|---|
@@ -1,37 +1,19 @@ | ||
class Api::BaseController < ActionController::Base | ||
class ScopeNotHandled < StandardError; end | ||
class RegistryNotHandled < StandardError; end | ||
class WrongPortusOTP < StandardError; end | ||
|
||
include Pundit | ||
|
||
respond_to :json | ||
|
||
rescue_from Namespace::AuthScope::ResourceIsNotFound, with: :deny_access | ||
rescue_from Pundit::NotAuthorizedError, with: :deny_access | ||
rescue_from ScopeNotHandled, with: :deny_access | ||
rescue_from RegistryNotHandled, with: :deny_access | ||
rescue_from WrongPortusOTP, with: :deny_access | ||
rescue_from Portus::AuthScope::ResourceNotFound, with: :deny_access | ||
|
||
protected | ||
|
||
def deny_access | ||
head :unauthorized | ||
end | ||
|
||
def scope_handler(registry, scope_string) | ||
type = scope_string.split(":", 3)[0] | ||
|
||
case type | ||
when "repository" | ||
auth_scope = Namespace::AuthScope.new(registry, scope_string) | ||
else | ||
logger.error "Scope not handled: #{type}" | ||
raise ScopeNotHandled | ||
end | ||
|
||
scopes = scope_string.split(":", 3)[2].split(",") | ||
|
||
[auth_scope, scopes] | ||
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
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,24 @@ | ||
# Registry::AuthScope parses the scope string so it can be used afterwards for | ||
# the "registry" type. | ||
class Registry::AuthScope < Portus::AuthScope | ||
def resource | ||
reg = Registry.find_by(hostname: @registry.hostname) | ||
if reg.nil? | ||
Rails.logger.warn "Could not find registry #{@registry.hostname}" | ||
raise ResourceNotFound | ||
end | ||
reg | ||
end | ||
|
||
def scopes | ||
catalog? ? ["all"] : [] | ||
end | ||
|
||
private | ||
|
||
# Returns true if the given scope string corresponds to the /v2/_catalog | ||
# endpoint. | ||
def catalog? | ||
@resource_name == "catalog" && @actions[0] == "*" | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide more details about the two scopes, like when they are used? This is not so clear right now as it is for the namespace scope (where pull and push are pretty obvious). The goal is to avoid someone else to dig into the distribution code later on ;)