Spring Security(08)-intercept-url構成



Spring Security Intercept Url Configuration



Spring Security(08)-intercept-url構成
ディレクトリ

1.1傍受されたURLを指定する



1.2アクセス権を指定する

1.3アクセス契約の指定



1.4リクエスト方法の指定

1.1傍受されたURLを指定する
現在のintercept-url定義を適用するURLをパターンごとに指定します。

1.2アクセス権を指定する
access属性を使用して、intercept-urlがURLアクセスに必要なアクセス許可を指定できます。アクセスの値は文字列であり、権限の定義または式のいずれかになります。一般的なタイプには、次のようにコンマで区切られた単純なロール名の定義があります。



In the above configuration, it means that all URL requests under the secure path should have ROLE_USER or ROLE_ADMIN privileges. When the value of access starts with 'ROLE_', it will be handled by RoleVoter. In addition, it can also be an expression. If the above configuration is expressed by an expression, it should look like this. Or use the hasRole() expression and then connect with or in the middle, like: Note that you need to specify the use-expressions='true' of the http element when using an expression. More on the use of expressions will be introduced later. When the access property of the intercept-url uses an expression, it will be processed by default using WebExpressionVoter. In addition, you can specify three more specific property values, which are handled by default using AuthenticatedVoter. IS_AUTHENTICATED_ANONYMOUSLY means that the user can access without logging in IS_AUTHENTICATED_REMEMBERED means that the user needs to be automatically logged in through the Remember-Me function IS_AUTHENTICATED_FULLY means that the user's authentication type should be other than the first two, that is, the user needs to log in through the portal. Only login authentication can be accessed. For example, we usually set the login address to IS_AUTHENTICATED_ANONYMOUSLY. It should be noted that when attempting to use http requests to restrict resources that can only be accessed through https, it will automatically jump to the corresponding https channel re-request. If the http or https protocol used is not listening on the standard port (http is 80 by default, https is 443 by default), we need to define their correspondence through the port-mapping element.

セキュリティ:http

The optional values ​​for method are GET, POST, DELETE, PUT, HEAD, OPTIONS, and TRACE.

1.3アクセス契約の指定
アプリケーションがHttpアクセスとHttpsアクセスの両方をサポートし、特定のURLにHttps経由でのみアクセスする必要がある場合、この要件は、intercept-urlのrequires-channelプロパティを指定することで指定できます。 require-channelは、http、https、およびanyの3つの値をサポートします。 Anyは、httpとhttpsの両方にアクセスできることを意味します。

|_+_|
 
|_+_|

1.4リクエスト方法の指定
通常、特定のURLはPOSTを介してのみ要求する必要があり、一部のURLはGETを介してのみ要求できます。これらの制限は、SpringSecurityによって実装されています。インターセプトURLのメソッドプロパティを指定することで、現在のインターセプトURLアプリケーションメソッドを制限できます。デフォルトでは、すべての方法を使用できます。

|_+_|