Ahoo-Wang/CoSec has 45 GitHub stars and 4 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-24 17:48 UTC. Last push 2026-11-22.
計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 履歴を収集中
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
概要
RBAC-based And Policy-based Multi-Tenant Reactive Security Framework | 基于 RBAC 和策略的多租户响应式安全框架
セキュリティREADME.md
オリジナルCoSec
Multi-tenant, non-blocking authorization for Spring: IAM-style policy documents and role-based permissions, evaluated deny-first for every request.
Why CoSec
- Policies as data. Platform, app and tenant documents in JSON: statements on actions and resources, typed conditions (roles, tenant, app and space, IP ranges, time windows, external attributes), and bindings that say who each policy applies to. Every instance compiles them into a snapshot read from Redis and picks up published changes without a restart.
- Deny wins, everywhere. Any matching DENY overrides every ALLOW, in any document; unmatched requests are
denied; a request that cannot be decided fails closed with
503. - Multi-tenant and role-based. Tenants own their documents, each app publishes its permission catalog and grants permissions to roles per space, and platform boundaries cap what any tenant can allow.
- Reviewed changes. A control plane validates, simulates and shadow-tests a change on live traffic before it is published, keeps its revisions, and rolls back.
- Rate limits. Per-IP, per-user or shared quotas as document rules, spent only by permitted requests, counted
cluster-wide in Redis, with
RateLimit-*andRetry-Afterheaders. - One pipeline, three stacks. Spring WebFlux, Spring MVC and Spring Cloud Gateway share one pipeline and answer
identically, with
application/problem+jsonerrors. - Fast and non-blocking. About 2 µs of pipeline overhead per request, with no blocking on the event loop.
- Auditable. A decision event for every request (audit log, Kafka, Micrometer, OpenTelemetry), naming the statement and binding that decided it.
How a decision is made
flowchart LR
R([Request + token]) --> BL{Blacklisted?}
BL -->|yes| DENY([Deny])
BL -->|no| D{"Any DENY of the bound<br>policies matched?"}
D -->|yes| DENY
D -->|no| U{"Anything that could<br>not be checked?"}
U -->|yes| IND([Indeterminate])
U -->|no| A{Any ALLOW matched?}
A -->|no| DENY
A -->|yes| B{Within the tenant's boundary?}
B -->|no| DENY
B -->|yes| P([Permit])
Denied anonymous callers get 401, authenticated callers 403, undecidable requests 503, and permitted requests
over a rate limit 429.
Quick start
Needs JDK 21, Spring Boot 4.1 and, for cosec-cocache, CoCache 8: see
what CoSec needs from your build.
dependencies {
implementation(platform("me.ahoo.cosec:cosec-bom:<version>"))
implementation("me.ahoo.cosec:cosec-spring-boot")
implementation("me.ahoo.cosec:cosec-webflux") // or cosec-webmvc / cosec-gateway
implementation("me.ahoo.cosec:cosec-cocache") // Redis: snapshot, revocation, rate limits
implementation("org.springframework.boot:spring-boot-data-redis")
implementation("me.ahoo.cocache:cocache-spring-boot-starter")
}
cosec:
jwt:
secret: ${COSEC_JWT_SECRET}
authorization:
routes:
location: "" # no route map yet: requests are authorized as http:<METHOD> on http:path:<path>
Redis must run with maxmemory-policy noeviction. Publish a platform document (here with
cosec-migrate publish); until one exists, every request is answered 503:
{
"schema": 2, "revision": 1, "publishedAt": "2026-10-28T00:00:00Z",
"policies": [
{ "id": "public", "statements": [
{ "effect": "allow", "action": "http:POST", "resource": "http:path:/auth/login" },
{ "effect": "allow", "action": "http:GET", "resource": "http:path:/actuator/health" } ] },
{ "id": "members", "statements": [
{ "effect": "allow", "action": "http:*", "resource": "http:path:/api/**",
"condition": { "eq": ["subject.authenticated", true] } } ] },
{ "id": "admins-only", "statements": [
{ "effect": "deny", "action": "http:*", "resource": "http:path:/api/admin/**",
"condition": { "not": { "in": ["admin", "scope.roles"] } } } ] }
],
"bindings": [
{ "id": "public", "subject": "*", "app": "*", "space": "*", "policy": "public" },
{ "id": "members", "subject": "*", "app": "*", "space": "*", "policy": "members" },
{ "id": "admins-only", "subject": "*", "app": "*", "space": "*", "policy": "admins-only" }
]
}
Continue with the Quick Start to issue tokens, then the policy language.
Modules
cosec-spring-boot brings the request pipeline, login, JWT support and auto-configuration; each integration
(WebFlux, MVC, Gateway, Redis, control plane, OAuth, OpenTelemetry, Micrometer, OpenAPI, ip2region, Kafka) is a module
you add next to it, and the starter wires what it finds on the classpath. cosec-migrate converts 7.x data and publishes documents. See
Modules for the full list. A ready-to-run gateway is
published as the container image ahoowang/cosec-gateway.
Documentation
- Getting started: Introduction · Quick Start · Concepts · Security Model
- Integration: Web Integration · Authentication · Checks in Code
- Policies: Policy Language · Role Permissions · Rate Limiting · Testing Policies
- Operations: Configuration · Storage and Caching · Upgrading · Observability · Troubleshooting
- Architecture: Overview · Extending CoSec
- Releases: GitHub Releases
Contributing
Contributions are welcome. Read CONTRIBUTING.md for the workflow, quality gates and release process. This project follows a Code of Conduct.
Security
Report vulnerabilities privately as described in SECURITY.md; do not open public issues for them.
License
CoSec is released under the Apache License 2.0. Its policy model is inspired by AWS IAM.
関連プロジェクトを探す
読み込み中…