feat: As a user, I want to store basic auth credentials in hashed form, to not leak them to authorized admins

オープン
#12,995 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
lua

調査の方向性

参照されている151行目付近の plugins/basic-auth.lua から始め、consumer credentials がどのように保存され、チェックされるかを追跡してください。issue では、保存パスが特定されていないとされています。提案されている hashed_password と hash の設定を、既存の basic-auth および key-auth の動作と比較し、その後、credential の保存と認証を対象とするテストを定義してください。完了条件には、合意済みの hashing 設計、互換性のある設定動作、および両方の credential タイプに対する QA を含めます。

索引モデルが issue の本文から書いたものです。

説明

feature-request
Description

As a User, I want to store basic auth credentials in a hashed way, to not leak credentials to other admin users.

Hi, we are manaiging APISIX with a team of people using the apisix-dashboard.

There is a different set of users that have authenticated access to some APIs exposed via APISIX (not the admin API). We use consumers and a combination of basic-auth and restrict-consumers-plugins to restrict access. We have noticed, that all basic-auth credentials of consumers are stored in a readable format for admins (i.e. if you go to consumers -> <consumer> -> credentials -> <basic-auth-credential>, you can see the plain password for this user.

This allows for trivial impersonation of people and API access for admin users. Thus, I would like to see at least the option to store basic-auth passwords in a hashed way. Sane defaults would be to use SHA512 or bcrypt (depending on which algorithms are supported by lua), with a defined salt, e.g. SHA512(USERNAME.PASSWORD).

The same is true for key-auth API keys.

I am open to help with both code fragments, testing and QA, although I am not very familiar with lua.

The schema for configuration would be something like:

# user config
{
  "username": "testuser",
  "plugins": {
    "basic-auth": {
       "username": "my-basic-credential",  # existing
       "password": "my-password",            # existing
       "hashed_password": "<hash>",        # mutually exclusive to password, allows outside hashing     
       "hash": "sha512"                               # sane default, future-proofing if algorithm needs to be changed
    }
  }
}

Regarding implementation, there need to be 2 sections:

  • saving new credentials - didn't find that in a quick search. There needs to be some logic for differentation between passwordand hashed_password parameter
  • checking the credentials (pseudocode, plugins/basic-auth.lua:151)
# snippet of basic-auth.lua
# import library
local hash = require("lua-hash")

...

# within find_consumer(ctx), before line 151
   if cur_consumer.auth_conf.hash != "" then
     local password_to_check = hash.oneshot(cur_consumer.auth_conf.hash, username .. password)
   else
     local password_to_check = password
   fi
   if cur_consumer.auth_conf.password ~= password_to_check then

Please let me know what you think of the idea. Let me know if you need any more information; as I said, I can contribute code as well, but I will need some pointers in regards to boilerplate (requirements, tests, ...) that need to be implented.

主要言語
Lua
スター
17.3k
フォーク
3k
平均マージ
4日 16時間
マージ済み PR(30日)
69

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/apisix のほかの issue

apache/apisix の issue をすべて見る

似ている issue

Lua の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。