Class: KeycloakSdk::Config
- Inherits:
-
Object
- Object
- KeycloakSdk::Config
- Defined in:
- lib/keycloak_sdk/config.rb
Overview
불변 설정. 생성 시 검증하고 freeze한다. client_secret은 inspect에서 마스킹.
Constant Summary collapse
- DEFAULT_JWKS_MIN_REFETCH =
JWKS 최소 재조회 간격 기본값의 유일한 정의 자리(초). DoS 증폭 상한이고 아홉 언어가 같은 값으로 정렬돼 있다 —
scripts/test/test-security-defaults.sh가 아홉 언어 코드와 소비자 문서를 함께 대조한다.⚠️ 이 숫자를 다른 곳에 다시 적지 말 것. 예전에는 여기 30.0,
JwksStore#initialize에 10.0으로 두 번 적혀 있었다.JwksStore는 평범한 public 클래스라 소비자가 직접 생성하면 (파사드를 거치지 않으면) 문서가 말하는 30초가 아니라 10초를 받아 IdP를 3배 자주 때렸다. 한글 README도 그 10.0을 그대로 옮겨 적고 있었다(2026-08-12 문서 감사 → 2026-08-13 Task D1). 30.0- DEFAULT_CLOCK_SKEW =
JWT
exp/nbf검증의 시계 오차 허용치 기본값(초). 이것도 아홉 언어 공동 불변식이다 — 한 언어만 커지면 그 언어에서만 만료된 토큰이 더 오래 통과한다. ⚠️JwtValidator#initialize가 같은 값을 두 번째로 적고 있었다(둘 다 30이라 아직 갈리지는 않았으나 JWKS가 10.0/30.0으로 갈린 것과 똑같은 모양이다). 그 자리는 이제 이 상수를 참조한다. 30
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#clock_skew ⇒ Object
readonly
Returns the value of attribute clock_skew.
-
#connect_timeout ⇒ Object
readonly
Returns the value of attribute connect_timeout.
-
#expected_audience ⇒ Object
readonly
Returns the value of attribute expected_audience.
-
#jwks_min_refetch ⇒ Object
readonly
Returns the value of attribute jwks_min_refetch.
-
#read_timeout ⇒ Object
readonly
Returns the value of attribute read_timeout.
-
#realm ⇒ Object
readonly
Returns the value of attribute realm.
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
-
#server_url ⇒ Object
readonly
Returns the value of attribute server_url.
-
#signature_algorithms ⇒ Object
readonly
Returns the value of attribute signature_algorithms.
Instance Method Summary collapse
-
#initialize(server_url:, realm:, client_id:, client_secret: nil, scopes: ["openid"], signature_algorithms: ["RS256"], connect_timeout: 10, read_timeout: 10, clock_skew: DEFAULT_CLOCK_SKEW, jwks_min_refetch: DEFAULT_JWKS_MIN_REFETCH, expected_audience: nil) ⇒ Config
constructor
A new instance of Config.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(server_url:, realm:, client_id:, client_secret: nil, scopes: ["openid"], signature_algorithms: ["RS256"], connect_timeout: 10, read_timeout: 10, clock_skew: DEFAULT_CLOCK_SKEW, jwks_min_refetch: DEFAULT_JWKS_MIN_REFETCH, expected_audience: nil) ⇒ Config
Returns a new instance of Config.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/keycloak_sdk/config.rb', line 26 def initialize(server_url:, realm:, client_id:, client_secret: nil, scopes: ["openid"], signature_algorithms: ["RS256"], connect_timeout: 10, read_timeout: 10, clock_skew: DEFAULT_CLOCK_SKEW, jwks_min_refetch: DEFAULT_JWKS_MIN_REFETCH, expected_audience: nil) @server_url = strip_trailing_slashes(normalize_required("server_url", server_url)) @realm = normalize_required("realm", realm) @client_id = normalize_required("client_id", client_id) @client_secret = client_secret @scopes = Array(scopes).freeze # JWT 서명 검증 허용 알고리즘 핀(기본 RS256). ES256/PS256 realm을 위해 설정 가능하되 # 빈 집합은 alg 핀을 무력화하므로 거부한다. @signature_algorithms = non_empty_array("signature_algorithms", signature_algorithms).freeze @connect_timeout = positive("connect_timeout", connect_timeout) @read_timeout = positive("read_timeout", read_timeout) @clock_skew = non_negative("clock_skew", clock_skew) # 미해결 kid로 인한 JWKS 재조회의 최소 간격(초) — DoS 증폭 상한. 기본값은 위 상수. @jwks_min_refetch = non_negative("jwks_min_refetch", jwks_min_refetch) # 토큰 aud에 들어있어야 할 값(기본 nil = client_id). 기본 realm은 client-credentials 토큰의 # aud에 client_id를 넣지 않으므로, realm이 실제로 발급하는 리소스/오디언스를 지정한다. @expected_audience = expected_audience freeze end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def client_secret @client_secret end |
#clock_skew ⇒ Object (readonly)
Returns the value of attribute clock_skew.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def clock_skew @clock_skew end |
#connect_timeout ⇒ Object (readonly)
Returns the value of attribute connect_timeout.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def connect_timeout @connect_timeout end |
#expected_audience ⇒ Object (readonly)
Returns the value of attribute expected_audience.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def expected_audience @expected_audience end |
#jwks_min_refetch ⇒ Object (readonly)
Returns the value of attribute jwks_min_refetch.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def jwks_min_refetch @jwks_min_refetch end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def read_timeout @read_timeout end |
#realm ⇒ Object (readonly)
Returns the value of attribute realm.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def realm @realm end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def scopes @scopes end |
#server_url ⇒ Object (readonly)
Returns the value of attribute server_url.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def server_url @server_url end |
#signature_algorithms ⇒ Object (readonly)
Returns the value of attribute signature_algorithms.
22 23 24 |
# File 'lib/keycloak_sdk/config.rb', line 22 def signature_algorithms @signature_algorithms end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
49 50 51 52 53 |
# File 'lib/keycloak_sdk/config.rb', line 49 def inspect "#<KeycloakSdk::Config server_url=#{@server_url.inspect} realm=#{@realm.inspect} " \ "client_id=#{@client_id.inspect} client_secret=#{Masking.mask(@client_secret).inspect} " \ "scopes=#{@scopes.inspect}>" end |