From f4523de5a4c4a9c04dde239902fbe1b5f77375ef Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Thu, 21 Nov 2024 00:47:44 +0700 Subject: [PATCH] fix db --- .vscode/launch.json | 3 +- api/smm_core.proto | 1 + cmd/smm_core/main.go | 23 ++- internal/app/server.go | 1 + internal/services/requests.restbook | 2 +- internal/services/user/user_service.go | 15 +- ...sql => 20241109180651_add_users_table.sql} | 4 +- .../20241120173848_add_budgets_table.sql | 13 ++ ...> 20241120173924_add_coregories_table.sql} | 5 +- .../20241120174237_add_positions_table.sql | 15 ++ proto/smm_core.pb.go | 138 ++++++++++-------- resources/smm_core.swagger.json | 3 + 12 files changed, 152 insertions(+), 71 deletions(-) rename migrations/{20241109180651_add_user.sql => 20241109180651_add_users_table.sql} (71%) create mode 100644 migrations/20241120173848_add_budgets_table.sql rename migrations/{20241118122922_add_coregories_table.sql => 20241120173924_add_coregories_table.sql} (76%) create mode 100644 migrations/20241120174237_add_positions_table.sql diff --git a/.vscode/launch.json b/.vscode/launch.json index a19b2ad..bdc1c3f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,8 @@ "mode": "debug", "program": "${workspaceFolder}/cmd/smm_core", "env": { - "DATABASE_URL": "user=crab password=crab dbname=smm-core host=localhost port=5432 sslmode=disable" + "DATABASE_URL": "user=crab password=crab dbname=smm-core host=localhost port=5432 sslmode=disable", + "AUTHORIZATION": "Y3JhYjpjcmFi" } }, ] diff --git a/api/smm_core.proto b/api/smm_core.proto index 31f2bd5..81295dd 100644 --- a/api/smm_core.proto +++ b/api/smm_core.proto @@ -49,6 +49,7 @@ message PingRsp {} message CreateUserReq { string username = 1; + string password = 2; } message User { diff --git a/cmd/smm_core/main.go b/cmd/smm_core/main.go index 50f3c88..2b492fe 100644 --- a/cmd/smm_core/main.go +++ b/cmd/smm_core/main.go @@ -14,8 +14,10 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/jackc/pgx/v5/pgxpool" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" proto "git.3crabs.ru/save_my_money/smm_core/proto" ) @@ -38,7 +40,26 @@ func main() { userService := user.NewUserService(dbpool) // Create a gRPC server object - s := grpc.NewServer() + s := grpc.NewServer( + grpc.UnaryInterceptor( + func( + ctx context.Context, + req any, + info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler, + ) (resp any, err error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok || len(md["authorization"]) == 0 { + return nil, status.Errorf(codes.Unauthenticated, "no auth token") + } + authToken := md["authorization"][0] + if authToken != os.Getenv("AUTHORIZATION") { + return nil, status.Errorf(codes.Unauthenticated, "invalid token") + } + return handler(ctx, req) + }, + ), + ) // Attach the Greeter service to the server proto.RegisterSmmCoreServer(s, app.NewServer(categoryService, userService)) // Serve gRPC server diff --git a/internal/app/server.go b/internal/app/server.go index 8b12fe0..de2c23a 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -37,6 +37,7 @@ func (s *Server) AddUser(ctx context.Context, req *proto.CreateUserReq) (*proto. ctx, &user.UserEntity{ Username: req.Username, + Password: req.Password, }, ) if err != nil { diff --git a/internal/services/requests.restbook b/internal/services/requests.restbook index 90ebf1e..5b83627 100644 --- a/internal/services/requests.restbook +++ b/internal/services/requests.restbook @@ -1 +1 @@ -[{"kind":1,"language":"markdown","value":"# Добавление пользователя","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/users\n\n{\n \"username\": \"foo\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Wed, 20 Nov 2024 16:14:45 GMT","Content-Type":"application/json","Content-Length":"25"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","User-Agent":"rest-book","Content-Length":18}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/users","timeout":10000,"headers":{"User-Agent":"rest-book"},"data":{"username":"foo"}},"data":{"id":1,"username":"foo"}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Wed, 20 Nov 2024 16:14:45 GMT","Content-Type":"application/json","Content-Length":"25"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","User-Agent":"rest-book","Content-Length":18}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/users","timeout":10000,"headers":{"User-Agent":"rest-book"},"data":{"username":"foo"}},"data":{"id":1,"username":"foo"}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Добавление категории","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/categories\nUser-Id: 1\n\n{\n \"name\": \"Продукты питания\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":500,"statusText":"Internal Server Error","headers":{"Date":"Wed, 20 Nov 2024 16:25:26 GMT","Content-Type":"application/json","Content-Length":"184"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","User-Id":"2","User-Agent":"axios/0.21.4","Content-Length":42}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/categories","timeout":10000,"headers":{"User-Id":"2"},"data":{"name":"Продукты питания"}},"data":{"code":2,"message":"unable to insert row: ERROR: insert or update on table \"categories\" violates foreign key constraint \"categories_user_id_fkey\" (SQLSTATE 23503)","details":[]}}},{"mime":"text/x-json","value":{"status":500,"statusText":"Internal Server Error","headers":{"Date":"Wed, 20 Nov 2024 16:25:26 GMT","Content-Type":"application/json","Content-Length":"184"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","User-Id":"2","User-Agent":"axios/0.21.4","Content-Length":42}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/categories","timeout":10000,"headers":{"User-Id":"2"},"data":{"name":"Продукты питания"}},"data":{"code":2,"message":"unable to insert row: ERROR: insert or update on table \"categories\" violates foreign key constraint \"categories_user_id_fkey\" (SQLSTATE 23503)","details":[]}}},{"mime":"text/html","value":"[object Object]"}]}] \ No newline at end of file +[{"kind":1,"language":"markdown","value":"# Добавление пользователя","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/users\nauthorization: Y3JhYjpjcmFi\n\n{\n \"username\": \"foo\",\n \"password\": \"bar\"\n}","outputs":[{"mime":"application/vnd.code.notebook.error","value":{"name":"Error","message":"timeout of 10000ms exceeded"}}]},{"kind":1,"language":"markdown","value":"# Добавление категории","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/categories\nUser-Id: 1\n\n{\n \"name\": \"Продукты питания\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":500,"statusText":"Internal Server Error","headers":{"Date":"Wed, 20 Nov 2024 16:25:26 GMT","Content-Type":"application/json","Content-Length":"184"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","User-Id":"2","User-Agent":"axios/0.21.4","Content-Length":42}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/categories","timeout":10000,"headers":{"User-Id":"2"},"data":{"name":"Продукты питания"}},"data":{"code":2,"message":"unable to insert row: ERROR: insert or update on table \"categories\" violates foreign key constraint \"categories_user_id_fkey\" (SQLSTATE 23503)","details":[]}}},{"mime":"text/x-json","value":{"status":500,"statusText":"Internal Server Error","headers":{"Date":"Wed, 20 Nov 2024 16:25:26 GMT","Content-Type":"application/json","Content-Length":"184"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","User-Id":"2","User-Agent":"axios/0.21.4","Content-Length":42}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/categories","timeout":10000,"headers":{"User-Id":"2"},"data":{"name":"Продукты питания"}},"data":{"code":2,"message":"unable to insert row: ERROR: insert or update on table \"categories\" violates foreign key constraint \"categories_user_id_fkey\" (SQLSTATE 23503)","details":[]}}},{"mime":"text/html","value":"[object Object]"}]}] \ No newline at end of file diff --git a/internal/services/user/user_service.go b/internal/services/user/user_service.go index 7276e71..f4ac294 100644 --- a/internal/services/user/user_service.go +++ b/internal/services/user/user_service.go @@ -2,6 +2,8 @@ package user import ( "context" + "crypto/md5" + "encoding/hex" "errors" "fmt" @@ -13,6 +15,7 @@ import ( type UserEntity struct { Id int Username string + Password string } type UsernameAlreadyExistsErr struct{} @@ -34,9 +37,10 @@ func NewUserService( } func (s *UserService) AddUser(ctx context.Context, user *UserEntity) (*UserEntity, error) { - query := `INSERT INTO users (username) VALUES (@username) RETURNING id` + query := `INSERT INTO users (username, password) VALUES (@username, @password) RETURNING id` args := pgx.NamedArgs{ "username": user.Username, + "password": hashPassword(user.Username, user.Password, "crab"), } if err := s.db.QueryRow(ctx, query, args).Scan(&user.Id); err != nil { var pgErr *pgconn.PgError @@ -49,3 +53,12 @@ func (s *UserService) AddUser(ctx context.Context, user *UserEntity) (*UserEntit } return user, nil } + +func hashPassword(username string, password string, salt string) string { + return getMD5Hash(username + password + salt) +} + +func getMD5Hash(text string) string { + hash := md5.Sum([]byte(text)) + return hex.EncodeToString(hash[:]) +} diff --git a/migrations/20241109180651_add_user.sql b/migrations/20241109180651_add_users_table.sql similarity index 71% rename from migrations/20241109180651_add_user.sql rename to migrations/20241109180651_add_users_table.sql index 19fe2f3..82091c8 100644 --- a/migrations/20241109180651_add_user.sql +++ b/migrations/20241109180651_add_users_table.sql @@ -2,7 +2,9 @@ -- +goose StatementBegin CREATE TABLE IF NOT EXISTS users ( id SERIAL PRIMARY KEY, - username TEXT UNIQUE NOT NULL + username TEXT UNIQUE NOT NULL, + password TEXT NOT NULL, + created_at TIMESTAMP ); -- +goose StatementEnd diff --git a/migrations/20241120173848_add_budgets_table.sql b/migrations/20241120173848_add_budgets_table.sql new file mode 100644 index 0000000..f8bfaf5 --- /dev/null +++ b/migrations/20241120173848_add_budgets_table.sql @@ -0,0 +1,13 @@ +-- +goose Up +-- +goose StatementBegin +CREATE TABLE IF NOT EXISTS budgets ( + id SERIAL PRIMARY KEY, + start_day INT NOT NULL, + created_at TIMESTAMP +); +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +DROP TABLE IF EXISTS budgets; +-- +goose StatementEnd diff --git a/migrations/20241118122922_add_coregories_table.sql b/migrations/20241120173924_add_coregories_table.sql similarity index 76% rename from migrations/20241118122922_add_coregories_table.sql rename to migrations/20241120173924_add_coregories_table.sql index b168038..d98ce20 100644 --- a/migrations/20241118122922_add_coregories_table.sql +++ b/migrations/20241120173924_add_coregories_table.sql @@ -3,10 +3,11 @@ CREATE TABLE IF NOT EXISTS categories ( id SERIAL PRIMARY KEY, name TEXT NOT NULL, - user_id INT REFERENCES users(id), + budget_id INT REFERENCES budgets(id), favorite BOOLEAN DEFAULT FALSE, monthly_limit INT DEFAULT 0, - UNIQUE (user_id, name) + UNIQUE (budget_id, name), + created_at TIMESTAMP ); -- +goose StatementEnd diff --git a/migrations/20241120174237_add_positions_table.sql b/migrations/20241120174237_add_positions_table.sql new file mode 100644 index 0000000..cfa7c10 --- /dev/null +++ b/migrations/20241120174237_add_positions_table.sql @@ -0,0 +1,15 @@ +-- +goose Up +-- +goose StatementBegin +CREATE TABLE IF NOT EXISTS positions ( + id SERIAL PRIMARY KEY, + name TEXT NOT NULL, + price INT NOT NULL, + amount FLOAT NOT NULL, + created_at TIMESTAMP +); +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +DROP TABLE IF EXISTS positions; +-- +goose StatementEnd diff --git a/proto/smm_core.pb.go b/proto/smm_core.pb.go index 559880d..f3a14a6 100644 --- a/proto/smm_core.pb.go +++ b/proto/smm_core.pb.go @@ -100,6 +100,7 @@ type CreateUserReq struct { unknownFields protoimpl.UnknownFields Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` } func (x *CreateUserReq) Reset() { @@ -139,6 +140,13 @@ func (x *CreateUserReq) GetUsername() string { return "" } +func (x *CreateUserReq) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + type User struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -492,73 +500,75 @@ var file_smm_core_proto_rawDesc = []byte{ 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x09, 0x0a, 0x07, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x22, 0x09, 0x0a, 0x07, 0x50, 0x69, 0x6e, - 0x67, 0x52, 0x73, 0x70, 0x22, 0x2b, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, + 0x67, 0x52, 0x73, 0x70, 0x22, 0x47, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, - 0x65, 0x22, 0x32, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, - 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, - 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x68, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, - 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, - 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, - 0x78, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, - 0x79, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, - 0x72, 0x69, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, - 0x72, 0x69, 0x74, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, - 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, - 0x74, 0x68, 0x6c, 0x79, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x6f, 0x0a, 0x08, 0x43, 0x61, 0x74, - 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, - 0x6f, 0x72, 0x69, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, - 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, - 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, - 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x2f, 0x0a, 0x11, 0x43, 0x61, - 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, - 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x22, 0x46, 0x0a, 0x0a, 0x43, - 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x0a, 0x63, 0x61, 0x74, - 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, - 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, - 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, - 0x69, 0x65, 0x73, 0x32, 0xd7, 0x03, 0x0a, 0x07, 0x53, 0x6d, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, - 0x47, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, - 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, - 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, - 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x07, 0x12, 0x05, 0x2f, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x51, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x55, - 0x73, 0x65, 0x72, 0x12, 0x1d, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, - 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, - 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, - 0x3a, 0x01, 0x2a, 0x22, 0x06, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x62, 0x0a, 0x0b, 0x41, - 0x64, 0x64, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, - 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, - 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, - 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x3a, - 0x01, 0x2a, 0x22, 0x0b, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, - 0x67, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, - 0x79, 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, - 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, - 0x79, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, - 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x18, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x1a, 0x10, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, - 0x69, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x63, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x43, - 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x32, 0x0a, + 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, + 0x65, 0x22, 0x68, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, + 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x61, + 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, + 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, + 0x79, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, + 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x78, 0x0a, 0x11, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, + 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x6c, 0x69, 0x6d, 0x69, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, + 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x6f, 0x0a, 0x08, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, + 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x6c, 0x69, 0x6d, + 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, + 0x79, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x2f, 0x0a, 0x11, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, + 0x72, 0x79, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, + 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, + 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x22, 0x46, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, + 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, - 0x6f, 0x72, 0x79, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x63, - 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, - 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, - 0x12, 0x0b, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x42, 0x0e, 0x92, - 0x41, 0x00, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x72, 0x79, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x32, + 0xd7, 0x03, 0x0a, 0x07, 0x53, 0x6d, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x47, 0x0a, 0x04, 0x50, + 0x69, 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, + 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, + 0x6e, 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, + 0x70, 0x69, 0x6e, 0x67, 0x12, 0x51, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, 0x72, 0x12, + 0x1d, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x14, + 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x3a, 0x01, 0x2a, 0x22, + 0x06, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x62, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x43, 0x61, + 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, + 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, + 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, + 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, + 0x6f, 0x72, 0x79, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x3a, 0x01, 0x2a, 0x22, 0x0b, + 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x67, 0x0a, 0x0e, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x21, 0x2e, + 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, + 0x1a, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x12, 0x1a, 0x10, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x2f, + 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x63, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, + 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, + 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, + 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, + 0x72, 0x69, 0x65, 0x73, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x12, 0x0b, 0x2f, 0x63, + 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x42, 0x0e, 0x92, 0x41, 0x00, 0x5a, 0x09, + 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/resources/smm_core.swagger.json b/resources/smm_core.swagger.json index ac9b7af..49fb046 100644 --- a/resources/smm_core.swagger.json +++ b/resources/smm_core.swagger.json @@ -263,6 +263,9 @@ "properties": { "username": { "type": "string" + }, + "password": { + "type": "string" } } },