Class: KeycloakSdk::Config
- Inherits:
-
Object
- Object
- KeycloakSdk::Config
- Defined in:
- lib/keycloak_sdk/config.rb
Overview
불변 설정. 생성 시 검증하고 freeze한다. client_secret은 inspect에서 마스킹.
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: 30, jwks_min_refetch: 30.0, 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: 30, jwks_min_refetch: 30.0, expected_audience: nil) ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/keycloak_sdk/config.rb', line 10 def initialize(server_url:, realm:, client_id:, client_secret: nil, scopes: ["openid"], signature_algorithms: ["RS256"], connect_timeout: 10, read_timeout: 10, clock_skew: 30, jwks_min_refetch: 30.0, expected_audience: nil) @server_url = normalize_required("server_url", server_url).sub(%r{/+\z}, "") @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 재조회의 최소 간격(초, 기본 10.0) — 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.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def client_secret @client_secret end |
#clock_skew ⇒ Object (readonly)
Returns the value of attribute clock_skew.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def clock_skew @clock_skew end |
#connect_timeout ⇒ Object (readonly)
Returns the value of attribute connect_timeout.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def connect_timeout @connect_timeout end |
#expected_audience ⇒ Object (readonly)
Returns the value of attribute expected_audience.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def expected_audience @expected_audience end |
#jwks_min_refetch ⇒ Object (readonly)
Returns the value of attribute jwks_min_refetch.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def jwks_min_refetch @jwks_min_refetch end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def read_timeout @read_timeout end |
#realm ⇒ Object (readonly)
Returns the value of attribute realm.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def realm @realm end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def scopes @scopes end |
#server_url ⇒ Object (readonly)
Returns the value of attribute server_url.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def server_url @server_url end |
#signature_algorithms ⇒ Object (readonly)
Returns the value of attribute signature_algorithms.
6 7 8 |
# File 'lib/keycloak_sdk/config.rb', line 6 def signature_algorithms @signature_algorithms end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
33 34 35 36 37 |
# File 'lib/keycloak_sdk/config.rb', line 33 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 |