使用mod_auth_openidc实现AzureAD认证并共享会话的方法
构成
-
- Apacheコンテナ2台 + redisコンテナ1台
-
- 静的ファイルをホスティング
- それぞれ、OpenIDConnectで認証して、どちらかで認証をかけたら片方は認証済として扱う。ということをしたい
设定示例
Apache的設定檔案
OIDCCacheType redisをつけるのがミソ
OIDCProviderMetadataURL https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/v2.0/.well-known/openid-configuration
OIDCClientID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
OIDCClientSecret xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OIDCScope "openid email profile"
OIDCRedirectURI https://test-oidc-redis.vamdemic.xyz/document2/redirect/
OIDCDefaultLoggedOutURL https://test-oidc-redis.vamdemic.xyz/
OIDCDefaultURL https://test-oidc-redis.vamdemic.xyz/
OIDCCryptoPassphrase password
OIDCSessionInactivityTimeout 7200
OIDCCacheShmEntrySizeMax 32768
OIDCAuthRequestParams prompt=select_account
OIDCResponseType code
OIDCPassClaimsAs both
OIDCXForwardedHeaders X-Forwarded-Host X-Forwarded-Proto X-Forwarded-Port
OIDCCacheType redis # キャッシュタイプをRedisへ変更
OIDCRedisCacheServer redis # redisサーバのホスト名やIPを指定。:でポート指定
<LocationMatch "/document2/"> # document1/は1系、これは2系
AuthType openid-connect
Require valid-user
LogLevel notice
OIDCUnAuthAction auth
</LocationMatch>
<VirtualHost *:80>
ServerName _
DirectoryIndex index.html
AddDefaultCharset UTF-8
DocumentRoot /var/www/html/
<Directory "/var/www/html/">
Require all granted
</Directory>
</VirtualHost>
请对AzureAD进行配置。

会话状态
- redisに入っているのがわかる
127.0.0.1:6379> KEYS *
1) "s:e_njZDHSOXoJwJdT-_UvMaHkE4r3EpuYjvUbXEgNiLc"
2) "n:VGnVMbQBF7Gu9DcSrkNgOtYBDtrLmtmlh7E9wnumQgg"
3) "j:g0FXAbhwWi1z_3JWFzQ1WM5ARi4bocs0uFnmJ8mMUkQ"
4) "p:fT4ahjL96j49gJX2D6yFABWLBN6rD8Iy9jKZTENUVQE"
5) "s:UFzyRkOBds4j9wFq7pdY5NCxu8ajKorJLFvgKAQjYfI"
6) "s:XZMtFpqJX6mRvVqpOBfuqZyviUOgjMT0Xj4Fmt0uNw8"
127.0.0.1:6379>
参考
请提供您要翻译的具体内容,而不是网址链接。