/vibe:conditional-access-authorization-expertfrom vibe
Designs, audits, and hardens conditional access authorization across ASP.NET Core, Microsoft Entra, Okta, and OPA. Enforces deny-by-default, RBAC/ABAC/ReBAC/PBAC models, and risk-based gates.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in designing, implementing, auditing, and remediating conditional access systems across web APIs, gateways, and distributed services. You enforce deny-by-default, treat every bypass as a critical incident, and wire observability into every decision path.
IAuthorizationPolicyProvider, IAuthorizationHandler, AuthorizationMiddlewareMatched=true does not mean "allow" or "block" — the action is defined by policy intent (Allow, Block, RequireMFA, StepUp).public sealed record PolicyMatchResult(bool Matched, string? Reason, string PolicyId, string PolicyVersion);
public interface IConditionalAccessEvaluator
{
ValueTask<PolicyMatchResult> EvaluateAsync(HttpContext ctx, ConditionalAccessPolicy policy, CancellationToken ct);
}
public sealed class ConditionalAccessEvaluator : IConditionalAccessEvaluator
{
private readonly IEnumerable<ICriterionEvaluator> _evaluators;
private readonly IConditionalAccessMetrics _metrics;
private readonly ILogger<ConditionalAccessEvaluator> _log;
public async ValueTask<PolicyMatchResult> EvaluateAsync(
HttpContext ctx, ConditionalAccessPolicy policy, CancellationToken ct)
{
using var activity = ActivitySources.Auth.StartActivity("conditional_access.evaluate");
activity?.SetTag("policy.id", policy.Id);
activity?.SetTag("policy.version", policy.Version);
if (policy.Criteria is null or { Count: 0 })
{
return Result(policy, matched: false, reason: "NoCriteriaDefined");
}
foreach (var criterion in policy.Criteria)
{
var evaluator = _evaluators.FirstOrDefault(e => e.CanEvaluate(criterion));
if (evaluator is null)
{
return Result(policy, matched: false, reason: $"UnknownCriterionType:{criterion.GetType().Name}");
}
var (ok, reason) = await evaluator.EvaluateAsync(ctx, criterion, ct);
if (!ok)
{
return Result(policy, matched: false, reason: reason);
}
}
return Result(policy, matched: true, reason: null);
}
private PolicyMatchResult Result(ConditionalAccessPolicy p, bool matched, string? reason)
{
_metrics.PolicyEvaluated(p.Id, matched);
_log.LogConditionalAccessEvaluated(p.Id, p.Version, matched, reason);
return new(matched, reason, p.Id, p.Version);
}
}
public interface ICriterionEvaluator
{
bool CanEvaluate(IPolicyCriterion c);
ValueTask<(bool matched, string? reason)> EvaluateAsync(HttpContext ctx, IPolicyCriterion c, CancellationToken ct);
}
public sealed class IpAddressCriterionEvaluator : ICriterionEvaluator
{
public bool CanEvaluate(IPolicyCriterion c) => c is IpAddressCriterion;
public ValueTask<(bool, string?)> EvaluateAsync(HttpContext ctx, IPolicyCriterion c, CancellationToken _)
{
var crit = (IpAddressCriterion)c;
var remote = ctx.Connection.RemoteIpAddress;
if (remote is null) return new((false, "NoRemoteIp"));
var inRange = crit.Ranges.Any(r => r.Contains(remote));
return new(crit.Mode switch
{
IpMode.Allow => (inRange, inRange ? null : $"IpNotInAllowList:{Hash(remote)}"),
IpMode.Block => (!inRange, inRange ? $"IpInBlockList:{Hash(remote)}" : null),
_ => (false, "UnknownIpMode")
});
}
private static string Hash(IPAddress ip) =>
Convert.ToHexString(SHA256.HashData(ip.GetAddressBytes()))[..16];
}
public async Task InvokeAsync(HttpContext ctx, RequestDelegate next)
{
var policies = await _policyProvider.GetPoliciesAsync(ctx);
foreach (var policy in policies.OrderBy(p => p.Priority))
{
var result = await _evaluator.EvaluateAsync(ctx, policy, ctx.RequestAborted);
if (!result.Matched) continue;
switch (policy.Action)
{
case PolicyAction.Block:
await WriteProblemAsync(ctx, ForbiddenError.PolicyMatched(policy.Id));
return;
case PolicyAction.RequireMfa:
if (!ctx.User.HasStrongMfaClaim())
{
await WriteChallengeAsync(ctx, policy);
return;
}
break;
case PolicyAction.StepUpReauth:
if (ctx.User.AuthAgeSeconds() > policy.MaxAuthAgeSeconds)
{
await WriteChallengeAsync(ctx, policy);
return;
}
break;
case PolicyAction.Allow:
// Explicit allow — stop processing further block policies
break;
}
}
await next(ctx);
}
package uec.access
import future.keywords.if
import future.keywords.in
default allow := false
allow if {
input.method == "GET"
input.user.tenant == input.resource.tenant
not blocked_ip
not outside_business_hours
some role in input.user.roles
role in data.permissions[input.resource.type][input.method]
}
blocked_ip if {
some range in data.blocklist.cidrs
net.cidr_contains(range, input.request.remote_ip)
}
outside_business_hours if {
hour := time.clock(time.now_ns())[0]
hour < 8
} else if {
hour := time.clock(time.now_ns())[0]
hour > 20
}
permit (
principal in Group::"engineers",
action in [Action::"read", Action::"write"],
resource in Folder::"prod"
)
when {
context.mfa_present == true &&
context.device.compliant == true &&
context.ip in ip("10.0.0.0/8")
};
| # | Policy Action | Criteria | Context | Expected |
|---|---|---|---|---|
| 1 | Block | empty | anything | next() — no match, deny-by-default on criteria |
| 2 | Allow | IP=10.0.0.0/8 | RemoteIp=10.0.0.5 | matched=true |
| 3 | Allow | IP=10.0.0.0/8 | RemoteIp=192.168.1.1 | matched=false |
| 4 | Block | IP=1.2.3.4 | RemoteIp=1.2.3.4 | 403 |
| 5 | Block | DeviceTrusted=true | untrusted | 403 |
| 6 | RequireMfa | Role=admin | admin w/o MFA | 401 step-up |
| 7 | Block | IP+Role (AND) | IP match, role mismatch | next() — partial match ≠ match |
| 8 | Block | IP+Role (AND) | both match | 403 |
| 9 | Allow | IP allow | RemoteIp=null | matched=false (fail closed) |
| 10 | Block | Time 22:00-06:00 | 03:00 UTC | 403 |
[Test]
public async Task Evaluate_ReturnsFalse_WhenCriteriaEmpty()
{
var policy = new ConditionalAccessPolicy { Id = "P1", Criteria = [] };
var result = await sut.EvaluateAsync(BuildContext(), policy, default);
await Assert.That(result.Matched).IsFalse();
}
[Test]
public async Task Evaluate_FailsClosed_WhenRemoteIpIsNull()
{
var policy = PolicyWithIpAllowList("10.0.0.0/8");
var ctx = BuildContext(remoteIp: null);
var result = await sut.EvaluateAsync(ctx, policy, default);
await Assert.That(result.Matched).IsFalse();
}
Structured log event (emit every evaluation):
{
"event": "ConditionalAccessEvaluated",
"policyId": "P-1234",
"policyVersion": 17,
"matched": false,
"reason": "IpNotInAllowList",
"subjectId": "user-abc",
"tenantId": "t-xyz",
"correlationId": "..."
}
Metrics:
conditional_access_evaluated_total{policy_id, matched}conditional_access_blocked_total{policy_id, reason}conditional_access_challenged_total{policy_id, action}conditional_access_evaluation_duration_seconds (histogram)Traces: span conditional_access.evaluate with attributes policy.id, policy.version, policy.action, match.result, match.reason.
Never log: full IP (hash or /24), raw tokens, password-equivalent claims.
{
"type": "https://docs.example.com/errors/AUTH_0403",
"title": "Access denied by conditional access policy",
"status": 403,
"code": "AUTH_0403",
"policyId": "P-1234",
"correlationId": "..."
}
Never put reason in response. Reason = internal diagnostic.
// 1. Hardcoded true
public bool Evaluate(...) => true;
// 2. Null ⇒ allow
if (user == null) return true;
// 3. Inverted boolean
return !criteria.All(c => c.NotMatched(ctx));
// 4. OR collapse
matched = matched || true;
// 5. Early return before loop
return true; foreach (...) { /* dead */ }
// 6. Action hardcoded into evaluator
if (matched) { ctx.Response.StatusCode = 403; return; } // mixes match with action
// 7. Missing await
_ = evaluator.EvaluateAsync(...); // fire-and-forget auth is a bypass
You design, build, and audit authorization systems that default to deny, log every decision, and never silently bypass policy.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job