---
title: "Sitecore統合されたフェデレーテッド認証を有効にする"
slug: "enable-sitecore-integrated-federated-authentication"
abstract: "統合されたJSSアプリでフェデレーテッド認証を活用しましょう"
---
# Sitecore統合されたフェデレーテッド認証を有効にする

[統合モードで](https://doc.sitecore.com/xp/ja/developers/hd/19/sitecore-headless-development/start-a-jss-app-in-integrated-mode.html "Start a JSS app in integrated mode")JSSアプリケーションを実行する際、Sitecoreの組み込み[Owin](http://owin.org/)サポートを利用して認証を委任し、ユーザーをSitecoreセキュリティモデルにマッピングできます。

> !注この方法はヘッドレスや接続モードでは機能しません。なぜなら、ブラウザからのリクエストが直接Sitecoreに向かっているからです。

連邦認証を可能にするために:

1.  構成手順については、[Sitecoreでのフェデレーテッド認証の使用](https://doc.sitecore.com/xp/en/developers/102/sitecore-experience-manager/using-federated-authentication-with-sitecore.html) に関するドキュメントを参照してください。
    
2.  [お好みのプロバイダーでフェデレーテッド認証を設定しましょう](https://doc.sitecore.com/xp/en/developers/101/sitecore-experience-manager/configure-federated-authentication.html)。
    
3.  レイアウトサービスのコンテキストを拡張して、Sitecore生成のログインURLをレイアウトサービスの出力に追加します。
    
    > !ヒントレイアウト [サービスから返されるコンテキストデータの拡張](https://doc.sitecore.com/xp/ja/developers/hd/19/sitecore-headless-development/extending-context-data-returned-by-the-layout-service.html "Extending context data returned by the Layout Service")に関するドキュメントを参照してください。
    
    例えば:
    
    using System.Linq;
    using Sitecore.Abstractions;
    using Sitecore.LayoutService.ItemRendering.Pipelines.GetLayoutServiceContext;
    using Sitecore.Pipelines.GetSignInUrlInfo;
    
    public class AddLoginLinks : Sitecore.JavaScriptServices.ViewEngine.LayoutService.Pipelines.GetLayoutServiceContext.JssGetLayoutServiceContextProcessor
    {
     protected readonly BaseCorePipelineManager CorePipelineManager;
     protected readonly BaseLinkManager LinkManager;
    
     public AddLoginLinks(Sitecore.JavaScriptServices.Configuration.IConfigurationResolver configurationResolver, BaseCorePipelineManager corePipelineManager, BaseLinkManager linkManager) : base(configurationResolver)
     {
     CorePipelineManager = corePipelineManager;
     LinkManager = linkManager;
     }
    
     protected override void DoProcess(GetLayoutServiceContextArgs args, Sitecore.JavaScriptServices.Configuration.AppConfiguration application)
     {
     var returnUrl = LinkManager.GetItemUrl(args.RenderedItem);
     var loginUrlArgs = new GetSignInUrlInfoArgs(site: "JssReactWeb", returnUrl: returnUrl);
     GetSignInUrlInfoPipeline.Run(CorePipelineManager, loginUrlArgs);
     if (loginUrlArgs.Result.Any())extend the Layout Service context
     {
     args.ContextData.Add("loginUrls", loginUrlArgs.Result);
     }
     }
    }
    
4.  レイアウトサービスから望ましい出力が返ってきているか確認してください。前のステップのカスタマイズに基づき、レイアウトサービスから返されるJSONデータには以下が含まれているはずです:
    
    loginUrls: 
     {
     identityProvider: "Auth0",
     caption: "Log in with Auth0",
     icon: "/sitecore/shell/themes/standard/Images/24x24/helloworld",
     href: "/identity/externallogin?authenticationType=Auth0&ReturnUrl=%2fidentity%2fexternallogincallback%3fReturnUrl%3d%252fservices%26sc\_site%3djssreactweb%26authenticationSource%3dDefault&sc\_site=JssReactWeb"
     }