12.10. データソースセキュリティー
データソースセキュリティーとは、データソース接続のパスワードを暗号化したり分かりにくくすることを言います。これらのパスワードはプレーンテキストで設定ファイルに保存できますが、セキュリティーリスクが高くなります。
データソースセキュリティーに使用できるメソッドは複数あります。以下には、各メソッドの例が含まれています。
セキュリティードメインを使用したデータソースのセキュア化
データソースのセキュリティードメインが定義されます。
<security-domain name="DsRealm" cache-type="default">
<authentication>
<login-module code="ConfiguredIdentity" flag="required">
<module-option name="userName" value="sa"/>
<module-option name="principal" value="sa"/>
<module-option name="password" value="sa"/>
</login-module>
</authentication>
</security-domain>
セキュリティードメインが複数のデータソースと使用される場合は、セキュリティードメインでキャッシュを無効にする必要があります。キャッシュを無効にするには、 cache-type 属性の値を none に設定するか、この属性を削除します。しかし、キャッシュが必要な場合は、各データソースに個別のセキュリティードメインを使用する必要があります。
DsRealm セキュリティードメインはデータソース設定によって参照されます。
<datasources>
<datasource jndi-name="java:jboss/datasources/securityDs"
pool-name="securityDs">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<new-connection-sql>select current_user()</new-connection-sql>
<security>
<security-domain>DsRealm</security-domain>
</security>
</datasource>
</datasources>
セキュリティードメインの使用に関する詳細は、『How to Configure Identity Management』を参照してください。
パスワード Vault を使用したデータソースのセキュア化
<security>
<user-name>admin</user-name>
<password>${VAULT::ds_ExampleDS::password::N2NhZDYzOTMtNWE0OS00ZGQ0LWE4MmEtMWNlMDMyNDdmNmI2TElORV9CUkVBS3ZhdWx0}</password>
</security>
パスワード vault の使用に関する詳細は、JBoss EAP『How to Configure Server Security』の「Password Vault」の項を参照してください。
認証情報ストアを使用したデータソースのセキュア化
認証情報ストアを使用してパスワードを提供することもできます。elytron サブシステムを使用すると、認証情報ストアを作成してパスワードをセキュアに保存し、JBoss EAP 全体でパスワードを使用することができます。認証情報ストアの作成および使用に関する詳細は、JBoss EAP『How to Configure Server Security』の「Credential Store」を参照してください。
認証情報ストア参照を ExampleDS に追加
/subsystem=datasources/data-source=ExampleDS:write-attribute(name=credential-reference,value={store=exampleCS, alias=example-ds-pw})
認証コンテキストを使用したデータソースのセキュア化
Elytron 認証コンテキストを使用して、ユーザー名とパスワードを提供することもできます。
以下の手順にしたがって、データソースセキュリティーの認証コンテキストを設定および使用します。
passwordとuser-nameを削除します。/subsystem=datasources/data-source=ExampleDS:undefine-attribute(name=password) /subsystem=datasources/data-source=ExampleDS:undefine-attribute(name=user-name)データソースの Elytron セキュリティーを有効にします。
/subsystem=datasources/data-source=ExampleDS:write-attribute(name=elytron-enabled,value=true) reload認証情報の
authentication-configurationを作成します。認証設定には、接続時にデータソースに使用させる認証情報が含まれています。以下の例は、認証情報ストアへの参照を使用しますが、Elytron セキュリティードメインを使用することもできます。
/subsystem=elytron/authentication-configuration=exampleAuthConfig:add(authentication-name=sa,credential-reference={clear-text=sa})authentication-contextを作成します。/subsystem=elytron/authentication-context=exampleAuthContext:add(match-rules=[{authentication-configuration=exampleAuthConfig}])認証コンテキストを使用するよう、データソースを更新します。
以下の例は、認証コンテキストを使用するよう、
ExampleDSを更新します。/subsystem=datasources/data-source=ExampleDS:write-attribute(name=authentication-context,value=exampleAuthContext) reload注記authentication-contextが設定されておらず、elytron-enabledがtrueに設定された場合、JBoss EAP は現在のコンテキストを使用して認証を行います。
Kerberos を使用したデータソースの保護
kerberos 認証を使用してデータソースを保護にするには、以下の設定が必要です。
- Kerberos がデータベースサーバーに設定されている。
- JBoss EAP ホストサーバーには、データベースサーバーのキータブエントリーがある。
kerberos を使用してデータソースを保護にするには、以下を実行します。
Kerberos を使用するよう JBoss EAP を設定
/system-property=java.security.krb5.conf:add(value="/path/to/krb5.conf") /system-property=sun.security.krb5.debug:add(value="false") /system-property=sun.security.spnego.debug:add(value="false")デバッグを行う場合は、
sun.security.krb5.debugとsun.security.spnego.debugの値をtrueに変更します。本番環境では、値をfalseに設定することが推奨されます。セキュリティーを設定します。
データソースを保護にするには、レガシーセキュリティーまたは Elytron セキュリティーを使用できます。
レガシーのセキュリティーで kerberos を使用するには、以下の手順に従います。
期限切れのチケットをキャッシュから定期的に削除するように infinispan キャッシュを設定します。
batch /subsystem=infinispan/cache-container=security:add(default-cache=auth-cache) /subsystem=infinispan/cache-container=security/local-cache=auth-cache:add() /subsystem=infinispan/cache-container=security/local-cache=auth-cache/expiration=EXPIRATION:add(lifespan=3540000,max-idle=3540000) /subsystem=infinispan/cache-container=security/local-cache=auth-cache/eviction=EVICTION:add(strategy=LRU, max-entries=1000) run-batch以下の属性はチケットの有効期限を定義します。
-
lifespan: KDC から新しい証明書を要求する間隔 (ミリ秒単位)。KDC で定義される lifespan 条件よりも小さい値になるように、lifespan属性 の値を設定します。 -
max-idle: 未使用の場合に、有効なチケットがキャッシュから削除される間隔 (ミリ秒単位)。 max-entries: キャッシュに保持する kerberos チケットの最大コピー数。この値は、データソースで設定された接続の数に対応します。エビクションの詳細は、『Infinispan』ユーザーガイドの「Eviction and Data Container」以下の項を参照してください。
-
セキュリティードメインを作成します。
batch /subsystem=security/security-domain=KerberosDatabase:add(cache-type=infinispan) /subsystem=security/security-domain=KerberosDatabase/authentication=classic:add /subsystem=security/security-domain=KerberosDatabase/authentication=classic/login-module="KerberosDatabase-Module":add(code="org.jboss.security.negotiation.KerberosLoginModule",module="org.jboss.security.negotiation",flag=required, module-options={ "debug" => "false", "storeKey" => "false", "useKeyTab" => "true", "keyTab" => "/path/to/eap.keytab", "principal" => "PRINCIPAL@SERVER.COM", "doNotPrompt" => "true", "refreshKrb5Config" => "true", "isInitiator" => "true", "addGSSCredential" => "true", "credentialLifetime" => "-1"}) run-batch-
SQL サーバーに Microsoft JDBC ドライバーを使用する場合は、
module-optionsに属性と"wrapsphinx" ⇒ "true"の値を追加します。 -
デバッグするには、
module-optionsのdebug属性の値をtrueに変更します。
-
SQL サーバーに Microsoft JDBC ドライバーを使用する場合は、
Elytron で kerberos を使用するには、以下を行います。
Elytron で kerberos ファクトリーを設定します。
/subsystem=elytron/kerberos-security-factory=krbsf:add(debug=false, principal=PRINCIPAL@SERVER.COM, path=/path/to/keytab, request-lifetime=-1, obtain-kerberos-ticket=true, server=false)デバッグを行う場合は、属性および
debug = trueの値を追加します。対応している属性の一覧は、『How to Configure Server Security』の「Kerberos Security Factory Attributes」を参照してください。
kerberos ファクトリーを使用するよう認証設定を作成します。
/subsystem=elytron/authentication-configuration=kerberos-conf:add(kerberos-security-factory=krbsf)authentication-context を作成します。
/subsystem=elytron/authentication-context=ds-context:add(match-rules=[{authentication-configuration=kerberos-conf}])
データソースを kerberos で保護します。
レガシーのセキュリティーを使用する場合:
セキュリティードメインを使用するようにデータソースを設定します。
/subsystem=datasources/data-source=KerberosDS:add(connection-url="URL", min-pool-size=0, max-pool-size=10, jndi-name="java:jboss/datasource/KerberosDS", driver-name=<jdbc-driver>.jar, security-domain=KerberosDatabase, allow-multiple-users=false, pool-prefill=false, pool-use-strict-min=false, idle-timeout-minutes=2)ベンダー固有の接続プロパティーを設定します。
/subsystem=datasources/data-source=KerberosDS/connection-properties=<connection-property-name>:add(value="(<kerberos-value>)")例: Oracle データベースの接続プロパティー。
/subsystem=datasources/data-source=KerberosDS/connection-properties=oracle.net.authentication_services:add(value="(KERBEROS5)")
Elytron を使用する場合:
認証コンテキストを使用するようにデータソースを設定します。
/subsystem=datasources/data-source=KerberosDS:add(connection-url="URL", min-pool-size=0, max-pool-size=10, jndi-name="java:jboss/datasource/KerberosDS", driver-name=<jdbc-driver>.jar, elytron-enabled=true, authentication-context=ds-context, allow-multiple-users=false, pool-prefill=false, pool-use-strict-min=false, idle-timeout-minutes=2)ベンダー固有の接続プロパティーを設定します。
/subsystem=datasources/data-source=KerberosDS/connection-properties=<connection-property-name>:add(value="(<kerberos-value>)")例: Oracle データベースの接続プロパティー
/subsystem=datasources/data-source=KerberosDS/connection-properties=oracle.net.authentication_services:add(value="(KERBEROS5)")
kerberos 認証を使用する場合は、データソースに以下の属性と値を使用することが推奨されます。
-
pool-prefill=false -
pool-use-strict-min=false -
idle-timeout-minutes
対応している属性のリストは、「データソース属性」を参照してください。