AthenZ は、Yahoo が開発したオープンソースの認証・認可フレームワークで、マイクロサービス環境向けに設計されています。サービス間通信のための X.509 証明書による認証と、RBAC(ロールベースアクセス制御)による細粒度のアクセス制御を提供します。特に Kubernetes やクラウド環境において、ゼロトラストセキュリティを実現するための基盤として活用されます。
起動するときに遭遇したエラーとその解決方法をこちらに残します。
Dockerで起動時の問題
まず簡単に機能とUIを確認したいため、Dockerを使って起動してみます。ご親切に以下の起動スクリプトはすでに用意されています。
ページに示すコマンドを実行すると、以下のところで止まっています。
...
4. start ZTS
834a8538a18b6944fd0f55e3316a3588301c75a6891e6e7538df2227c1d37fdd
curl: (7) Failed to connect to athenz-zts-server port 8443: Connection refused
ZTS is unavailable - will sleep 3s...
curl: (22) The requested URL returned error: 503 Service Unavailable
ZTS is unavailable - will sleep 3s...
curl: (22) The requested URL returned error: 503 Service Unavailable
ZTS is unavailable - will sleep 3s...
...
トラブルシュッティング
状況を確認すると、コンテナーの状態がunhealthy
であり、responseも503
になっています。
docker ps -a | grep -i zts
834a8538a18b athenz/athenz-zts-server:latest "/usr/local/bin/dock…" 4 minutes ago Up 4 minutes (unhealthy) 0.0.0.0:8443->8443/tcp, [::]:8443->8443/tcp athenz-zts-server
3a524f4f3fc6 athenz/athenz-zts-db:latest "docker-entrypoint.s…" 4 minutes ago Up 4 minutes (healthy) 0.0.0.0:3307->3306/tcp, [::]:3307->3306/tcp athenz-zts-db
curl -k -s -o /dev/null -w "%{http_code}" https://localhost:8443/zts/v1/status
503%
server.log
を確認したらどうやら、ZMS サーバが起動時に OAuth の JWKS(JSON Web Key Set)URI 設定が不足しているため、初期化に失敗しています。
ERROR c.y.a.a.o.OAuthCertBoundJwtAccessTokenAuthority - Invalid OAuthJwtAccessTokenParserFactory class: com.yahoo.athenz.auth.oauth.parser.DefaultOAuthJwtAccessTokenParserFactory
...
Caused by: com.yahoo.athenz.auth.util.CryptoException: Jwks uri must be specified
設定の部分を確認すると、athenz.zms.authority_classes
に com.yahoo.athenz.auth.oauth.OAuthCertBoundJwtAccessTokenAuthority
が含まれています:
docker exec athenz-zms-server cat /opt/athenz/zms/conf/zms_server/zms.properties
athenz.zms.authority_classes=com.yahoo.athenz.auth.impl.PrincipalAuthority,com.yahoo.athenz.auth.impl.TestUserAuthority,com.yahoo.athenz.auth.oauth.OAuthCertBoundJwtAccessTokenAuthority,com.yahoo.athenz.auth.impl.CertificateAuthority
しかし、OAuth Authority の動作には JWKS URI の設定が必須で、それがないためにエラーが発生しています。ZMS の基本機能(X.509ベースの認証など)だけを使用する場合は、この OAuth Authority を設定から削除することで問題が解決します。
docker exec athenz-zms-server sed -i 's/athenz.zms.authority_classes=com.yahoo.athenz.auth.impl.PrincipalAuthority,com.yahoo.athenz.auth.impl.TestUserAuthority,com.yahoo.athenz.auth.oauth.OAuthCertBoundJwtAccessTokenAuthority,com.yahoo.athenz.auth.impl.CertificateAuthority/athenz.zms.authority_classes=com.yahoo.athenz.auth.impl.PrincipalAuthority,com.yahoo.athenz.auth.impl.TestUserAuthority,com.yahoo.athenz.auth.impl.CertificateAuthority/' /opt/athenz/zms/conf/zms_server/zms.properties
docker exec athenz-zts-server sed -i 's/athenz.zts.authority_classes=com.yahoo.athenz.auth.oauth.OAuthCertBoundJwtAccessTokenAuthority,com.yahoo.athenz.auth.impl.CertificateAuthority/athenz.zts.authority_classes=com.yahoo.athenz.auth.impl.CertificateAuthority/' /opt/athenz/zts/conf/zts_server/zts.properties
コンテナーを再起動したら新しい設定が適用され、状態がhealthy
になり、responseも200になりました!
docker restart athenz-zms-server
docker ps -a | grep zms
0b455c9d1508 athenz/athenz-zms-server:latest "/usr/local/bin/dock…" 5 minutes ago Up 15 seconds (healthy) 0.0.0.0:4443->4443/tcp, [::]:4443->4443/tcp athenz-zms-server
fe60903808f3 athenz/athenz-zms-db:latest "docker-entrypoint.s…" 5 minutes ago Up 5 minutes (healthy) 0.0.0.0:3306->3306/tcp, [::]:3306->3306/tcp athenz-zms-db
curl -k -s https://localhost:4443/zms/v1/status
{"code":200,"message":"OK"}%
結果確認
その後は順調に最後までデプロイできました!UIへのログインも問題ない!
#################################################
### Athenz is up!
#################################################
You can access UI now at https://localhost