Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xSteph Pentest ai AuthCredentials Build Auth Args

From Leeroopedia
Knowledge Sources
Domains Authentication, Tool_Integration, CLI_Flags
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for representing auth credentials and translating them into tool-specific CLI flags, provided by the pentest-ai engine.

Description

The AuthCredentials dataclass holds authentication state (cookies, bearer token, basic auth, custom headers) and the build_auth_args function translates them into tool-specific CLI flags. A TOOL_AUTH_FLAGS dict maps each tool (nuclei, sqlmap, nikto, ffuf, etc.) to flag templates for each auth type. AuthCredentials.from_cli_args constructs credentials from CLI --cookie, --header, and --basic-auth options.

Usage

Import these when you need to pass authentication credentials into external tool invocations. Used by tool wrappers to inject auth flags into subprocess calls.

Code Reference

Source Location

Signature

@dataclass
class AuthCredentials:
    auth_type: str = ""
    cookies: str = ""
    bearer_token: str = ""
    basic_auth: str = ""
    headers: dict[str, str] = field(default_factory=dict)
    form_fields: dict[str, str] = field(default_factory=dict)
    set_cookie_raw: str = ""

    @classmethod
    def from_dict(cls, data: dict[str, Any] | None) -> AuthCredentials: ...
    @classmethod
    def from_cli_args(cls, cookie: str = "", header: str = "", basic_auth: str = "") -> AuthCredentials: ...
    @property
    def is_set(self) -> bool: ...

TOOL_AUTH_FLAGS: dict[str, dict[str, str]] = ...

def build_auth_args(tool_name: str, creds: AuthCredentials) -> list[str]: ...

Import

from engine.auth_handler import AuthCredentials, build_auth_args, TOOL_AUTH_FLAGS

I/O Contract

Inputs

Name Type Required Description
tool_name str Yes Tool name (e.g. "nuclei", "sqlmap")
creds AuthCredentials Yes Credentials to inject
cookie str No Cookie string for from_cli_args
header str No Custom header for from_cli_args
basic_auth str No Basic auth credentials for from_cli_args

Outputs

Name Type Description
args list[str] CLI flag list for the tool, e.g. ["-H", "Cookie: session=abc"]

Usage Examples

Build Tool Auth Flags

from engine.auth_handler import AuthCredentials, build_auth_args

creds = AuthCredentials(
    auth_type="cookie",
    cookies="session=abc123; csrf=xyz",
)

# Build nuclei auth flags
flags = build_auth_args("nuclei", creds)
# ["-H", "Cookie: session=abc123; csrf=xyz"]

# Build sqlmap auth flags
flags = build_auth_args("sqlmap", creds)
# ["--cookie=session=abc123; csrf=xyz"]

From CLI Args

from engine.auth_handler import AuthCredentials, build_auth_args

creds = AuthCredentials.from_cli_args(
    cookie="session=abc123",
    header="Authorization: Bearer eyJhbGc...",
)
flags = build_auth_args("ffuf", creds)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment