Skip to content

Commit

Permalink
Deprecate hashed_pwd and relax testcase endpoint decoding limit (#85)
Browse files Browse the repository at this point in the history
* relax max frame size for testcase endpoint

* chore(backend)!: deprecated updating password using UserFullInfo
  • Loading branch information
Eason0729 authored Sep 4, 2024
1 parent 4cc275f commit 6767dd2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 0 additions & 1 deletion backend/src/endpoint/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ impl<'a> From<WithAuth<'a, Model>> for UserFullInfo {
let model = value.1;
let writable = Entity::writable(&model, value.0);
UserFullInfo {
hashed_pwd: model.password.clone(),
info: model.into(),
writable,
}
Expand Down
9 changes: 6 additions & 3 deletions backend/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use tonic_web::GrpcWebLayer;
use tower_http::cors::{AllowOrigin, Any, CorsLayer};
use tracing::Instrument;

const MAX_FRAME_SIZE: u32 = 1024 * 1024 * 8;
const MAX_TESTCASE_CODEX_SIZE: usize = 1024 * 1024 * 16;

// from https://docs.rs/tonic-web/0.11.0/src/tonic_web/lib.rs.html#140
const DEFAULT_EXPOSED_HEADERS: [&str; 3] =
Expand Down Expand Up @@ -143,13 +143,16 @@ impl Server {
server
.layer(cors)
.layer(GrpcWebLayer::new())
.max_frame_size(Some(MAX_FRAME_SIZE))
.add_service(ProblemServer::new(self_.clone()))
.add_service(EducationServer::new(self_.clone()))
.add_service(UserServer::new(self_.clone()))
.add_service(TokenServer::new(self_.clone()))
.add_service(ContestServer::new(self_.clone()))
.add_service(TestcaseServer::new(self_.clone()))
.add_service(
TestcaseServer::new(self_.clone())
.max_decoding_message_size(MAX_TESTCASE_CODEX_SIZE)
.max_encoding_message_size(MAX_TESTCASE_CODEX_SIZE),
)
.add_service(SubmitServer::new(self_.clone()))
.add_service(ChatServer::new(self_.clone()))
.add_service(AnnouncementServer::new(self_.clone()))
Expand Down
12 changes: 11 additions & 1 deletion grpc/proto/backend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,13 @@ message ListContestResponse {
message CreateContestRequest {
message Info {
required string title = 1;
// if begin is set, the contest will be open automatically even if contest is private
//
// try to close contest when it's open bacause of time reached will result in end being set to current time
//
// if contest was made public after end, both begin and end timer would be cancel and contest would be immediately visible to anyone
//
// if contest end before it begin, the contest would be public
required google.protobuf.Timestamp begin = 2;
required google.protobuf.Timestamp end = 3;
required string tags = 6;
Expand Down Expand Up @@ -697,6 +704,7 @@ service Contest {
rpc Update(UpdateContestRequest) returns (google.protobuf.Empty);
rpc Remove(RemoveRequest) returns (google.protobuf.Empty);

// public means the contest itself is visible, it may be guarded by password or so
rpc Publish(PublishRequest) returns (google.protobuf.Empty);
rpc Unpublish(PublishRequest) returns (google.protobuf.Empty);

Expand All @@ -711,8 +719,8 @@ message UserInfo {

message UserFullInfo {
required UserInfo info = 1;
required bytes hashed_pwd = 2;
required bool writable = 3;
// require string description = 4;
}

message ListUserResponse {
Expand All @@ -726,6 +734,7 @@ message CreateUserRequest {
required string username = 1;
required string password = 2;
required Role role = 4;
// required string description = 5;
}
required Info info = 1;
// can prevent duplicate request.
Expand All @@ -739,6 +748,7 @@ message UpdateUserRequest {
optional string username = 1;
optional string password = 2;
optional Role role = 3;
// optional string description = 4;
}
required Info info = 1;
required int32 id = 2;
Expand Down

0 comments on commit 6767dd2

Please sign in to comment.