class

RustAuthTagger

Inherits FrameworkTagger < FileHelper < Tagger < Reference < Object

Constants

ACTIX_AUTH_PATTERNS = [/HttpAuthentication/, /BearerAuth/, /BasicAuth/, /Identity/]

Actix-Web auth middleware/extractor patterns

AUTH_NAME = /auth|jwt|bearer/i
AWAITED_LET = /\blet\s+(?:mut\s+)?\w+\s*(?::[^=;]+)?=\s*(?:fut|future|(?:self\.)?service\.call\([^;]*?\)|next\.run\([^;]*?\))\s*\.await\s*\??\s*;|\b(?:match|if\s+let\s+[^=]+=)\s*(?:fut|future|(?:self\.)?service\.call\([^;{]*?\)|next\.run\([^;{]*?\))\s*\.await\s*\??\s*\{/

The inner service's answer bound to a name (let res = fut.await?;, let res = self.service.call(req).await;).

AXUM_EXTRACTOR_PATTERNS = [/Extension<.*(?:Auth|Claims|Token|User|Session).*>/, /TypedHeader<.*(?:Authorization|Bearer).*>/]

Axum extractor patterns

CALL_CREDENTIAL = /authoriz|bearer|jwt|token|api[-_]?key|claims|session|login|credential|valid|auth_keys|\bauth\b/i

What a refusing middleware reads from the request to decide.

CALL_FN = /\bfn\s+call\b[^{;]*\{/
CARGO_TOML = /\ACargo\.toml\z/
COMPARED = /(?:\w+::)*\w+\s*[=!]=|[=!]=\s*(?:\w+::)*\w+/

A path compared against (res.status() == StatusCode::UNAUTHORIZED): read, not answered.

CONDITIONAL_WRAP = /\bCondition\w*\s*::\s*(?:new|from_option)\b/

Condition::new(flag, mw) / ConditionEx::from_option(opt) register the middleware only when something was configured.

CONFIGURE_ARG = /\.configure\s*\(\s*((?:\w+::)*\w+)\s*\)/
CREDENTIAL = /authoriz|bearer|jwt|token|api[-_]?key|claims|session|login/i

What a middleware reads to tell who the caller is (CSRF names cut out).

CSRF_NAME = /[\w-]*(?:csrf|xsrf)[\w-]*/i
ERROR_EXIT = /\bErr\s*\(|[\w)]\?/

An error whose status is decided elsewhere: Err(...), ctx?, f()?.

EXEMPT_CALL = /\.\w*(?:skip|exclude|allow|ignore|public|whitelist|except)\w*\s*\(((?:[^()]|\((?:[^()]|\([^()]*\))*\))*)\)/i

A call that hands the middleware literal paths to pass: .skip_paths(vec!["/login"]).

EXEMPT_VAR = /\b(\w*(?:white|allow|skip|public|exempt|bypass)\w*)\b/i

A variable naming the paths a middleware lets through unchecked.

FN_NAME_RE = /\bfn\s+(?:r#)?([A-Za-z_]\w*)/
GUARD_ATTRIBUTE_PATTERNS = [/#\[guard\s*=\s*"(\w+)"\]/, /#\[.*guard.*\]/i]

Guard/middleware attribute patterns

GUARD_TYPE_PATTERNS = [/\b(?:Auth|Authenticated|AuthGuard|AuthUser|AuthToken)\b/, /\b(?:ApiKey|ApiToken|BearerToken|AccessToken)\b/, /\b(?:Claims|JwtClaims|TokenClaims|JwtToken)\b/, /\b(?:AdminUser|AdminGuard|Admin)\b/, /\b(?:UserGuard|UserToken|CurrentUser|LoggedInUser)\b/, /\b(?:Session|SessionUser|CookieAuth)\b/, /\b(?:RoleGuard|Permission|Authorized)\b/]

Rocket request guard types (in function signatures)

HANDED_ON = /\blet\s+(?:mut\s+)?\w+\s*(?::[^=;]+)?=\s*next\s*\.\s*run\s*\(/
IMPL_FOR = /\bimpl\b[^{;]*?\bfor\s+(\w+)[^{;]*\{/
METHOD_MENTION = /\bmethod\b|\bMethod::/
MIDDLEWARE_LAYER_PATTERNS = [/\.wrap\s*\(\s*(\w*[Aa]uth\w*)/, /\.wrap\s*\(\s*HttpAuthentication/, /\.middleware\s*\(\s*(\w*[Aa]uth\w*)/]

Middleware layer patterns (in Router/App setup)

MIDDLEWARE_REFUSAL = /#{Noir::RustRequestGuards::REFUSAL_RE}|\b\w+::(?:Unauthori[sz]ed|Unauthenticated|Forbidden)\b/

A 401/403 a middleware answers itself: a status, an actix error helper, or an error variant spelled as one (AuthError::Unauthorized).

SERVICE_ARG = /\.service\s*\(\s*((?:\w+::)*\w+)\s*\)/
SERVICE_TUPLE = /\.service\s*\(\s*\(([^()]*)\)\s*\)/
STRUCT_DECL = /\bstruct\s+(\w+)/
TO_ARG = /\.to\s*\(\s*((?:\w+::)*\w+)\s*\)/
TRANSFORM_TYPE = /\btype\s+Transform\s*=\s*(\w+)/

Constructors

new(options : Hash(String, YAML::Any))
Source

Class methods

target_techs
Source

Instance methods

perform(endpoints : Array(Endpoint)) : Array(Endpoint)

The per-endpoint shape: look at each endpoint, tag in place, hand the array back. Taggers declare only check_endpoint; those that need a pass over the whole set first (a project pre-scan, mcp's legacy prefixes) override perform and call super or loop themselves.

Source

Nested types