{
  "@context": [
    "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
    "https://linkedsoftwaredependencies.org/bundles/npm/css-google-auth/^2.0.0/components/context.jsonld",
    "https://linkedsoftwaredependencies.org/bundles/npm/idsrv2/^1.0.0/components/context.jsonld"
  ],
  "import": [
    "css:config/app/init/static-root.json",
    "css:config/app/main/default.json",
    "css:config/app/variables/default.json",
    "css:config/http/handler/default.json",
    "css:config/http/middleware/default.json",
    "css:config/http/notifications/disabled.json",
    "css:config/http/server-factory/http.json",
    "css:config/http/static/default.json",
    "css:config/identity/access/restricted.json",
    "css:config/identity/email/default.json",
      "css:config/identity/handler/base/default.json",
      "css:config/identity/handler/routing/default.json",
      "css:config/identity/handler/storage/password.json",
      "css:config/identity/handler/enable/account.json",
    "css:config/identity/oidc/default.json",
    "css:config/identity/ownership/token.json",
    "css:config/identity/pod/static.json",
    "css:config/ldp/authentication/dpop-bearer.json",
    "css:config/ldp/authorization/webacl.json",
    "css:config/ldp/handler/default.json",
    "css:config/ldp/metadata-parser/default.json",
    "css:config/ldp/metadata-writer/default.json",
    "css:config/ldp/modes/default.json",
    "css:config/storage/backend/file.json",
    "css:config/storage/key-value/resource-store.json",
    "css:config/storage/location/root.json",
    "css:config/storage/middleware/default.json",
    "css:config/util/auxiliary/acl.json",
    "css:config/util/identifiers/suffix.json",
    "css:config/util/index/default.json",
    "css:config/util/logging/winston.json",
    "css:config/util/representation-conversion/default.json",
    "css:config/util/resource-locker/file.json",
    "css:config/util/variables/default.json",
        "cga:config/identity/handler/routing/google/main.json",
        "cga:config/identity/handler/routing/google/google-oidc.json",
        "cga:config/identity/handler/routing/google/create.json",
        "cga:config/identity/handler/routing/google/login.json",
        "cga:config/identity/handler/routing/google/register.json",
        "cga:config/identity/handler/routing/google/temporary.json",
      "cga:config/identity/handler/storage/google.json"
  ],
  "@graph": [
    {
      "comment": [
        "css:config/oidc.jsonをベースにカスタマイズするためのComponent.js設定ファイル。",
        "現在はまだテスト。"
      ]
    },
    {
      "comment": "設定ファイル(settingsフォルダの中のjsonファイル)を読み込み情報を保存するインスタンス",
      "@id": "urn:idsrv2:core:Idsrv2Settings",
      "@type": "Idsrv2Settings"
    },
    {
      "comment": [
        "idsrv2のIDとCSSのaccountId、google OIDCのsubを",
        "保存するためのJsonResourceStorage。"
      ],
      "@id": "urn:idsrv2:core:Idsrv2Storage",
      "@type": "JsonResourceStorage",
      "source": { "@id": "urn:solid-server:default:ResourceStore" },
      "baseUrl": { "@id": "urn:solid-server:default:variable:baseUrl" },
      "container": "./.internal/idsrv2/"
    },
    {
      "comment": "Googleアカウントのフィルタ",
      "@id": "urn:idsrv2:core:GoogleAuthFilter",
      "@type": "Idsrv2AuthFilter",
      "settings": { "@id": "urn:idsrv2:core:Idsrv2Settings" }
    },
    {
      "comment": "Googleアカウント追加後の処理",
      "@id": "urn:idsrv2:core:PostGAccountGen",
      "@type": "Idsrv2PostGAccountGen",
      "webIdStore": { "@id": "urn:solid-server:default:WebIdStore" },
      "baseUrl": { "@id": "urn:solid-server:default:variable:baseUrl" },
      "idsrv2Storage": { "@id": "urn:idsrv2:core:Idsrv2Storage" },
      "settings": { "@id": "urn:idsrv2:core:Idsrv2Settings" }
    },
    {
      "comment": "RegisterGoogleHandlerをオーバライドしてGoogleAuthFilterとPostGAccountGenを置き換える。",
      "@type": "Override",
      "overrideInstance": { "@id": "urn:cga:core:RegisterGoogleHandler" },
      "overrideParameters": {
        "@type": "RegisterGoogleHandler",
        "googleOIDC": { "@id": "urn:cga:core:GoogleOIDC" },
        "accountStore": { "@id": "urn:solid-server:default:AccountStore" },
        "googleStore": { "@id": "urn:cga:core:GoogleStore" },
        "gSessionStore": { "@id": "urn:cga:core:GSessionStore" },
        "cookieStore": { "@id": "urn:solid-server:default:CookieStore" },
        "googleAuthFilter": { "@id": "urn:idsrv2:core:GoogleAuthFilter" },
        "postGAccountGen": { "@id": "urn:idsrv2:core:PostGAccountGen" }
      }
    },
    {
      "comment": [
        "GoogleAuthFilterとPostGAccountGenの設定はここまで。**********************************",
        "以下はWebIDのURLでプロファイルのTurtleを自動生成するIdsrv2ProfileHandlerの設定。",
        "Idsrv2ProfileHandlerのルーティングはIdsrv2ProfileHandler#canHandleメソッドで行われる感じ。"
      ]
    },
    {
      "comment": "まずIdsrv2ProfileHandlerを生成。",
      "@id": "urn:idsrv2:core:Idsrv2ProfileHandler",
      "@type": "Idsrv2ProfileHandler",
      "baseUrl": { "@id": "urn:solid-server:default:variable:baseUrl" },
      "idsrv2Storage": { "@id": "urn:idsrv2:core:Idsrv2Storage" },
      "settings": { "@id": "urn:idsrv2:core:Idsrv2Settings" }
    },
    {
      "comment": "上で作ったIdsrv2ProfileHandlerをWaterfallHandlerの配列に追加。",
      "@id": "urn:idsrv2:core:Override1",
      "@type": "Override",
      "overrideInstance": { "@id": "urn:solid-server:default:BaseHttpHandler" },
      "overrideSteps": [
        {
          "@type": "OverrideListInsertAfter",
          "overrideParameter": { "@id": "WaterfallHandler:_handlers" },
          "overrideTarget": { "@id": "urn:solid-server:default:IdentityProviderHandler" },
          "overrideValue": { "@id": "urn:idsrv2:core:Idsrv2ProfileHandler" }
        }
      ]
    },
    {
      "comment": "以下管理機能の設定。*****************************************************",
    },
    {
      "comment": "管理機能のAPIを処理するIdsrv2AdminHandlerを生成。",
      "@id": "urn:idsrv2:core:Idsrv2AdminHandler",
      "@type": "Idsrv2AdminHandler",
      "baseUrl": { "@id": "urn:solid-server:default:variable:baseUrl" },
      "accountStore": { "@id": "urn:solid-server:default:AccountStore" },
      "idsrv2Storage": { "@id": "urn:idsrv2:core:Idsrv2Storage" },
      "webIdStore": { "@id": "urn:solid-server:default:WebIdStore" },
      "googleStore": { "@id": "urn:cga:core:GoogleStore" },
      "settings": { "@id": "urn:idsrv2:core:Idsrv2Settings" },
      "aIndexedStorage": { "@id": "urn:solid-server:default:IndexedStorage" }
    },
    {
      "comment": "上のIdsrv2AdminHandlerのルーティングを設定する。",
      "@id": "urn:idsrv2:core:Idsrv2AdminRouter",
      "@type": "InteractionRouteHandler",
      "route": {
        "@id": "urn:idsrv2:core:Idsrv2AdminRoute",
        "@type": "RelativePathInteractionRoute",
        "base": {
          "@id": "urn:idsrv2:core:Idsrv2Route",
          "@type": "RelativePathInteractionRoute",
          "base": { "@id": "urn:solid-server:default:IndexRoute" },
          "relativePath": "idsrv2/"
        },
        "relativePath": "admin/"
      },
      "source": { "@id": "urn:idsrv2:core:Idsrv2AdminHandler" }
    },
    {
      "@id": "urn:solid-server:default:InteractionRouteHandler",
      "@type": "WaterfallHandler",
      "handlers": [{ "@id": "urn:idsrv2:core:Idsrv2AdminRouter" }]
    },
    {
      "comment": "以下テンプレートなどHTMLの実装を生成。*****************************************************",
    },
    {
      "comment": "管理画面用テンプレートを作って追加。",
      "@id": "urn:solid-server:default:HtmlViewHandler",
      "@type": "HtmlViewHandler",
      "templates": [{
        "@id": "urn:idsrv2:core:Idsrv2AdminHtml",
        "@type": "HtmlViewEntry",
        "filePath": "templates/identity/idsrv2/admin-top.html.ejs",
        "route": { "@id": "urn:idsrv2:core:Idsrv2AdminRoute" }
      }]
    },
    {
      "comment": "以下コントロール(controls)の設定。*****************************************************",
    },
    { "comment": "コントロールのトップ(control)にidsrv2を追加",
      "@id": "urn:solid-server:default:ControlHandler",
      "@type": "ControlHandler",
      "controls": [
        {
          "ControlHandler:_controls_key": "idsrv2",
          "ControlHandler:_controls_value": {
            "comment": "All controls associated with the idsrv2.",
            "@id": "urn:idsrv2:core:Idsrv2ControlHandler",
            "@type": "ControlHandler",
            "controls": []
          }
        }
      ]
    },
    { "comment": "Adding the necessary controls(idsrvコントロールの中にadminを追加する)",
      "@id": "urn:idsrv2:core:Idsrv2ControlHandler",
      "@type": "ControlHandler",
      "controls": [{
        "ControlHandler:_controls_key": "admin",
        "ControlHandler:_controls_value": { "@id": "urn:idsrv2:core:Idsrv2AdminRoute" }
      }]
    },
    { "comment": "コントロールのcontrol.htmlにidsrv2を追加",
      "@id": "urn:solid-server:default:HtmlControlHandler",
      "@type": "ControlHandler",
      "controls": [
        {
          "ControlHandler:_controls_key": "idsrv2",
          "ControlHandler:_controls_value": {
            "comment": "All controls associated with the idsrv2.",
            "@id": "urn:idsrv2:core:Idsrv2HtmlControlHandler",
            "@type": "ControlHandler",
            "controls": []
          }
        }
      ]
    },
    { "comment": "Adding HTML(admin-topのHTMLをコントロール(controls.html.idsrv2)の所に追加)",
      "ControlHandler:_controls_value": {
        "@id": "urn:idsrv2:core:Idsrv2HtmlControlHandler",
        "@type": "ControlHandler",
        "controls": [{
          "ControlHandler:_controls_key": "admin",
          "ControlHandler:_controls_value": { "@id": "urn:idsrv2:core:Idsrv2AdminRoute" }
        }]
      }
    },
    {
      "comment": [
        "******************************************************",
        "以下、WebACLでアクセス制限を設定するための色々をやる。",
        "******************************************************"
      ]
    },
    {
      "comment": [
        "テンプレートを使ってリソースを生成するStaticFolderGenerator",
        "テンプレートはsettings/adminに保存されている物を使う",
      ],
      "@id": "urn:idsrv2:core:StaticFolderGenerator1",
      "@type": "StaticFolderGenerator",
      "templateFolder": "settings/admin",
      "resourcesGenerator": { "@id": "urn:solid-server:default:TemplatedResourcesGenerator" }
    },
    {
      "comment": [
        "/.account/admin/を初期化するContainerInitializer",
        "初期化方法は上で作ったStaticFolderGeneratorにおまかせ",
      ],
      "@id": "urn:idsrv2:core:ContainerInitializer1",
      "@type": "ContainerInitializer",
      "args_baseUrl": { "@id": "urn:solid-server:default:variable:baseUrl" },
      "args_path": "/.account/idsrv2/admin/",
      "args_store": { "@id": "urn:solid-server:default:ResourceStore" },
      "args_generator": { "@id": "urn:idsrv2:core:StaticFolderGenerator1" },
      "args_storageKey": "adminContainerInitialized",
      "args_storage": { "@id": "urn:solid-server:default:SetupStorage" }
    },
    {
      "comment": [
        "たぶん最初の1回だけ初期化をさせるためのConditionalHandler",
        "上のContainerInitializerを使う。良くわかっていない",
      ],
      "@id": "urn:idsrv2:core:AdminContainerInitializer",
      "@type": "ConditionalHandler",
      "storageKey": "adminContainerInitialized",
      "storageValue": true,
      "storage": { "@id": "urn:solid-server:default:SetupStorage" },
      "source": { "@id": "urn:idsrv2:core:ContainerInitializer1" },
    },
    {
      "comment": [
        "上のConditionalHandlerを初期化処理に追加",
      ],
      "@id": "urn:solid-server:default:PrimaryParallelInitializer",
      "@type": "ParallelHandler",
      "handlers": [
        { "@id": "urn:idsrv2:core:AdminContainerInitializer" },
      ],
    },
    {
      "comment": "アカウント情報画面のgoogle_subの削除ボタンを非常時にするためにCreateGoogleHandlerの引数を上書き。",
      "@type": "Override",
      "overrideInstance": { "@id": "urn:cga:core:CreateGoogleHandler" },
      "overrideParameters": {
        "@type": "CreateGoogleHandler",
        "googleOIDC": { "@id": "urn:cga:core:GoogleOIDC" },
        "googleStore": { "@id": "urn:cga:core:GoogleStore" },
        "googleRoute": { "@id": "urn:cga:core:GoogleIdRoute" },
        "gSessionStore": { "@id": "urn:cga:core:GSessionStore" },
        "googleAuthFilter": { "@id": "urn:cga:core:GoogleAuthFilter" },
        "postGAccountGen": { "@id": "urn:cga:core:PostGAccountGen" },
        "addDelLinks": false
      }
    },
  ]
}
