Skip to content

Commit 43c34bb

Browse files
author
Zander
committed
Improve OIDC logging; add rate limit env var
1 parent 4cf1ee0 commit 43c34bb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Sessions::OidcController < ApplicationController
22
disallow_account_scope
33
require_unauthenticated_access
4-
rate_limit to: 10, within: 15.minutes, only: :create, with: :rate_limit_exceeded
4+
rate_limit to: ENV.fetch("OIDC_RATE_LIMIT", 10).to_i, within: 15.minutes, only: :create, with: :rate_limit_exceeded
55
skip_forgery_protection only: :create
66

77
layout "public"
@@ -10,18 +10,21 @@ def create
1010
auth_hash = request.env["omniauth.auth"]
1111

1212
if auth_hash.present?
13+
Rails.logger.info "[OIDC] Callback for #{auth_hash.info&.email}"
1314
authenticate_with_oidc(auth_hash)
1415
else
15-
Rails.logger.debug "OIDC data not found"
16+
Rails.logger.warn "[OIDC] Data not found"
1617
authentication_failed(message: "OIDC authentication failed.")
1718
end
1819
rescue => e
20+
Rails.logger.error "[OIDC] Authentication error: #{e.class} - #{e.message}"
1921
Rails.error.report(e, severity: :error)
2022
authentication_failed(message: "Error during OIDC authentication.")
2123
end
2224

2325
def failure
2426
error_type = params[:message] || "unknown_error"
27+
Rails.logger.warn "[OIDC] Failure: #{error_type}"
2528
authentication_failed(message: "OIDC authentication failed: #{error_type}")
2629
end
2730
end

0 commit comments

Comments
 (0)