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

implement read-only auth #373

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions crates/y-sweet-core/src/api_types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use serde_json::Value;

#[derive(Serialize)]
pub struct NewDocResponse {
Expand All @@ -27,13 +24,12 @@ impl Authorization {

#[derive(Deserialize)]
#[allow(unused)]
rolyatmax marked this conversation as resolved.
Show resolved Hide resolved
#[serde(default)]
rolyatmax marked this conversation as resolved.
Show resolved Hide resolved
pub struct AuthDocRequest {
#[serde(default = "Authorization::full")]
pub authorization: Authorization,
#[serde(rename = "userId")]
pub user_id: Option<String>,
#[serde(default)]
pub metadata: HashMap<String, Value>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use this at present. And if we did, we'd likely need to encode it into the token which we'd like to avoid since its length is unbounded. Let's just drop this field altogether.

#[serde(skip_serializing_if = "Option::is_none", rename = "validForSeconds")]
pub valid_for_seconds: Option<u64>,
}
Expand All @@ -43,7 +39,6 @@ impl Default for AuthDocRequest {
Self {
authorization: Authorization::Full,
user_id: None,
metadata: HashMap::new(),
valid_for_seconds: None,
}
}
Expand Down
2 changes: 0 additions & 2 deletions crates/y-sweet/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,6 @@ async fn auth_doc(
#[cfg(test)]
mod test {
use super::*;
use std::collections::HashMap;
use y_sweet_core::api_types::Authorization;

#[tokio::test]
Expand Down Expand Up @@ -752,7 +751,6 @@ mod test {
Some(Json(AuthDocRequest {
authorization: Authorization::Full,
user_id: None,
metadata: HashMap::new(),
valid_for_seconds: None,
})),
)
Expand Down
3 changes: 0 additions & 3 deletions js-pkg/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export type AuthDocRequest = {
/** A user ID to associate with the token. Not currently used. */
userId?: string

/** Metadata to associate with the user accessing the document. Not currently used. */
metadata?: Record<string, any>

/** The number of seconds the token should be valid for. */
validForSeconds?: number
}
3 changes: 0 additions & 3 deletions openapi/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,6 @@ components:
userId:
type: string
nullable: true
metadata:
type: object
nullable: true
validForSeconds:
description: |
The duration that the returned token will be valid for, in seconds.
Expand Down