jboss web.xmlの変更は効果がありません
-
24-09-2019 - |
質問
JBossサーバーのWeb.xmlにこれを追加しました。しかし、それは効果がありませんでした。私はまだ、双方向の証明書交換を使用しないポートに接続することが許可されています。誰かがアイデアを持っていますか?
<!-- Force SSL for entire site as described here: http://wiki.metawerx.net/wiki/ForcingSSLForSectionsOfYourWebsite -->
<security-constraint>
<!-- defines resources to be protected (in this case everything)-->
<web-resource-collection>
<!-- name for the resource, can be anything you like -->
<!-- Question: is this referenced anywhere else? -->
<web-resource-name>
Entire Application
</web-resource-name>
<!-- protect the entire application -->
<url-pattern>
/*
</url-pattern>
</web-resource-collection>
<!-- defines protection level for protected resource -->
<user-data-constraint>
<!-- data cannot be observed or changed -->
<!-- how it works in tomcat: -->
<!-- if (set to integral or confidential && not using ssl) -->
<!-- redirect sent to client, redirecting them to same url -->
<!-- but using the port defined in the redirect port -->
<!-- attribute in the <Connector> element of server.xml -->
<!-- default is 443, so in other words user is redirected -->
<!-- to same page using ssl. -->
<!-- BUT it is differnt for JBOSS!! See this link: http://wiki.metawerx.net/wiki/ForcingSSLForSectionsOfYourWebsite -->
<transport-guarantee>
CONFIDENTIAL
</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<!-- Client-side SSL certificate based authentication. The cert is passed to the server to authenticate -->
<!-- I am pretty sure that CLIENT-CERT should have a dash NOT an underscore see: http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg139845.html -->
<!-- CLIENT-CERT uses a client's AND server's certificates. See: http://monduke.com/2006/01/19/the-mysterious-client-cert/ -->
<auth-method>
CLIENT-CERT
</auth-method>
</login-config>
アップデート
実際、元の投稿でエラーを犯したようです。
Web.xmlは、HTTPを使用してユーザーがWebサービスに接続するのをブロックします(以下のポートC)。ただし、ユーザーは、ユーザーに自分自身を認証することを強制しないポートに接続することが許可されています(ポートB)。ユーザーはポートAに接続できるはずだと思います(持っています clientAuth="true"
)しかし、私は人々がポートBに接続できるべきだとは思わない(それは持っています clientAuth="false"
).
server.xmlからの抜粋
<Connector port="<A>" ... SSLEnabled="true"
...
scheme="https" secure="true" clientAuth="true"
keystoreFile="... .keystore"
keystorePass="pword"
truststoreFile="... .keystore"
truststorePass="pword"
sslProtocol="TLS"/>
<Connector port="<B>" ... SSLEnabled="true"
...
scheme="https" secure="true" clientAuth="false"
keystoreFile="... .keystore"
keystorePass="pword" sslProtocol = "TLS" />
<Connector port="<C>" ...
/>
解決
ポートを想定しています <C>
HTTPであり、構成しているためです <transport-guarantee> CONFIDENTIAL </transport-guarantee>
したがって、ポート <C>
ブロックされています。
ポート <B>
満たすSSLを使用します <transport-guarantee> CONFIDENTIAL </transport-guarantee>
したがって、ブロックされていません。
.
web.xml構成にいくつかの要素がありません。 Webリソースに許可の制約はありません。したがって、ポートからアクセスするとき <B>
あなたは認証されていませんが、あなたはあなたのリソースに認証を入れていないので、あなたはまだリソースにアクセスすることを許可されています。
のリストが必要です <security-role>
含む <role-name>
このアプリケーションにアクセスできます。
<security-constraint>
為に <web-resource-collection>
すべきだった <auth-constraint>
どちらを伝える <role-name>
他の人にアクセスできるようにするには、制限されます。
上記で構成されている役割は、Java EEの役割です。 コンテナ(JBOSS)は、認証された役割をJava EEの役割にマッピングするように構成する必要があります。
参照:
http://java.sun.com/javaee/5/docs/tutorial/doc/bncbe.html
http://community.jboss.org/wiki/rolemappingloginmodule
.
上記のweb.xmlの更新コピー
<!-- Force SSL for entire site as described here: http://wiki.metawerx.net/wiki/ForcingSSLForSectionsOfYourWebsite -->
<security-constraint>
<!-- defines resources to be protected (in this case everything)-->
<web-resource-collection>
<!-- name for the resource, can be anything you like -->
<!-- Question: is this referenced anywhere else? -->
<web-resource-name>
Entire Application
</web-resource-name>
<!-- protect the entire application -->
<url-pattern>
/*
</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>Authorized Roles</description>
<role-name>ALL_AUTHENTICATED</role-name>
</auth-constraint>
<!-- defines protection level for protected resource -->
<user-data-constraint>
<!-- data cannot be observed or changed -->
<!-- how it works in tomcat: -->
<!-- if (set to integral or confidential && not using ssl) -->
<!-- redirect sent to client, redirecting them to same url -->
<!-- but using the port defined in the redirect port -->
<!-- attribute in the <Connector> element of server.xml -->
<!-- default is 443, so in other words user is redirected -->
<!-- to same page using ssl. -->
<!-- BUT it is differnt for JBOSS!! See this link: http://wiki.metawerx.net/wiki/ForcingSSLForSectionsOfYourWebsite -->
<transport-guarantee>
CONFIDENTIAL
</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<!-- Client-side SSL certificate based authentication. The cert is passed to the server to authenticate -->
<!-- I am pretty sure that CLIENT-CERT should have a dash NOT an underscore see: http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg139845.html -->
<!-- CLIENT-CERT uses a client's AND server's certificates. See: http://monduke.com/2006/01/19/the-mysterious-client-cert/ -->
<auth-method>
CLIENT-CERT
</auth-method>
</login-config>
<security-role>
<description>All authenticated users</description>
<role-name>ALL_AUTHENTICATED</role-name>
</security-role>
.
セキュリティには、認証と承認という2つのことがあります。
認証: ユーザーがサブジェクトであることを確認し、ユーザーに特定のプリンシパルを付与するという行為。 「あなたは誰ですか。」
承認: ユーザーが特定のリソースにアクセスできることを確認する行為。 「あなたができること。」
<auth-method>
ユーザーを認証する方法、またはあなたが誰であるかを尋ねる方法を教えてください。ユーザーがクライアント証明書を持っていない場合、彼は認定されていないユーザーです。ユーザーができることはわかりません。
でも <auth-constraint>
あなたができることです。あなたが置くなら <auth-constraint>
, 、そこに言及された役割のみが、それぞれのWebリソースにアクセスできます。認証されていないが、リソースがCertianの役割に制約されていない場合は、特定のリソースにアクセスすることを許可されているユーザーを引き続き使用できます。
他のヒント
変更を加えてからWebアプリケーションをリロードしましたか?