---
schema_version: "1"
id: 1354efb7dc369933130f7ec948973cfb3d1225eaf5f7d9b6902e58e98b519975
title: Spring セキュリティを使用したコンポーネントの認証
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/mule-runtime/4.7/component-authorization-using-spring-security.md
canonical_url: https://docs.mulesoft.com/jp/mule-runtime/4.7/component-authorization-using-spring-security
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 522dad8c221a51fbd00566ecc78309c5e1bf932c126d2254e62fceadc349610f
description: MuleSoft Documentation Site
release: "4.7"
latest: false
---
# Spring セキュリティを使用したコンポーネントの認証

ユーザーが呼び出せるメソッドをロールごとに限定するために、Spring セキュリティ機能を使用した認証を Mule コンポーネントで設定する方法を学習します。

## [](#spring-セキュリティ認証マネージャーの設定)Spring セキュリティ認証マネージャーの設定

Spring セキュリティインターフェース認証マネージャーは、認証プロバイダーオブジェクトのチェーン内での要求の受け渡しを管理します。フローコンポーネントへのコールでセキュリティを確保するには、設定済みの ​`authenticationManager`​ をアプリケーションコンテキストに追加する必要があります。

次の例では、保護されているプロセッサーへのアクセスレベルが異なるロールを定義しています。

```xml
  <ss:authentication-manager alias="authenticationManager">
    <ss:authentication-provider>
      <ss:user-service id="userService">
        <ss:user name="admin" password="admin" authorities="ROLE_ADMIN" />
        <ss:user name="joe" password="secret" authorities="ROLE_ADMIN" />
        <ss:user name="anon" password="anon" authorities="ROLE_ANON" />
        <ss:user name="user" password="password" authorities="ROLE_ANON" />
        <ss:user name="ross" password="ross" authorities="ROLE_ANON" />
        <ss:user name="marie" password="marie" authorities="ROLE_ANON" />
      </ss:user-service>
    </ss:authentication-provider>
  </ss:authentication-manager>
```

次の例は、定義されている ​`authenticationManager`​ を参照して、​`requiredAuthorities`​ 項目で ​`ROLE_ADMIN`​ ロールを持つユーザーのみが操作にアクセスできるようにしています。

```xml
	<spring:security-manager>
		<spring:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />
	</spring:security-manager>

	<flow name="protectedFlow">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/" />
		<http:basic-security-filter doc:name="Basic security filter" realm="mule" />
		<spring:authorization-filter requiredAuthorities="ROLE_ADMIN" />

		<ee:transform doc:name="Transform Message">
			<ee:message>
				<ee:set-payload><![CDATA[%dw 2.0
				output application/json
				---
				{
					"status": "ok"
				}]]>
				</ee:set-payload>
			</ee:message>
		</ee:transform>
	</flow>
```

## [](#非同期システムでのセキュアコンポーネントの設定)非同期システムでのセキュアコンポーネントの設定

複数のスレッドで認証を設定するためには、セキュリティプロバイダーにセキュリティプロパティを追加する必要があるため、非同期システムでは Spring セキュリティが便利です。 次の例では、​`MODE_GLOBAL`​ が追加されたセキュリティプロパティです。

```xml
    <mule-ss:security-manager>
        <mule-ss:delegate-security-provider name="memory-dao" delegate-ref="authenticationManager">
            <mule-ss:security-property name="securityMode" value="MODE_GLOBAL"/>
        </mule-ss:delegate-security-provider>
    </mule-ss:security-manager>
```