Skip to content

Commit

Permalink
79903 user credential log update (#16305)
Browse files Browse the repository at this point in the history
* adds csps and acrs attributes to ClientConfig

* name update

* adds validation of csp type & acr against client config

* adds csps and acrs attributes to ClientConfig

* name update

* name updates and removes redundant validations

* removes duplicate test

* update log output

* update

* rubocop

* updates codeowners
  • Loading branch information
bramleyjl authored Apr 15, 2024
1 parent f72cca0 commit 9fbe39d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,6 @@ rakelib/mockdata_synchronize.rake @department-of-veterans-affairs/octo-identity
rakelib/pension_burial.rake @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
rakelib/piilog_repl @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
rakelib/prod @department-of-veterans-affairs/vfs-vaos @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
rakelib/prod/user_credential.rake @department-of-veterans-affairs/octo-identity
rakelib/remove_va1995s_records.rake @department-of-veterans-affairs/govcio-vfep-codereviewers @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
rakelib/routes_csv.rake @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
rakelib/rswag.rake @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1485,6 +1484,7 @@ spec/rakelib/form526_spec.rb @department-of-veterans-affairs/Benefits-Team-1 @de
spec/rakelib/piilog_repl @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/rakelib/piilog_repl/piilog_helpers_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/rakelib/vet360_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
rakelib/prod/user_credential.rake @department-of-veterans-affairs/octo-identity
spec/requests/admin_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/requests/appeals_request_spec.rb @department-of-veterans-affairs/backend-review-group
spec/requests/appointments_request_spec.rb @department-of-veterans-affairs/vfs-vaos @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
34 changes: 28 additions & 6 deletions rakelib/prod/user_credential.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ namespace :user_credential do
type = args[:type]
credential_id = args[:credential_id]
context = { type:, credential_id:, requested_by: args[:requested_by] }
log_task(namespace:, status: 'start', context:)
log_to_stdout(level: 'info', message: "[#{namespace}] rake task start, context: #{context.to_json}")
user_verification = UserVerification.where(["#{type}_uuid = ?", credential_id]).first
user_verification.lock!
log_task(namespace:, status: 'complete', context: context.merge(locked: user_verification.locked))
context[:locked] = user_verification.locked
log_to_stdout(level: 'info', message: "[#{namespace}] rake task complete, context: #{context.to_json}")
puts "#{namespace} complete - #{type}_uuid: #{credential_id}"
rescue => e
puts "#{namespace} failed - #{e.message}"
Expand All @@ -23,10 +24,11 @@ namespace :user_credential do
type = args[:type]
credential_id = args[:credential_id]
context = { type:, credential_id:, requested_by: args[:requested_by] }
log_task(namespace:, status: 'start', context:)
log_to_stdout(level: 'info', message: "[#{namespace}] rake task start, context: #{context.to_json}")
user_verification = UserVerification.where(["#{type}_uuid = ?", credential_id]).first
user_verification.unlock!
log_task(namespace:, status: 'complete', context: context.merge(locked: user_verification.locked))
context[:locked] = user_verification.locked
log_to_stdout(level: 'info', message: "[#{namespace}] rake task complete, context: #{context.to_json}")
puts "#{namespace} complete - #{type}_uuid: #{credential_id}"
rescue => e
puts "#{namespace} failed - #{e.message}"
Expand All @@ -38,7 +40,27 @@ namespace :user_credential do
args[:requested_by].blank?
end

def log_task(namespace:, status:, context:)
Rails.logger.info("[#{namespace}] rake task #{status}", context)
def log_to_stdout(level:, message:)
`echo "#{log_message(level:, message:).to_json.dump}" >> /proc/1/fd/1`
end

def log_message(level:, message:)
{
level:,
message:,
application: 'vets-api-server',
environment: Rails.env,
timestamp: Time.zone.now.iso8601,

file: 'rakelib/prod/user_credential.rake',
named_tags: {
dd: {
env: ENV.fetch('DD_ENV', nil),
service: 'vets-api'
},
ddsource: 'ruby'
},
name: 'Rails'
}
end
end

0 comments on commit 9fbe39d

Please sign in to comment.