Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(native): Native gateway - support check_auth, context_to_api_scopes #9377

Merged
merged 12 commits into from
Mar 25, 2025
Prev Previous commit
Next Next commit
chore: expose
  • Loading branch information
ovr committed Mar 24, 2025
commit 8e9997caf5073c02d51eed6c2805a74db8793359
16 changes: 16 additions & 0 deletions packages/cubejs-backend-native/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ impl AuthContext for NativeSQLAuthContext {
fn as_any(&self) -> &dyn Any {
self
}

fn user(&self) -> Option<&String> {
self.user.as_ref()
}

fn security_context(&self) -> Option<&serde_json::Value> {
self.security_context.as_ref()
}
}

#[async_trait]
Expand Down Expand Up @@ -140,6 +148,14 @@ impl GatewayAuthContext for NativeGatewayAuthContext {
fn as_any(&self) -> &dyn Any {
self
}

fn user(&self) -> Option<&String> {
None
}

fn security_context(&self) -> Option<&serde_json::Value> {
self.security_context.as_ref()
}
}

#[derive(Debug, Serialize)]
Expand Down
4 changes: 4 additions & 0 deletions packages/cubejs-backend-native/src/gateway/auth_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ use serde::Serialize;
// Any type will allow us to split (with downcast) auth context
pub trait GatewayAuthContext: Debug + Send + Sync {
fn as_any(&self) -> &dyn Any;

fn user(&self) -> Option<&String>;

fn security_context(&self) -> Option<&serde_json::Value>;
}

pub type GatewayAuthContextRef = Arc<dyn GatewayAuthContext>;
Expand Down
4 changes: 4 additions & 0 deletions rust/cubesql/cubesql/src/sql/auth_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
// Any type will allow us to split (with downcast) auth context into HTTP (standalone) or Native
pub trait AuthContext: Debug + Send + Sync {
fn as_any(&self) -> &dyn Any;

fn user(&self) -> Option<String>;

fn security_context(&self) -> Option<&serde_json::Value>;
}

pub type AuthContextRef = Arc<dyn AuthContext>;
Expand All @@ -18,7 +22,7 @@
pub base_path: String,
}

impl AuthContext for HttpAuthContext {

Check failure on line 25 in rust/cubesql/cubesql/src/sql/auth_service.rs

View workflow job for this annotation

GitHub Actions / Build native Linux 20 x86_64-unknown-linux-gnu Python fallback

not all trait items implemented, missing: `user`, `security_context`

Check failure on line 25 in rust/cubesql/cubesql/src/sql/auth_service.rs

View workflow job for this annotation

GitHub Actions / build

not all trait items implemented, missing: `user`, `security_context`

Check failure on line 25 in rust/cubesql/cubesql/src/sql/auth_service.rs

View workflow job for this annotation

GitHub Actions / Build & Test :dev for Debian without pushing

not all trait items implemented, missing: `user`, `security_context`

Check failure on line 25 in rust/cubesql/cubesql/src/sql/auth_service.rs

View workflow job for this annotation

GitHub Actions / unit (20.x, 3.11, false)

not all trait items implemented, missing: `user`, `security_context`

Check failure on line 25 in rust/cubesql/cubesql/src/sql/auth_service.rs

View workflow job for this annotation

GitHub Actions / unit (20.x, 3.11, true)

not all trait items implemented, missing: `user`, `security_context`

Check failure on line 25 in rust/cubesql/cubesql/src/sql/auth_service.rs

View workflow job for this annotation

GitHub Actions / unit (22.x, 3.11, false)

not all trait items implemented, missing: `user`, `security_context`

Check failure on line 25 in rust/cubesql/cubesql/src/sql/auth_service.rs

View workflow job for this annotation

GitHub Actions / unit (22.x, 3.11, true)

not all trait items implemented, missing: `user`, `security_context`

Check failure on line 25 in rust/cubesql/cubesql/src/sql/auth_service.rs

View workflow job for this annotation

GitHub Actions / integration-cubestore (20.x)

not all trait items implemented, missing: `user`, `security_context`
fn as_any(&self) -> &dyn Any {
self
}
Expand Down
Loading