-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if host does not exist raise RoleNotFound #2018
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,13 @@ def spiffe_id | |
end | ||
|
||
def host | ||
@host ||= @resource_class[host_id] | ||
return @host if @host | ||
|
||
@host = @resource_class[host_id] | ||
|
||
raise Errors::Authentication::Security::RoleNotFound, host_id unless @host | ||
|
||
@host | ||
end | ||
|
||
def validate_spiffe_id_exists | ||
|
@@ -161,7 +167,7 @@ def audit_success | |
Audit::Event::Authn::InjectClientCert.new( | ||
authenticator_name: AUTHENTICATOR_NAME, | ||
service: webservice, | ||
role_id: host.id, | ||
role_id: sanitized_role_id, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align the keys of a hash literal if they span more than one line. |
||
client_ip: @client_ip, | ||
success: true, | ||
error_message: nil | ||
|
@@ -174,13 +180,22 @@ def audit_failure(err) | |
Audit::Event::Authn::InjectClientCert.new( | ||
authenticator_name: AUTHENTICATOR_NAME, | ||
service: webservice, | ||
role_id: host.id, | ||
role_id: sanitized_role_id, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align the keys of a hash literal if they span more than one line. |
||
client_ip: @client_ip, | ||
success: false, | ||
error_message: err.message | ||
) | ||
) | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra empty line detected at method body end. |
||
# TODO: this logic is taken from app/models/audit/event/authn.rb. | ||
# We should use that logic here. | ||
# Masking role if it doesn't exist to avoid audit pollution | ||
def sanitized_role_id | ||
return "not-found" unless @resource_class[host_id] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add empty line after guard clause. |
||
|
||
host.id | ||
end | ||
end | ||
end | ||
end |
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.
mnissing link to issue