Skip to content

Commit 92fdc93

Browse files
committed
Revert "Organizations (clockworklabs#4087)"
This reverts commit 46f572b.
1 parent 1e48210 commit 92fdc93

File tree

8 files changed

+110
-351
lines changed

8 files changed

+110
-351
lines changed

crates/cli/src/subcommands/publish.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,6 @@ If a parent is given, the new database inherits the team permissions from the pa
8484
A parent can only be set when a database is created, not when it is updated."
8585
)
8686
)
87-
.arg(
88-
Arg::new("organization")
89-
.help("Name or identity of an organization for this database")
90-
.long("organization")
91-
.alias("org")
92-
.long_help(
93-
"The name or identity of an existing organization this database should be created under.
94-
95-
If an organization is given, the organization member's permissions apply to the new database.
96-
An organization can only be set when a database is created, not when it is updated."
97-
)
98-
)
9987
.arg(
10088
Arg::new("name|identity")
10189
.help("A valid domain or identity for this database")
@@ -151,7 +139,6 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
151139
let num_replicas = args.get_one::<u8>("num_replicas");
152140
let force_break_clients = args.get_flag("break_clients");
153141
let parent = args.get_one::<String>("parent");
154-
let org = args.get_one::<String>("organization");
155142

156143
// If the user didn't specify an identity and we didn't specify an anonymous identity, then
157144
// we want to use the default identity
@@ -240,9 +227,6 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
240227
if let Some(parent) = parent {
241228
builder = builder.query(&[("parent", parent)]);
242229
}
243-
if let Some(org) = org {
244-
builder = builder.query(&[("org", org)]);
245-
}
246230

247231
println!("Publishing module...");
248232

crates/client-api/src/lib.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,7 @@ pub struct DatabaseDef {
204204
pub num_replicas: Option<NonZeroU8>,
205205
/// The host type of the supplied program.
206206
pub host_type: HostType,
207-
/// The optional identity of an existing database the database shall be a
208-
/// child of.
209207
pub parent: Option<Identity>,
210-
/// The optional identity of an organization the database shall belong to.
211-
pub organization: Option<Identity>,
212208
}
213209

214210
/// Parameters for resetting a database via [`ControlStateDelegate::reset_database`].
@@ -512,12 +508,9 @@ impl axum::response::IntoResponse for Unauthorized {
512508
}
513509

514510
/// Action to be authorized via [Authorization::authorize_action].
515-
#[derive(Clone, Copy, Debug)]
511+
#[derive(Debug)]
516512
pub enum Action {
517-
CreateDatabase {
518-
parent: Option<Identity>,
519-
organization: Option<Identity>,
520-
},
513+
CreateDatabase { parent: Option<Identity> },
521514
UpdateDatabase,
522515
ResetDatabase,
523516
DeleteDatabase,
@@ -528,13 +521,9 @@ pub enum Action {
528521
impl fmt::Display for Action {
529522
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
530523
match self {
531-
Self::CreateDatabase { parent, organization } => match (parent, organization) {
532-
(Some(parent), Some(org)) => {
533-
write!(f, "create database with parent {} and organization {}", parent, org)
534-
}
535-
(Some(parent), None) => write!(f, "create database with parent {}", parent),
536-
(None, Some(org)) => write!(f, "create database with organization {}", org),
537-
(None, None) => f.write_str("create database"),
524+
Self::CreateDatabase { parent } => match parent {
525+
Some(parent) => write!(f, "create database with parent {}", parent),
526+
None => f.write_str("create database"),
538527
},
539528
Self::UpdateDatabase => f.write_str("update database"),
540529
Self::ResetDatabase => f.write_str("reset database"),

crates/client-api/src/routes/database.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,6 @@ pub struct PublishDatabaseQueryParams {
651651
#[serde(default)]
652652
host_type: HostType,
653653
parent: Option<NameOrIdentity>,
654-
#[serde(alias = "org")]
655-
organization: Option<NameOrIdentity>,
656654
}
657655

658656
pub async fn publish<S: NodeDelegate + ControlStateDelegate + Authorization>(
@@ -665,7 +663,6 @@ pub async fn publish<S: NodeDelegate + ControlStateDelegate + Authorization>(
665663
policy,
666664
host_type,
667665
parent,
668-
organization,
669666
}): Query<PublishDatabaseQueryParams>,
670667
Extension(auth): Extension<SpacetimeAuth>,
671668
program_bytes: Bytes,
@@ -713,10 +710,6 @@ pub async fn publish<S: NodeDelegate + ControlStateDelegate + Authorization>(
713710
None => None,
714711
Some(parent) => parent.resolve(&ctx).await.map(Some)?,
715712
};
716-
let maybe_org_identity = match organization.as_ref() {
717-
None => None,
718-
Some(org) => org.resolve(&ctx).await.map(Some)?,
719-
};
720713

721714
// Check that the replication factor looks somewhat sane.
722715
let num_replicas = num_replicas.map(validate_replication_factor).transpose()?.flatten();
@@ -729,18 +722,19 @@ pub async fn publish<S: NodeDelegate + ControlStateDelegate + Authorization>(
729722
.await
730723
.map_err(log_and_500)?;
731724
match existing.as_ref() {
725+
// If not, check that the we caller is sufficiently authenticated.
732726
None => {
733727
allow_creation(&auth)?;
734-
ctx.authorize_action(
735-
auth.claims.identity,
736-
database_identity,
737-
Action::CreateDatabase {
738-
parent: maybe_parent_database_identity,
739-
organization: maybe_org_identity,
740-
},
741-
)
742-
.await?;
728+
if let Some(parent) = maybe_parent_database_identity {
729+
ctx.authorize_action(
730+
auth.claims.identity,
731+
database_identity,
732+
Action::CreateDatabase { parent: Some(parent) },
733+
)
734+
.await?;
735+
}
743736
}
737+
// If yes, authorize via ctx.
744738
Some(database) => {
745739
ctx.authorize_action(auth.claims.identity, database.database_identity, Action::UpdateDatabase)
746740
.await?;
@@ -774,7 +768,6 @@ pub async fn publish<S: NodeDelegate + ControlStateDelegate + Authorization>(
774768
num_replicas,
775769
host_type,
776770
parent,
777-
organization: maybe_org_identity,
778771
},
779772
schema_migration_policy,
780773
)
@@ -929,7 +922,6 @@ pub async fn pre_publish<S: NodeDelegate + ControlStateDelegate + Authorization>
929922
num_replicas: None,
930923
host_type,
931924
parent: None,
932-
organization: None,
933925
},
934926
style,
935927
)

crates/standalone/src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,6 @@ impl spacetimedb_client_api::Authorization for StandaloneEnv {
478478
database: Identity,
479479
action: spacetimedb_client_api::Action,
480480
) -> Result<(), spacetimedb_client_api::Unauthorized> {
481-
// Creating a database is always allowed.
482-
if let spacetimedb_client_api::Action::CreateDatabase { .. } = action {
483-
return Ok(());
484-
}
485-
486-
// Otherwise, the database must already exist,
487-
// and the `subject` equal to `database.owner_identity`.
488481
let database = self
489482
.get_database_by_identity(&database)
490483
.await?

crates/testing/src/modules.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ impl CompiledModule {
221221
num_replicas: None,
222222
host_type: self.host_type,
223223
parent: None,
224-
organization: None,
225224
},
226225
MigrationPolicy::Compatible,
227226
)

docs/docs/00300-resources/00200-reference/00100-cli-reference/00100-cli-reference.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ Run `spacetime help publish` for more detailed information.
108108

109109
If a parent is given, the new database inherits the team permissions from the parent.
110110
A parent can only be set when a database is created, not when it is updated.
111-
* `--organization <ORGANIZATION>` — The name or identity of an existing organization this database should be created under.
112-
113-
If an organization is given, the organization member's permissions apply to the new database.
114-
An organization can only be set when a database is created, not when it is updated.
115111
* `-s`, `--server <SERVER>` — The nickname, domain name or URL of the server to host the database.
116112
* `-y`, `--yes` — Run non-interactively wherever possible. This will answer "yes" to almost all prompts, but will sometimes answer "no" to preserve non-interactivity (e.g. when prompting whether to log in with spacetimedb.com).
117113

smoketests/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ def log_records(self, n):
235235
logs = self.spacetime("logs", "--format=json", "-n", str(n), "--", self.database_identity)
236236
return list(map(json.loads, logs.splitlines()))
237237

238-
def publish_module(self, domain=None, *, clear=True, capture_stderr=True,
239-
num_replicas=None, break_clients=False, organization=None):
238+
def publish_module(self, domain=None, *, clear=True, capture_stderr=True, num_replicas=None, break_clients=False):
240239
publish_output = self.spacetime(
241240
"publish",
242241
*[domain] if domain is not None else [],
@@ -248,7 +247,6 @@ def publish_module(self, domain=None, *, clear=True, capture_stderr=True,
248247
"--yes",
249248
*["--num-replicas", f"{num_replicas}"] if num_replicas is not None else [],
250249
*["--break-clients"] if break_clients else [],
251-
*["--organization", f"{organization}"] if organization is not None else [],
252250
capture_stderr=capture_stderr,
253251
)
254252
self.resolved_identity = re.search(r"identity: ([0-9a-fA-F]+)", publish_output)[1]
@@ -408,7 +406,7 @@ def enterClassContext(cls, cm):
408406
result = cm.__enter__()
409407
cls.addClassCleanup(cm.__exit__, None, None, None)
410408
return result
411-
409+
412410
def assertSql(self, sql: str, expected: str):
413411
"""Assert that executing `sql` produces the expected output."""
414412
self.maxDiff = None

0 commit comments

Comments
 (0)