LoginSignup
3
2

More than 5 years have passed since last update.

Elasticsearch のホスティングサービス Found の ACL の設定

Last updated at Posted at 2015-08-07

Elasticsearch のホスティングサービス Found の ACL の設定について調べたのでメモ。

スクリーンショット 2015-08-07 12.13.12.png

Clusters > Access control のページに行き、このページの「Load into editor」ボタンを押すと、以下のようなデフォルトの設定を生成して、ページ上のエディタに読み込んでくれる。


# Deny everyone by default, as authentication is required.
# Deny is the default also if no "default" is specified,
# so it's only necessary to specify it if you want the
# default to be "allow".
default: deny

auth:
  users:
    # Here are the username/passwords.
    # We generated random passwords for you. You can use these.
    # Do NOT reuse your existing password, as they are saved in clear text.
    # Consider the passwords to be API-keys and the usernames to be descriptions.

    # Note: If dynamic scripts is enabled, you must fully trust whoever you grant search-access.
    searchonly: ul2dp11vxwi
    readwrite: qdmh5dhs6ga

rules:
  - paths:
      # Match all search requests.
      - '/_search|/([^_/]+/_search)|/[^_/]+/[^_/]+/_search'
    conditions:
      - basic_auth:
          users: [searchonly]
    action: allow

  # Also, allow any GET-request.
  - paths: ['.*']
    conditions:
      - basic_auth:
          users:
            - searchonly
      - method:
          verbs: [GET]
    action: allow

  # Allow everything for the readwrite-user
  - paths: ['.*']
    conditions:
      - basic_auth:
          users:
            - readwrite
# Uncomment the following if you want to require SSL.
#      - ssl:
#          require: true
    action: allow

ユーザー認証は、basic認証で行われる。ユーザーの定義は、auth -> users下で行い、rules下のconditions->basic_authで、どのユーザーに権限を与えるかを記述する。

また、conditions下では、ユーザー以外に、HTTPSエンドポイント使用の強制や、アクセス元IPアドレス制限などの制約も記述できる。また、basic_auth を設定せずに、アクセス元IPアドレスの制約だけにすることもできる。これについての詳細はドキュメントに書かれている。

基本的に、生成されたものをベースにして、それをカスタマイズしていくと良いと思う。例えば、IPアドレス 123.456.789.000 からユーザーjohnny が HTTPSエンドポイントにアクセスしてきた場合に、すべての操作を許可するには、以下のように設定する。


default: deny

auth:
  users:
    johnny: qdmh5dhs6ga

rules:
  - paths: ['.*']
    conditions:
      - ssl:
          require: true
      - basic_auth:
          users:
            - johnny
      - client_ip:
          ips:
            - 123.456.789.000
    action: allow

ひとつ途中で躓いたのが、大抵の箇所は空白2つのインデントで良いのにもかかわらず、ssl下のrequire: truebasic_auth下の users: などは、空白4つでインデントしないと設定に反映されなかったこと。なぜだか分かる方教えてください。。。

参考

Access Control - Found by elastic

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2