Skip to content

Commit 204584f

Browse files
committed
chore: rebase
1 parent e640c78 commit 204584f

8 files changed

Lines changed: 1 addition & 828 deletions

File tree

crate/clients/ckms/src/tests/security/privilege_bypass.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Privileged-user bypass tests (CLI-level).
22
//!
33
//! Verifies that the `crypto_officer_users` server configuration correctly scopes
4-
//! Verifies that the `crypto_officer_users` server configuration correctly scopes
54
//! privileges: only listed users can create keys; the privilege does NOT bleed
65
//! into read or access-management operations on keys owned by other users.
76
//!
@@ -47,7 +46,6 @@ async fn pb01_privileged_user_can_create_key() -> CosmianResult<()> {
4746

4847
// ---------------------------------------------------------------------------
4948
// PB2: Non-privileged user cannot create a key when crypto_officer_users is set.
50-
// PB2: Non-privileged user cannot create a key when crypto_officer_users is set.
5149
// ---------------------------------------------------------------------------
5250
#[tokio::test]
5351
async fn pb02_non_privileged_user_cannot_create() -> CosmianResult<()> {

crate/server/src/config/command_line/clap_config.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,6 @@ pub struct ClapConfig {
215215
#[clap(long, hide = true)]
216216
pub non_revocable_key_id: Option<Vec<String>>,
217217

218-
/// **Deprecated** — use `--crypto-officer-users` (under `[roles]`) instead.
219-
///
220-
/// List of users who have the right to create and import objects and grant
221-
/// the `Create` access right to other users. Kept for backward compatibility;
222-
/// if set and `[roles] crypto_officer_users` is not configured, these users
223-
/// are promoted to the `CryptoOfficer` role automatically on startup.
224-
#[clap(long, hide = true, verbatim_doc_comment)]
225218
/// **Deprecated** — use `--crypto-officer-users` (under `[roles]`) instead.
226219
///
227220
/// List of users who have the right to create and import objects and grant
@@ -231,10 +224,10 @@ pub struct ClapConfig {
231224
#[clap(long, hide = true, verbatim_doc_comment)]
232225
pub privileged_users: Option<Vec<String>>,
233226

234-
#[clap(flatten)]
235227
/// RBAC role assignments (`CryptoOfficer`).
236228
/// Users not listed in any role default to `Operator` (minimum privilege).
237229
/// In TOML these fields live under the `[roles]` section.
230+
#[clap(flatten)]
238231
#[serde(default, rename = "roles")]
239232
pub roles: RolesConfig,
240233

@@ -505,7 +498,6 @@ impl ClapConfig {
505498
// 4. Deserialize into `ClapConfig`, collecting any unknown fields as errors.
506499
// `serde_ignored` wraps the deserializer and calls the callback for every
507500
// field the target type does not recognize — including fields that bubble up
508-
// field the target type does not recognize — including fields that bubble up
509501
// via `#[serde(flatten)]` (e.g. `HsmConfig`), where `deny_unknown_fields`
510502
// would conflict with the flatten and cannot be used directly.
511503
let load_file = |p: &PathBuf| -> KResult<Self> {
@@ -750,8 +742,6 @@ impl fmt::Debug for ClapConfig {
750742
let x = x.field("non_revocable_key_id", &self.non_revocable_key_id);
751743
let x = x.field("privileged_users (deprecated)", &self.privileged_users);
752744
let x = x.field("roles", &self.roles);
753-
let x = x.field("privileged_users (deprecated)", &self.privileged_users);
754-
let x = x.field("roles", &self.roles);
755745

756746
let x = x.field("aws_xks_config", &self.aws_xks_config);
757747
let x = if self.aws_xks_config.aws_xks_enable {

crate/server/src/core/operations/dispatch.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ async fn dispatch_inner(
234234
// Enforce role-based access control before any other check.
235235
check_role_permission(kms, user, operation_tag, &kms.params.crypto_officer).await?;
236236

237-
// Enforce role-based access control before any other check.
238-
check_role_permission(kms, user, operation_tag, &kms.params.crypto_officer).await?;
239-
240237
// For operations where the request carries algorithm choices, validate them
241238
// before executing any cryptographic action. Skip entirely when no policy
242239
// is configured — avoids a function call + match on every dispatch.

crate/server/src/core/operations/generate_crl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ use crate::{
4040
/// In-memory cache of the most recently generated CRL per issuer.
4141
///
4242
/// The public CRL endpoint (`GET /public/certificates/{id}/crl`) reads from
43-
///
44-
/// The public CRL endpoint (`GET /public/certificates/{id}/crl`) reads from
4543
/// this cache so it can serve pre-signed bytes without requiring any
4644
/// authentication or access to key material.
4745
///

crate/server/src/middlewares/auth_verifier/token.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,12 @@ const ALLOWED_ALGORITHMS: &[Algorithm] = &[
4848
Algorithm::PS512,
4949
];
5050

51-
/// Claims extracted from a Cosmian Auth Verifier JWT.
52-
///
53-
/// The auth server includes the RBAC `roles` (RFC 9068 private claim) and
54-
/// the realm identifier in `as_rid` so that OPA can enforce domain-scoped
55-
/// policies without an additional lookup.
5651
/// Claims extracted from a Cosmian Auth Verifier JWT.
5752
///
5853
/// The auth server includes the RBAC `roles` (RFC 9068 private claim) and
5954
/// the realm identifier in `as_rid` so that OPA can enforce domain-scoped
6055
/// policies without an additional lookup.
6156
#[derive(Debug, Deserialize)]
62-
/// Subject — used as the KMS user identity (username / email).
6357
pub(crate) struct AuthVerifierClaims {
6458
/// Subject — used as the KMS user identity (username / email).
6559
pub sub: String,
@@ -82,10 +76,6 @@ pub(crate) struct AuthVerifierClaims {
8276
/// against every key in the JWKS (Cosmian tokens carry no `kid`), and
8377
/// populates [`AuthenticatedUser`] with the full claims — including `roles`
8478
/// and `domain` — so OPA can evaluate role-based and domain-scoped policies.
85-
/// Extracts the bearer token from the `Authorization` header, validates it
86-
/// against every key in the JWKS (Cosmian tokens carry no `kid`), and
87-
/// populates [`AuthenticatedUser`] with the full claims — including `roles`
88-
/// and `domain` — so OPA can evaluate role-based and domain-scoped policies.
8979
pub(super) async fn handle_auth_verifier(
9080
jwks_manager: &Arc<JwksManager>,
9181
req: &ServiceRequest,
@@ -102,22 +92,15 @@ pub(super) async fn handle_auth_verifier(
10292
})
10393
}
10494

105-
/// Validate a Cosmian Auth Verifier JWT and return its full claims.
10695
/// Validate a Cosmian Auth Verifier JWT and return its full claims.
10796
///
10897
/// Validates the signature against every public key in the JWKS (Cosmian
10998
/// tokens carry no `kid`). Returns all claims — `sub`, `roles`, and
11099
/// `domain` (`as_rid` / `as_domain`) — so callers can populate
111100
/// [`AuthenticatedUser`] or store them in a session without re-parsing.
112-
/// Validates the signature against every public key in the JWKS (Cosmian
113-
/// tokens carry no `kid`). Returns all claims — `sub`, `roles`, and
114-
/// `domain` (`as_rid` / `as_domain`) — so callers can populate
115-
/// [`AuthenticatedUser`] or store them in a session without re-parsing.
116101
///
117102
/// In test / insecure builds the signature check is skipped; only the
118103
/// claim structure is decoded (same behaviour as [`JwtAuth`]).
119-
/// In test / insecure builds the signature check is skipped; only the
120-
/// claim structure is decoded (same behaviour as [`JwtAuth`]).
121104
#[cfg_attr(any(test, feature = "insecure"), allow(unused_variables))]
122105
#[cfg_attr(any(test, feature = "insecure"), allow(clippy::unused_async))]
123106
pub(crate) async fn verify_auth_verifier_jwt(

crate/test_kms_server/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,6 @@ replays the steps sequentially.
355355
| OPA | `opa/mode_enforcing_native_co_cert_allowed` | OPA enforcing mode. A client authenticated via mTLS (cert CN = <owner.client@acme.com>) | 2 |
356356
| OPA | `opa/mode_enforcing_unknown_role_denied` | OPA enforcing mode. A bearer token carrying an unrecognised role `Hacker` | 1 |
357357
| OPA | `opa/mode_enforcing_wrong_domain` | OPA enforcing (dual-gate) mode — multi-tenant isolation. | 3 |
358-
| OPA | `opa/mode_enforcing_empty_roles_denied` | OPA enforcing mode. A bearer token with an empty `roles` claim (and no domain) | 1 |
359-
| OPA | `opa/mode_enforcing_native_co_cert_allowed` | OPA enforcing mode. A client authenticated via mTLS (cert CN = <owner.client@acme.com>) | 2 |
360-
| OPA | `opa/mode_enforcing_unknown_role_denied` | OPA enforcing mode. A bearer token carrying an unrecognised role `Hacker` | 1 |
361358
| OPA | `opa/mode_exclusive_allowed` | OPA exclusive mode; JWT with CryptoOfficer role from auth server; Create then Get allowed by is_owner=true. | 3 |
362359
| OPA | `opa/mode_exclusive_auditor_destroy_denied` | OPA exclusive mode. The CryptoOfficer (default JWT client, owner) creates an AES key. | 3 |
363360
| OPA | `opa/mode_exclusive_auditor_get_attributes_allowed` | OPA exclusive mode. The CryptoOfficer (default JWT client, owner) creates an AES key. | 3 |

0 commit comments

Comments
 (0)