外部認証とICAPを使用するadjust_send_usernameのSQUIDブロックモードは機能しません。

外部認証とICAPを使用するadjust_send_usernameのSQUIDブロックモードは機能しません。

私の目標は、外部ACLタイプから取得したユーザー名に基づいてHTTPおよびHTTPS URLを透過的にフィルタリングすることです。

私はインターセプトモードでSquid 3.5.23を実行していますが、調査した後はインターセプトモードでexternal_acl_typeを使用できるようです(間違っている可能性があります)。その後、OK / ERR応答の一部としてOK user = testuserを返すと、SQUIDはそれを使用します。ユーザー名は認証されたユーザーです。

私はstdinを読む簡単なPythonスクリプトを書いてから、すぐにSQUIDのstdoutにOK user = testuserを書き直しました。

SSLピック、スプライシング、バンピングが機能し、http_accessの場合、SSLポートへの要求でない場合はSNIの代わりに%DSTを使用する純粋な外部認証を使用します。次に、ポートがSSLの場合はこれを許可しますが、ssl-bumpを使用すると、SNIを介したSSL外部認証を参照します。

両方の外部ACLはOK user = testuserとして応答し、私が生成したログで機能していることがわかります。

ICAPサーバーに接続すると問題が発生します。

記録された要求の中には、クライアントIPとユーザー名がICAPヘッダーに表示され、一部ではまったく送信されないことがわかります。

なぜいくつかのICAP要求にヘッダーがあり、他の要求にヘッダーがないのかパターンを特定することはできません。

ICAP 要求は外部認証の前または後にいつ送信されますか?

私は何か間違っているのでしょうか、それとも実際には機能しないことをしようとしていますか?

これが私の構成に関連する部分だと思います。

    external_acl_type ssl_external negative_ttl=0 %SRC %PORT %METHOD %ssl::>sni %PATH /etc/webscreen/auth/webscreen.py
    external_acl_type plain_external negative_ttl=0 %SRC %PORT %METHOD %DST %PATH /etc/webscreen/auth/webscreen.py

    acl ssl_webscreen external ssl_external
    acl plain_webscreen external plain_external

    acl SSL_ports port 443

    acl step1 at_step SslBump1
    acl step2 at_step SslBump2
    acl step3 at_step SslBump3

    http_access allow !SSL_ports plain_webscreen
    http_access allow SSL_ports localnet
    http_access deny all

    ssl_bump peek step1 all
    ssl_bump splice step2 ssl_webscreen
    ssl_bump bump all

    icap_enable on
    icap_service_failure_limit -1
    icap_preview_enable on
    icap_preview_size 1024
    icap_persistent_connections on
    adaptation_send_client_ip on
    adaptation_send_username on
    icap_service webscreen1 reqmod_precache icap://127.0.0.1:1344/reqmod bypass=0
    icap_service webscreen2 respmod_precache icap://127.0.0.1:1344/respmod bypass=0
    adaptation_access webscreen1 allow all
    adaptation_access webscreen2 allow all

コメントでリクエストしたように、ここにwebscreen.pyがあります。

#!/usr/bin/env python
import sys, time, datetime, os

log_file = "/etc/squid/webscreen/webscreen.log"

def main ():

        while (1):
                inline = sys.stdin.readline()
                logEntry (10, "New proxy request "+inline)
                sys.stdout.write("OK user=webscreen\n")
                sys.stdout.flush()


def logEntry(logmessagelevel, logmessage):

        global log_file
        # Get timestamp as human readable format
        now = datetime.datetime.now()
        timestamp = now.strftime("%Y-%m-%d %H:%M:%s")

        # open file to apptend
        logfile = open(log_file, 'a')
        logfile.write(timestamp+" "+str(logmessagelevel)+" "+logmessage+"\n")
        logfile.close()
        return



if __name__ == '__main__':
        main()

ベストアンサー1

おすすめ記事