---
schema_version: "1"
id: 6a34ae9424bc204e8a224efb0e6f62b81cc0050c584b300b53fd6ea06668686c
title: 要求認証情報へのアクセス
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/pdk/1.2/policies-pdk-configure-features-authentication.md
canonical_url: https://docs.mulesoft.com/jp/pdk/1.2/policies-pdk-configure-features-authentication
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2a97ba10a682352181af1ec4b430e53f7f8314698daeb2b27e51877bbe192bb7
description: MuleSoft Documentation Site
release: "1.2"
latest: false
---
# 要求認証情報へのアクセス

`Authentication`​ Injectable は、以下のインターフェースを提供します。

- 他のポリシーによって消費される認証データを伝播します。
- 別のポリシーで設定済みの認証データをコンシュームします。

データを共有するために、​`Authentication`​ は ​`AuthenticationHandler`​ という trait を実装します。

```Rust
pub trait AuthenticationHandler {
    fn authentication(&self) -> Option<AuthenticationData>;
    fn set_authentication(&self, authentication: Option<&AuthenticationData>);
}
```

`AuthenticationData`​ 構造体には、以下の認証データが含まれます。

```Rust
pub struct AuthenticationData {
    pub principal: Option<String>,
    pub client_id: Option<String>,
    pub client_name: Option<String>,
    pub properties: Value,
}
```

たとえば、次のコードは ​`Authentication`​ データを読み込み、​`client_id`​ と ​`client_name`​ を上書きして変更します。

```Rust
async fn request_filter(state: RequestState, authentication: Authentication) -> Flow<()> {
    let state = state.into_headers_state().await;
    let header_handler = state.handler();

    let auth = authentication.authentication().unwrap_or_default();

    let properties = auth.properties.as_object().cloned().unwrap_or_default();

    let client_id = header_handler
        .header("custom_client_id_header")
        .unwrap_or_default();
    let client_name = header_handler
        .header("custom_client_name_header")
        .unwrap_or_default();

    let auth = AuthenticationData::new(
        auth.principal,
        Some(client_id),
        Some(client_name),
        properties
    );

    authentication.set_authentication(Some(&auth));

    Flow::Continue(())
}

#[entrypoint]
async fn configure(launcher: Launcher) -> Result<()> {
    let filter = on_request(|rs, auth| request_filter(rs, auth));
    launcher.launch(filter).await?;
    Ok(())
}
```

## [](#関連情報)関連情報

- [パラメーターの挿入](https://docs.mulesoft.com/jp/pdk/1.2/policies-pdk-configure-features-inject-parameters)