Fiware チュートリアルをやってみる(セキュリティ:ID管理) (その2)
こちらの続きです。
402. Roles and Permissions
パーミッションを作って、ロールを作って、ロールにパーミッションを割り当てる。
GUIでも、API経由でもできる。
403. Securing Application Access
ここでアプリケーションとセキュリティが組み合わされる。
これは是非、Google Cloud で起動してみよう。
./services create
Pulling Docker images
Using default tag: latest
latest: Pulling from curlimages/curl
Digest: sha256:a37d88a5b626208146c6d58f75b74a93c35dfc00b6b4676c4e9d2c166ea41954
Status: Image is up to date for curlimages/curl:latest
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.tutorial.depends_on contains an invalid type, it should be an array
あれ?ローカルではできているのに。
次の章に期待
404. Securing Microservices with a PEP Proxy
誤記じゃないけど、これまでと書き方が違う。これだと、証明書が必要なので、こちらで取得。
git clone git@github.com:Fiware/tutorials.PEP-Proxy.git
↓
git clone https://github.com/FIWARE/tutorials.PEP-Proxy.git
けど同じエラー
ERROR: The Compose file './docker-compose/orion.yml' is invalid because:
services.orion-proxy.depends_on contains an invalid type, it should be an array
services.tutorial.depends_on contains an invalid type, it should be an array
Docckerバージョンアップ
エラーの原因は、結論としては、Docker Compose のバージョンが古いことでした。
これもちょっと大変だったので、余談ですが、バージョンアップ方法についてメモしておきます。
元々は、スクリプトインストールをしている環境でした。
このスクリプトは、既にインストールされている Docker をアップグレードするように設計されていません。 このスクリプトを利用して既存インストールをアップデートする際には、依存パッケージが思いどおりにアップデートされない場合があります。 それによって古いバージョンのまま利用する状況となる場合があります。
それではいかん、ということで、リポジトリ利用の方法でできるかを試してみました。
sudo apt-get update # インストール可能なパッケージの「一覧」を更新する。
・・・
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://cli-assets.heroku.com/apt ./ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6DB5542C356545CF
W: Failed to fetch https://cli-assets.heroku.com/apt/./InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6DB5542C356545CF
W: Some index files failed to download. They have been ignored, or old ones used instead.
だめ。ならば、パッケージからのインストール。
何をダウンロードするかは、現在の環境を知る必要がある。
grep -H "" /etc/*version ; grep -H "" /etc/*release
/etc/debian_version:stretch/sid
/etc/ec2_version:Ubuntu 16.04.4 LTS (Xenial Xerus)
/etc/lsb-release:DISTRIB_ID=Ubuntu
・・・
そこで、これをダウンロード。
環境へのファイルアップロードは、SSHでログインしてから、アップロード。
しかし、これもだめ。
こちらのサイトに助けていただきました。
docker -v
Docker version 18.09.7, build 2d0083d
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys xxx
sudo apt-get update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
docker -v
Docker version 20.10.7, build f0df350
docker-compose -v
docker-compose version 1.21.0, build 5920eb0
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
docker-compose -v
docker-compose version 1.28.6, build 5db8d86f
これでやり直してみると、
./services create
./services start
ERROR: for fiware-orion-proxy UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: for fiware-iot-agent UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: for iot-agent UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: for orion-proxy UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60)
一応進んだ。けど、エラー・・・
結局だめなので、とりあえず、机上学習することにします。
あらためて、
403. Securing Application Access
あらためて
ローカルでも起動は苦しい
とりあえず、机上学習
一般的な OAuth 2.0 グラント・フローがいくつかある。
- Authorization Code (認可コード)
- Implicit (暗黙)
- Password (パスワード)
- Client Credentials (クライアント資格情報)
- Device Code (デバイス・コード )
- Refresh Token (リフレッシュ・トークン)
ユーザ資格情報のグラント (User Credentials Grant)
パスワード・グラントとしても知られている・・・分かりにくい・・・
認可コードのグラント (Authorization Code Grant)
認可サーバ (Authorization Server) にリダイレクトされ、そこにログインしてアクセスを許可。
この認可サーバを、Keyrock で実現できる。
暫定的なアクセス・コード→ユーザ承認 の手順。
暗黙のグラント (Implicit Grant)
暫定アクセスコードを 返すのではなく、直接 access_token を返します。
クライアント資格情報のグラント (Client Credentials Grant)
ユーザではなく、アプリケ ーションにリソースへのアクセスが許可されるように、アプリケーションを識別
突然出てきた、PDPという言葉。
Policy Decision Point。
ユーザが Keyrock を使用して認証した場合、/user エンドポイントに GET リクエ ストを行うことでアクセス・トークンの最新性を確認できます。
404. Securing Microservices with a PEP Proxy
前章は、アプリとKeyrockが連携することで、認証・認可を行うイメージ。
さらに、サービスの前に Policy Enforcement Point (PEP) を置くことで、アクセスを保護することができ、それを行うのが、FIWARE Wilma PEP Proxy。
Orion のポート1026に直接接続せずに、Wilma の1027に接続する。
405. XACML Rules-based Permissions
FIWARE Authzforce GE は、 XACML(eXtensible Access Control Markup Language) 標準 を使用して提供されたルールを解釈して、PDPを提供する。
複雑なビジネス・ルールを作成および変更できます。
複雑とは、ルールを相互に依存したり、 例外条項を設定したり、期限や属性値に基づいてアクセスさせること。
XACMLは、PolicySet, Policy と Rule の3つのレベルの 階層で定義する。
と言いつつ、本章では、この構成は出てこない。
406. Administrating XACML via a PAP
PAPとは、Policy Adminstration Point。
この章で、/authzforce-ce/domains/{{domain-id}}/pap/policies エンドポイントに、
<PolicySet ・・・>
から始まるPOST リクエストを行う。
追加章? OPENID CONNECT による ID 認証
FIWARE Keyrock generic enabler は OAuth 2.0 に加えて、OpenID Connect (OIDC) をサポートしている。
なんとなく雰囲気を感じつつ、次に進めます。
Discussion