From c54a24a34f014e5a094b32a276d3595d84033deb Mon Sep 17 00:00:00 2001 From: itsscb Date: Thu, 5 Oct 2023 03:20:02 +0200 Subject: [PATCH] add gRPC server and endpoints using protobuf Fixes #6 --- Makefile | 40 +- bff/api/account.go | 3 - bff/api/server.go | 1 - bff/app.env | 3 +- bff/db/sqlc/tx_create_account.go | 10 +- bff/db/sqlc/tx_update_account.go | 17 +- bff/doc/swagger/df.swagger.json | 820 ++++++++++-------- bff/gapi/authorization.go | 54 ++ bff/gapi/converter.go | 29 + bff/gapi/error.go | 30 + bff/gapi/metadata.go | 43 + bff/gapi/rpc_block_session.go | 65 ++ bff/gapi/rpc_create_account.go | 89 ++ bff/gapi/rpc_login.go | 92 ++ bff/gapi/rpc_refresh_token.go | 78 ++ bff/gapi/rpc_update_account.go | 127 +++ bff/gapi/rpc_update_account_privacy.go | 66 ++ bff/gapi/server.go | 56 ++ bff/go.mod | 11 +- bff/go.sum | 23 +- bff/main.go | 77 +- bff/pb/account.pb.go | 345 ++++++++ bff/pb/rpc_block_session.pb.go | 241 +++++ bff/pb/rpc_create_account.pb.go | 351 ++++++++ bff/pb/rpc_login.pb.go | 342 ++++++++ bff/pb/rpc_refresh_token.pb.go | 303 +++++++ bff/pb/rpc_update_account.pb.go | 339 ++++++++ bff/pb/rpc_update_account_privacy.pb.go | 245 ++++++ bff/pb/service_df.pb.go | 162 ++++ bff/pb/service_df.pb.gw.go | 650 ++++++++++++++ bff/pb/service_df_grpc.pb.go | 347 ++++++++ bff/proto/account.proto | 34 + bff/proto/google/api/annotations.proto | 31 + bff/proto/google/api/field_behavior.proto | 104 +++ bff/proto/google/api/http.proto | 379 ++++++++ bff/proto/google/api/httpbody.proto | 81 ++ .../options/annotations.proto | 44 + .../options/openapiv2.proto | 720 +++++++++++++++ bff/proto/rpc_block_session.proto | 43 + bff/proto/rpc_create_account.proto | 58 ++ bff/proto/rpc_login.proto | 61 ++ bff/proto/rpc_refresh_token.proto | 39 + bff/proto/rpc_update_account.proto | 47 + bff/proto/rpc_update_account_privacy.proto | 41 + bff/proto/service_df.proto | 110 +++ bff/util/config.go | 3 +- bff/val/validator.go | 54 ++ 47 files changed, 6510 insertions(+), 398 deletions(-) create mode 100644 bff/gapi/authorization.go create mode 100644 bff/gapi/converter.go create mode 100644 bff/gapi/error.go create mode 100644 bff/gapi/metadata.go create mode 100644 bff/gapi/rpc_block_session.go create mode 100644 bff/gapi/rpc_create_account.go create mode 100644 bff/gapi/rpc_login.go create mode 100644 bff/gapi/rpc_refresh_token.go create mode 100644 bff/gapi/rpc_update_account.go create mode 100644 bff/gapi/rpc_update_account_privacy.go create mode 100644 bff/gapi/server.go create mode 100644 bff/pb/account.pb.go create mode 100644 bff/pb/rpc_block_session.pb.go create mode 100644 bff/pb/rpc_create_account.pb.go create mode 100644 bff/pb/rpc_login.pb.go create mode 100644 bff/pb/rpc_refresh_token.pb.go create mode 100644 bff/pb/rpc_update_account.pb.go create mode 100644 bff/pb/rpc_update_account_privacy.pb.go create mode 100644 bff/pb/service_df.pb.go create mode 100644 bff/pb/service_df.pb.gw.go create mode 100644 bff/pb/service_df_grpc.pb.go create mode 100644 bff/proto/account.proto create mode 100644 bff/proto/google/api/annotations.proto create mode 100644 bff/proto/google/api/field_behavior.proto create mode 100644 bff/proto/google/api/http.proto create mode 100644 bff/proto/google/api/httpbody.proto create mode 100644 bff/proto/protoc-gen-openapiv2/options/annotations.proto create mode 100644 bff/proto/protoc-gen-openapiv2/options/openapiv2.proto create mode 100644 bff/proto/rpc_block_session.proto create mode 100644 bff/proto/rpc_create_account.proto create mode 100644 bff/proto/rpc_login.proto create mode 100644 bff/proto/rpc_refresh_token.proto create mode 100644 bff/proto/rpc_update_account.proto create mode 100644 bff/proto/rpc_update_account_privacy.proto create mode 100644 bff/proto/service_df.proto create mode 100644 bff/val/validator.go diff --git a/Makefile b/Makefile index de49886..fedea46 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,11 @@ DB_URL=postgresql://root:secret@localhost:5432/df?sslmode=disable reset_docker: - docker rm -vf df; docker rmi -f df; docker rm -vf postgres; docker rmi -f postgres; docker rm -vf migrate + docker rm -vf df + docker rmi -f df + docker rm -vf postgres + docker rmi -f postgres + docker rm -vf migrate backend_build: make network; \ @@ -41,21 +45,45 @@ dropdb: docker exec -it postgres dropdb df sqlc: - cd bff && sqlc generate && cd .. + cd bff && \ + sqlc generate && \ + cd .. sqlcinit: + cd bff && \ sqlc init test: - cd bff && go test -v -cover -short -count=1 ./... && cd .. + cd bff && \ + go test -v -cover -short -count=1 ./... \ + && cd .. coverage: - cd bff && go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out && cd .. + cd bff && \ + go test -coverprofile=coverage.out ./... && \ + go tool cover -html=coverage.out && \ + cd .. server: - cd bff && go run main.go && cd .. + cd bff && \ + go run main.go && \ + cd .. mock: cd bff && mockgen -package mockdb -destination db/mock/store.go github.com/itsscb/df/bff/db/sqlc Store && cd .. -.PHONY: postgres migratenew createdb dropdb migrateup migratedown sqlc sqlcinit test server backend_build backend backend-stop reset_docker +proto: + cd bff && \ + rm -f doc/swagger/*.swagger.json && \ + rm -f pb/*.go && \ + protoc --proto_path=proto --go_out=pb --go_opt=paths=source_relative \ + --go-grpc_out=pb --go-grpc_opt=paths=source_relative \ + --openapiv2_out=doc/swagger --openapiv2_opt=allow_merge=true,merge_file_name=df \ + --grpc-gateway_out=pb --grpc-gateway_opt=paths=source_relative \ + ./proto/*.proto + cd .. + +evans: + evans --host localhost --port 9090 --package pb -r repl + +.PHONY: postgres migratenew createdb dropdb migrateup migratedown sqlc sqlcinit test server backend_build backend backend-stop reset_docker proto evans diff --git a/bff/api/account.go b/bff/api/account.go index 238efd4..cdb0d03 100644 --- a/bff/api/account.go +++ b/bff/api/account.go @@ -3,14 +3,12 @@ package api import ( "database/sql" "errors" - "fmt" "net/http" "time" "github.com/gin-gonic/gin" db "github.com/itsscb/df/bff/db/sqlc" "github.com/itsscb/df/bff/token" - "golang.org/x/exp/slog" ) type createAccountRequest struct { @@ -111,7 +109,6 @@ func (server *Server) listAccounts(ctx *gin.Context) { } authPayload := ctx.MustGet(authorizationPayloadKey).(*token.Payload) - slog.Error("auth", "payload", fmt.Sprintf("%#v", authPayload)) account, err := server.store.GetAccountByEmail(ctx, authPayload.Email) if err != nil { diff --git a/bff/api/server.go b/bff/api/server.go index 39fbf29..e13e06d 100644 --- a/bff/api/server.go +++ b/bff/api/server.go @@ -41,7 +41,6 @@ func NewServer(config util.Config, store db.Store, swaggerFS http.FileSystem) (* logLevel := slog.LevelError if config.Environment == "development" { logLevel = slog.LevelDebug - // router.Static("/swagger/", "./doc/swagger/") } if swaggerFS != nil { diff --git a/bff/app.env b/bff/app.env index 3db94b4..c2eed02 100644 --- a/bff/app.env +++ b/bff/app.env @@ -1,6 +1,7 @@ DB_SOURCE=postgresql://root:secret@localhost:5432/df?sslmode=disable DB_DRIVER=postgres -SERVER_ADDRESS=0.0.0.0:8080 +HTTP_SERVER_ADDRESS=0.0.0.0:8080 +GRPC_SERVER_ADDRESS=0.0.0.0:9090 ENVIRONMENT=development LOG_OUTPUT=text ACCESS_TOKEN_DURATION=15m diff --git a/bff/db/sqlc/tx_create_account.go b/bff/db/sqlc/tx_create_account.go index 867f67c..11b996b 100644 --- a/bff/db/sqlc/tx_create_account.go +++ b/bff/db/sqlc/tx_create_account.go @@ -4,8 +4,6 @@ import ( "context" "database/sql" "time" - - "github.com/itsscb/df/bff/util" ) type CreateAccountTxParams struct { @@ -39,10 +37,10 @@ func (store *SQLStore) CreateAccountTx(ctx context.Context, arg CreateAccountTxP } } - arg.Passwordhash, err = util.HashPassword(arg.Passwordhash) - if err != nil { - return Account{}, nil - } + // arg.Passwordhash, err = util.HashPassword(arg.Passwordhash) + // if err != nil { + // return Account{}, nil + // } err = store.execTx(ctx, func(q *Queries) error { var err error diff --git a/bff/db/sqlc/tx_update_account.go b/bff/db/sqlc/tx_update_account.go index 4c3766e..3132c9d 100644 --- a/bff/db/sqlc/tx_update_account.go +++ b/bff/db/sqlc/tx_update_account.go @@ -3,8 +3,6 @@ package db import ( "context" "database/sql" - - "github.com/itsscb/df/bff/util" ) type UpdateAccountTxParams struct { @@ -28,16 +26,15 @@ type UpdateAccountTxResult struct { func (store *SQLStore) UpdateAccountTx(ctx context.Context, arg UpdateAccountTxParams) (Account, error) { var result UpdateAccountTxResult - var err error - if arg.Passwordhash.Valid { - arg.Passwordhash.String, err = util.HashPassword(arg.Passwordhash.String) - if err != nil { - return Account{}, nil - } - } + // if arg.Passwordhash.Valid { + // arg.Passwordhash.String, err = util.HashPassword(arg.Passwordhash.String) + // if err != nil { + // return Account{}, nil + // } + // } - err = store.execTx(ctx, func(q *Queries) error { + err := store.execTx(ctx, func(q *Queries) error { var err error result.Account, err = q.UpdateAccount(ctx, UpdateAccountParams(arg)) return err diff --git a/bff/doc/swagger/df.swagger.json b/bff/doc/swagger/df.swagger.json index 50c7c7e..8de6aa5 100644 --- a/bff/doc/swagger/df.swagger.json +++ b/bff/doc/swagger/df.swagger.json @@ -1,5 +1,5 @@ { - "openapi": "3.1.0", + "swagger": "2.0", "info": { "title": "df API", "version": "1.0", @@ -11,9 +11,18 @@ }, "tags": [ { - "name": "df" + "name": "Sessions", + "description": "Sessions" + }, + { + "name": "Accounts", + "description": "Account" } ], + "schemes": [ + "http", + "https" + ], "consumes": [ "application/json" ], @@ -21,25 +30,14 @@ "application/json" ], "paths": { - "/accounts/{id}": { - "get": { - "security": [ - { - "bearerAuth": [] - } - ], - "summary": "Get account", - "description": "Use this API to get a new account", - "operationId": "df_GetAccount", + "/v1/block_session": { + "post": { + "operationId": "Sessions_BlockSession", "responses": { "200": { "description": "A successful response.", - "content": { - "application/json": { - "schema": { - "$ref": "#/definitions/GetAccountResponse" - } - } + "schema": { + "$ref": "#/definitions/pbBlockSessionResponse" } }, "default": { @@ -51,192 +49,33 @@ }, "parameters": [ { - "name": "id", - "in": "path", + "name": "body", + "description": "Block a Session", + "in": "body", "required": true, "schema": { - "$ref": "#/definitions/GetAccountRequest" - } - } - ], - "tags": [ - "df" - ] - } - }, - "/accounts": { - "post": { - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "$ref": "#/definitions/CreateAccountRequest" - } - } - } - }, - "summary": "Create new account", - "description": "Use this API to create a new account", - "operationId": "df_CreateAccount", - "responses": { - "200": { - "description": "A successful response.", - "content": { - "application/json": { - "schema": { - "$ref": "#/definitions/CreateAccountResponse" - } - } - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "$ref": "#/definitions/CreateAccountRequest" + "$ref": "#/definitions/pbBlockSessionRequest" } } ], "tags": [ - "df" - ] - }, - "put": { - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "$ref": "#/definitions/UpdateAccountRequest" - } - } - } - }, + "Sessions" + ], "security": [ - { - "bearerAuth": [] - } - ], - "summary": "Update account", - "description": "Use this API to update account", - "operationId": "df_UpdateAccount", - "responses": { - "200": { - "description": "A successful response.", - "content": { - "application/json": { - "schema": { - "$ref": "#/definitions/UpdateAccountResponse" - } - } - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ { - "name": "body", - "in": "body", - "schema": { - "$ref": "#/definitions/UpdateAccountRequest" - } + "BearerAuth": [] } - ], - "tags": [ - "df" ] } }, - "/accounts/privacy": { - "put": { - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "$ref": "#/definitions/UpdateAccountPrivacyRequest" - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "summary": "Update account privacy settings", - "description": "Use this API to update account privacy settings", - "operationId": "df_UpdateAccountPrivacy", - "responses": { - "200": { - "description": "A successful response.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Account" - } - } - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "schema": { - "$ref": "#/definitions/UpdateAccountPrivacyRequest" - } - } - ], - "tags": [ - "df" - ] - } - }, - "/login": { + "/v1/create_account": { "post": { - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "$ref": "#/definitions/LoginAccountRequest" - } - } - } - }, - "summary": "Login account", - "description": "Use this API to login account and get access token \u0026 refresh token", - "operationId": "df_LoginAccount", + "operationId": "Accounts_CreateAccount", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/LoginAccountResponse" + "$ref": "#/definitions/pbCreateAccountResponse" } }, "default": { @@ -249,143 +88,200 @@ "parameters": [ { "name": "body", + "description": "Create an Account", "in": "body", - "schema": { - "$ref": "#/definitions/LoginAccountRequest" + "required": true, + "schema": { + "$ref": "#/definitions/pbCreateAccountRequest" } } ], "tags": [ - "df" + "Accounts" ] } - } - }, - "security": { - "bearerAuth": [] - }, - "components": { - "securitySchemes": { - "bearerAuth": { - "type": "http", - "scheme": "bearer", - "bearerFormat": "paseto", - "in": "header" + }, + "/v1/login": { + "post": { + "operationId": "Sessions_Login", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbLoginResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "description": "Login an Account", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbLoginRequest" + } + } + ], + "tags": [ + "Sessions" + ] } }, - "schemas": { - "Account": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "email": { - "type": "string" - }, - "passwordhash": { - "type": "string", - "format": "password" - }, - "permission_level": { - "type": "integer" - }, - "privacy_accepted": { - "type": "object", - "properties": { - "Bool": { - "type": "boolean" - }, - "Valid": { - "type": "boolean" - } + "/v1/refresh_token": { + "post": { + "operationId": "Sessions_RefreshToken", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbRefreshTokenResponse" } }, - "privacy_accepted_date": { - "type": "object", - "properties": { - "Time": { - "type":"string", - "format": "date-time" - }, - "Valid": { - "type": "boolean" - } + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" } - }, - "phone": { - "type": "object", - "properties": { - "String": { - "type": "string" - }, - "Valid": { - "type": "boolean" - } - } - }, - "firstname": { - "type": "string" - }, - "lastname": { - "type": "string" - }, - "birthday": { - "type":"string", - "format": "date-time" - }, - "street": { - "type": "string" - }, - "city": { - "type": "string" - }, - "zip": { - "type": "string" - }, - "country": { - "type": "string" - }, - "creator": { - "type": "string" - }, - "created": { - "type":"string", - "format": "date-time" - }, - "changer": { - "type": "string" - }, - "changed": { - "type":"string", - "format": "date-time" } - } + }, + "parameters": [ + { + "name": "body", + "description": "Get a new Access Token by submitting the Refresh Token", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbRefreshTokenRequest" + } + } + ], + "tags": [ + "Sessions" + ] + } + }, + "/v1/update_account": { + "post": { + "operationId": "Accounts_UpdateAccount", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbUpdateAccountResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "description": "Update an Account", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbUpdateAccountRequest" + } + } + ], + "tags": [ + "Accounts" + ], + "security": [ + { + "BearerAuth": [] + } + ] + } + }, + "/v1/update_account_privacy": { + "post": { + "operationId": "Accounts_UpdateAccountPrivacy", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/pbUpdateAccountPrivacyResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "description": "Update the Privacy Consent of an Account", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/pbUpdateAccountPrivacyRequest" + } + } + ], + "tags": [ + "Accounts" + ], + "security": [ + { + "BearerAuth": [] + } + ] } } }, "definitions": { - "CreateAccountRequest": { - "required": [ - "firstname", - "lastname", - "city", - "zip", - "street", - "country", - "email", - "password", - "birthday" - ], + "pbAccount": { "type": "object", + "example": { + "id": 185, + "email": "john.doe@example.com", + "firstname": "John", + "lastname": "Doe", + "phone": "", + "street": "Death Star 2", + "zip": "0815", + "city": "New York", + "country": "USA", + "birthday": "1990-10-05T00:00:0Z", + "privacy_accepted": false, + "privacy_accepted_date": "0001-01-01T00:00:00Z", + "creator": "john.doe@example.com", + "created": "2023-10-05T02:30:53Z", + "changer": "john.doe@example.com", + "changed": "2023-10-05T02:30:53Z" + }, "properties": { + "id": { + "type": "string", + "format": "int64" + }, + "email": { + "type": "string" + }, "firstname": { "type": "string" }, "lastname": { "type": "string" }, + "street": { + "type": "string" + }, "city": { "type": "string" }, @@ -395,105 +291,293 @@ "country": { "type": "string" }, - "street": { - "type": "string" - }, "birthday": { - "type":"string", + "type": "string", "format": "date-time" }, "phone": { "type": "string" }, + "privacyAccepted": { + "type": "boolean" + }, + "privacyAcceptedDate": { + "type": "string", + "format": "date-time" + }, + "permissionLevel": { + "type": "integer", + "format": "int32" + }, + "creator": { + "type": "string" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "changer": { + "type": "string" + }, + "changed": { + "type": "string", + "format": "date-time" + } + }, + "title": "Account" + }, + "pbBlockSessionRequest": { + "type": "object", + "example": { + "session_id": "5e1d67da-7c9b-4365-a4d5-3cc0a051241e" + }, + "properties": { + "sessionId": { + "type": "string", + "format": "uuid", + "example": "5e1d67da-7c9b-4365-a4d5-3cc0a051241e" + } + }, + "description": "Block a Session", + "title": "Block Session", + "required": [ + "sessionId" + ] + }, + "pbBlockSessionResponse": { + "type": "object", + "example": { + "session_id": "5e1d67da-7c9b-4365-a4d5-3cc0a051241e", + "blocked": true + }, + "properties": { + "sessionId": { + "type": "string", + "format": "uuid", + "example": "5e1d67da-7c9b-4365-a4d5-3cc0a051241e" + }, + "blocked": { + "type": "boolean", + "example": true + } + }, + "title": "Blocked Session" + }, + "pbCreateAccountRequest": { + "type": "object", + "example": { + "email": "john.doe@example.com", + "password": "MayTheForceBeWithYou!", + "firstname": "John", + "lastname": "Doe", + "street": "Main Street 1", + "zip": "0815", + "city": "New York", + "country": "USA", + "birthday": "1990-10-05T00:00:0Z" + }, + "properties": { "email": { "type": "string" }, "password": { + "type": "string" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "street": { + "type": "string" + }, + "city": { + "type": "string" + }, + "zip": { + "type": "string" + }, + "country": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "birthday": { "type": "string", - "format": "password" + "format": "date-time", + "example": "1990-10-05T00:00:0Z" + }, + "privacyAccepted": { + "type": "boolean", + "example": true } - } - }, - "CreateAccountResponse": { - "type": "object", - "properties": { - "account": { - "$ref": "#/components/schemas/Account" - } - } - }, - "GetAccountRequest": { + }, + "description": "Create an Account", + "title": "Create Account", "required": [ - "id" - ], - "type": "integer", - "format": "int64" + "email", + "password", + "firstname", + "lastname", + "street", + "city", + "zip", + "country", + "birthday" + ] }, - "GetAccountResponse": { + "pbCreateAccountResponse": { "type": "object", "properties": { "account": { - "$ref": "#/components/schemas/Account" + "$ref": "#/definitions/pbAccount" } - } + }, + "description": "Returns the created Account", + "title": "Created Account" }, - "LoginAccountRequest": { + "pbLoginRequest": { + "type": "object", + "example": { + "email": "john.doe@example.com", + "password": "MayTheForceBeWithYou!" + }, + "properties": { + "email": { + "type": "string", + "format": "email", + "example": "john.doe@example.com" + }, + "password": { + "type": "string", + "format": "password", + "example": "MayTheForceBeWithYou!" + } + }, + "description": "Login an Account", + "title": "Login", "required": [ "email", "password" - ], + ] + }, + "pbLoginResponse": { "type": "object", "properties": { + "sessionId": { + "type": "string", + "format": "uuid", + "example": "5e1d67da-7c9b-4365-a4d5-3cc0a051241e" + }, + "accessToken": { + "type": "string", + "example": "v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA1VDAxOjE3OjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiZjlhMjE2OWQtMWYxYS00YThiLTgzZWEtNzkxMzY5YjY3ZmYxIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9Ah0bVbx9S1LR-pf8hLWVRQPUfK9zrHZvA7ApJ5aZXwhA7H1j-kHhccBjOAGYXZQT-ts7Jq3SJlzo5vtUjGBtDg" + }, + "accessTokenExpiresAt": { + "type": "string", + "format": "date-time" + }, + "refreshToken": { + "type": "string", + "example": "v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA2VDAxOjAyOjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiNWUxZDY3ZGEtN2M5Yi00MzY1LWE0ZDUtM2NjMGEwNTEyNDFlIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9BoX36w0po1vvHSjsBP_KWeFxV1xRbQayqbJuIoK2jKqy1Bt2RoHyJbLoCEO15CRT5DnQ6P0AHlBzjsXt61aDDw" + }, + "refreshTokenExpiresAt": { + "type": "string", + "format": "date-time" + }, "email": { "type": "string", - "format": "email" - }, - "password": { - "type": "string", - "format": "password" + "format": "email", + "example": "john.doe@example.com" } - } + }, + "title": "Login Response" }, - "UpdateAccountPrivacyRequest": { + "pbRefreshTokenRequest": { + "type": "object", + "example": { + "refresh_token": "v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA2VDAxOjAyOjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiNWUxZDY3ZGEtN2M5Yi00MzY1LWE0ZDUtM2NjMGEwNTEyNDFlIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9BoX36w0po1vvHSjsBP_KWeFxV1xRbQayqbJuIoK2jKqy1Bt2RoHyJbLoCEO15CRT5DnQ6P0AHlBzjsXt61aDDw" + }, + "properties": { + "refreshToken": { + "type": "string", + "example": "v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA2VDAxOjAyOjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiNWUxZDY3ZGEtN2M5Yi00MzY1LWE0ZDUtM2NjMGEwNTEyNDFlIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9BoX36w0po1vvHSjsBP_KWeFxV1xRbQayqbJuIoK2jKqy1Bt2RoHyJbLoCEO15CRT5DnQ6P0AHlBzjsXt61aDDw", + "title": "Refresh Token" + } + }, + "description": "Get a new Access Token by submitting the Refresh Token", + "title": "Refresh Token Request", "required": [ - "id" - ], + "refreshToken" + ] + }, + "pbRefreshTokenResponse": { "type": "object", "properties": { - "id": { - "type": "integer", - "format": "int64" + "accessToken": { + "type": "string", + "example": "v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA1VDAxOjE3OjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiZjlhMjE2OWQtMWYxYS00YThiLTgzZWEtNzkxMzY5YjY3ZmYxIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9Ah0bVbx9S1LR-pf8hLWVRQPUfK9zrHZvA7ApJ5aZXwhA7H1j-kHhccBjOAGYXZQT-ts7Jq3SJlzo5vtUjGBtDg", + "title": "Access Token" }, - "privacy_accepted": { - "type": "boolean" + "accessTokenExpiresAt": { + "type": "string", + "format": "date-time" } - } + }, + "title": "Refresh Token Response" }, - "UpdateAccountPrivacyResponse": { + "pbUpdateAccountPrivacyRequest": { + "type": "object", + "example": { + "id": 185, + "privacy_accepted": true + }, + "properties": { + "id": { + "type": "string", + "format": "int64", + "example": 185 + }, + "privacyAccepted": { + "type": "boolean", + "example": true + } + }, + "description": "Update the Privacy Consent of an Account", + "title": "Update Account Privacy Consent", + "required": [ + "id", + "privacyAccepted" + ] + }, + "pbUpdateAccountPrivacyResponse": { "type": "object", "properties": { "account": { - "$ref": "#/components/schemas/Account" + "$ref": "#/definitions/pbAccount", + "title": "Updated Account" } - } + }, + "title": "Update Account Privacy Response" }, - "UpdateAccountRequest": { - "required": [ - "id" - ], + "pbUpdateAccountRequest": { "type": "object", + "example": { + "id": 195, + "street": "Death Star 2" + }, "properties": { "id": { - "type": "integer", + "type": "string", "format": "int64" }, - "new_password": { - "type": "string", - "format": "password" - }, "email": { - "type": "string", - "format": "email" + "type": "string" + }, + "password": { + "type": "string" }, "firstname": { "type": "string" @@ -501,7 +585,7 @@ "lastname": { "type": "string" }, - "phone": { + "street": { "type": "string" }, "city": { @@ -510,25 +594,33 @@ "zip": { "type": "string" }, - "street": { + "country": { "type": "string" }, - "country": { + "phone": { "type": "string" }, "birthday": { "type": "string", - "format": "date-time" + "format": "date-time", + "example": "1990-10-05T00:00:0Z" } - } + }, + "description": "Update an Account", + "title": "Update Account", + "required": [ + "id" + ] }, - "UpdateAccountResponse": { + "pbUpdateAccountResponse": { "type": "object", "properties": { "account": { - "$ref": "#/components/schemas/Account" + "$ref": "#/definitions/pbAccount" } - } + }, + "description": "Returns the updated Account", + "title": "Updated Account" }, "protobufAny": { "type": "object", @@ -552,10 +644,16 @@ "details": { "type": "array", "items": { + "type": "object", "$ref": "#/definitions/protobufAny" } } } } + }, + "securityDefinitions": { + "BearerAuth": { + "type": "apiKey" + } } } diff --git a/bff/gapi/authorization.go b/bff/gapi/authorization.go new file mode 100644 index 0000000..266afe1 --- /dev/null +++ b/bff/gapi/authorization.go @@ -0,0 +1,54 @@ +package gapi + +import ( + "context" + "fmt" + "strings" + + "github.com/itsscb/df/bff/token" + "google.golang.org/grpc/metadata" +) + +const ( + authorizationHeader = "authorization" + authorizationBearer = "bearer" +) + +func (server *Server) authorizeUser(ctx context.Context) (*token.Payload, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return nil, fmt.Errorf("missing metadata") + } + + values := md.Get(authorizationHeader) + if len(values) == 0 { + return nil, fmt.Errorf("missing authorization header") + } + + authHeader := values[0] + fields := strings.Fields(authHeader) + if len(fields) < 2 { + return nil, fmt.Errorf("invalid authorization header format") + } + + authType := strings.ToLower(fields[0]) + if authType != authorizationBearer { + return nil, fmt.Errorf("unsupported authorization type: %s", authType) + } + + accessToken := fields[1] + payload, err := server.tokenMaker.VerifyToken(accessToken) + if err != nil { + return nil, fmt.Errorf("invalid access token: %s", err) + } + + return payload, nil +} + +func (server *Server) isAdmin(ctx context.Context, payload *token.Payload) bool { + acc, err := server.store.GetAccountByEmail(ctx, payload.Email) + if err != nil { + return false + } + return acc.PermissionLevel < 1 +} diff --git a/bff/gapi/converter.go b/bff/gapi/converter.go new file mode 100644 index 0000000..bf014c4 --- /dev/null +++ b/bff/gapi/converter.go @@ -0,0 +1,29 @@ +package gapi + +import ( + db "github.com/itsscb/df/bff/db/sqlc" + "github.com/itsscb/df/bff/pb" + "google.golang.org/protobuf/types/known/timestamppb" +) + +func convertAccount(user db.Account) *pb.Account { + return &pb.Account{ + Id: user.ID, + PermissionLevel: user.PermissionLevel, + Email: user.Email, + Firstname: user.Firstname, + Lastname: user.Lastname, + City: user.City, + Street: user.Street, + Zip: user.Zip, + Country: user.Country, + Creator: user.Creator, + Changer: user.Changer, + PrivacyAccepted: user.PrivacyAccepted.Bool, + PrivacyAcceptedDate: timestamppb.New(user.PrivacyAcceptedDate.Time), + Birthday: timestamppb.New(user.Birthday), + Created: timestamppb.New(user.Created), + Changed: timestamppb.New(user.Changed), + Phone: user.Phone.String, + } +} diff --git a/bff/gapi/error.go b/bff/gapi/error.go new file mode 100644 index 0000000..b3b6db5 --- /dev/null +++ b/bff/gapi/error.go @@ -0,0 +1,30 @@ +package gapi + +import ( + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func fieldViolation(field string, err error) *errdetails.BadRequest_FieldViolation { + return &errdetails.BadRequest_FieldViolation{ + Field: field, + Description: err.Error(), + } +} + +func invalidArgumentError(violations []*errdetails.BadRequest_FieldViolation) error { + badRequest := &errdetails.BadRequest{FieldViolations: violations} + statusInvalid := status.New(codes.InvalidArgument, "invalid parameters") + + statusDetails, err := statusInvalid.WithDetails(badRequest) + if err != nil { + return statusInvalid.Err() + } + + return statusDetails.Err() +} + +func unauthenticatedError(err error) error { + return status.Errorf(codes.Unauthenticated, "unauthorized: %s", err) +} diff --git a/bff/gapi/metadata.go b/bff/gapi/metadata.go new file mode 100644 index 0000000..3be0345 --- /dev/null +++ b/bff/gapi/metadata.go @@ -0,0 +1,43 @@ +package gapi + +import ( + "context" + + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" +) + +const ( + grpcGatewayUserAgentHeader = "grpcgateway-user-agent" + userAgentHeader = "user-agent" + xForwardedForHeader = "x-forwarded-for" +) + +type Metadata struct { + UserAgent string + ClientIP string +} + +func (server *Server) extractMetadata(ctx context.Context) *Metadata { + mtdt := &Metadata{} + + if md, ok := metadata.FromIncomingContext(ctx); ok { + if userAgents := md.Get(grpcGatewayUserAgentHeader); len(userAgents) > 0 { + mtdt.UserAgent = userAgents[0] + } + + if userAgents := md.Get(userAgentHeader); len(userAgents) > 0 { + mtdt.UserAgent = userAgents[0] + } + + if clientIPs := md.Get(xForwardedForHeader); len(clientIPs) > 0 { + mtdt.ClientIP = clientIPs[0] + } + } + + if p, ok := peer.FromContext(ctx); ok { + mtdt.ClientIP = p.Addr.String() + } + + return mtdt +} diff --git a/bff/gapi/rpc_block_session.go b/bff/gapi/rpc_block_session.go new file mode 100644 index 0000000..f4b14fa --- /dev/null +++ b/bff/gapi/rpc_block_session.go @@ -0,0 +1,65 @@ +package gapi + +import ( + "context" + "database/sql" + "errors" + + "github.com/google/uuid" + "github.com/itsscb/df/bff/pb" + "github.com/itsscb/df/bff/val" + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (server *Server) BlockSession(ctx context.Context, req *pb.BlockSessionRequest) (*pb.BlockSessionResponse, error) { + authPayload, err := server.authorizeUser(ctx) + if err != nil { + return nil, unauthenticatedError(err) + } + + violations := validateBlockSessionRequest(req) + if violations != nil { + return nil, invalidArgumentError(violations) + } + + uid := uuid.MustParse(req.GetSessionId()) + session, err := server.store.GetSession(ctx, uid) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, status.Errorf(codes.NotFound, "session not found") + } + return nil, status.Errorf(codes.Internal, "failed to get session") + } + + if session.Email != authPayload.Email { + if !server.isAdmin(ctx, authPayload) { + return nil, status.Error(codes.NotFound, "session not found") + } + } + + if session.IsBlocked { + return nil, status.Errorf(codes.OK, "session already blocked") + } + + err = server.store.BlockSession(ctx, uid) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to block session") + + } + + rsp := &pb.BlockSessionResponse{ + SessionId: uid.String(), + Blocked: true, + } + return rsp, nil +} + +func validateBlockSessionRequest(req *pb.BlockSessionRequest) (violations []*errdetails.BadRequest_FieldViolation) { + if err := val.ValidateString(req.GetSessionId(), 200, 400); err != nil { + violations = append(violations, fieldViolation("session_id", err)) + } + + return violations +} diff --git a/bff/gapi/rpc_create_account.go b/bff/gapi/rpc_create_account.go new file mode 100644 index 0000000..354f5ce --- /dev/null +++ b/bff/gapi/rpc_create_account.go @@ -0,0 +1,89 @@ +package gapi + +import ( + "context" + "database/sql" + "errors" + "log" + + db "github.com/itsscb/df/bff/db/sqlc" + "github.com/itsscb/df/bff/pb" + "github.com/itsscb/df/bff/util" + "github.com/itsscb/df/bff/val" + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (server *Server) CreateAccount(ctx context.Context, req *pb.CreateAccountRequest) (*pb.CreateAccountResponse, error) { + violations := validateCreateAccountRequest(req) + if violations != nil { + return nil, invalidArgumentError(violations) + } + + hashedPassword, err := util.HashPassword(req.GetPassword()) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to hash password: %s", err) + } + + arg := db.CreateAccountTxParams{ + Passwordhash: hashedPassword, + PrivacyAccepted: sql.NullBool{ + Valid: true, + Bool: req.GetPrivacyAccepted(), + }, + Firstname: req.GetFirstname(), + Lastname: req.GetLastname(), + Birthday: req.GetBirthday().AsTime(), + Email: req.GetEmail(), + City: req.GetCity(), + Zip: req.GetZip(), + Street: req.GetStreet(), + Country: req.GetCountry(), + Creator: req.GetEmail(), + Phone: sql.NullString{ + Valid: req.GetPhone() != "", + String: req.GetPhone(), + }, + } + + account, err := server.store.CreateAccountTx(ctx, arg) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to create account: %s", err) + } + + rsp := &pb.CreateAccountResponse{ + Account: convertAccount(account), + } + + return rsp, nil +} + +func validateCreateAccountRequest(req *pb.CreateAccountRequest) (violations []*errdetails.BadRequest_FieldViolation) { + if err := val.ValidateEmail(req.GetEmail()); err != nil { + violations = append(violations, fieldViolation("email", err)) + } + + if err := val.ValidatePassword(req.GetPassword()); err != nil { + log.Println(req.GetPassword(), len(req.GetPassword())) + violations = append(violations, fieldViolation("password", err)) + } + + if err := val.ValidateName(req.GetFirstname()); err != nil { + violations = append(violations, fieldViolation("first_name", err)) + } + + if err := val.ValidateName(req.GetLastname()); err != nil { + violations = append(violations, fieldViolation("last_name", err)) + } + + if err := val.ValidateName(req.GetCity()); err != nil { + violations = append(violations, fieldViolation("city", err)) + } + + if len(req.GetZip()) < 4 { + violations = append(violations, fieldViolation("zip", errors.New("must be at least 4 characters long"))) + } + + return violations +} diff --git a/bff/gapi/rpc_login.go b/bff/gapi/rpc_login.go new file mode 100644 index 0000000..dced26a --- /dev/null +++ b/bff/gapi/rpc_login.go @@ -0,0 +1,92 @@ +package gapi + +import ( + "context" + "database/sql" + "errors" + + db "github.com/itsscb/df/bff/db/sqlc" + "github.com/itsscb/df/bff/pb" + "github.com/itsscb/df/bff/util" + "github.com/itsscb/df/bff/val" + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +func (server *Server) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error) { + violations := validateLoginRequest(req) + if violations != nil { + return nil, invalidArgumentError(violations) + } + + account, err := server.store.GetAccountByEmail(ctx, req.GetEmail()) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, status.Error(codes.NotFound, "account not found") + + } + return nil, status.Error(codes.Internal, "failed to find account") + } + + err = util.CheckPassword(req.GetPassword(), account.Passwordhash) + if err != nil { + return nil, status.Error(codes.PermissionDenied, "invalid password") + } + + accessToken, accessPayload, err := server.tokenMaker.CreateToken( + account.Email, + server.config.AccessTokenDuration, + ) + if err != nil { + return nil, status.Error(codes.Internal, "failed to create access token") + } + + refreshToken, refreshPayload, err := server.tokenMaker.CreateToken( + account.Email, + server.config.RefreshTokenDuration, + ) + if err != nil { + return nil, status.Error(codes.Internal, "failed to create refresh token") + + } + + mtdt := server.extractMetadata(ctx) + + session, err := server.store.CreateSession(ctx, db.CreateSessionParams{ + ID: refreshPayload.ID, + Email: account.Email, + RefreshToken: refreshToken, + UserAgent: mtdt.UserAgent, + ClientIp: mtdt.ClientIP, + IsBlocked: false, + ExpiresAt: refreshPayload.ExpiredAt, + }) + if err != nil { + return nil, status.Error(codes.Internal, "failed to create session") + + } + + rsp := &pb.LoginResponse{ + SessionId: session.ID.String(), + AccessToken: accessToken, + AccessTokenExpiresAt: timestamppb.New(accessPayload.ExpiredAt), + RefreshToken: refreshToken, + RefreshTokenExpiresAt: timestamppb.New(refreshPayload.ExpiredAt), + Email: account.Email, + } + return rsp, nil +} + +func validateLoginRequest(req *pb.LoginRequest) (violations []*errdetails.BadRequest_FieldViolation) { + if err := val.ValidateEmail(req.GetEmail()); err != nil { + violations = append(violations, fieldViolation("email", err)) + } + + if err := val.ValidatePassword(req.GetPassword()); err != nil { + violations = append(violations, fieldViolation("password", err)) + } + + return violations +} diff --git a/bff/gapi/rpc_refresh_token.go b/bff/gapi/rpc_refresh_token.go new file mode 100644 index 0000000..38f6194 --- /dev/null +++ b/bff/gapi/rpc_refresh_token.go @@ -0,0 +1,78 @@ +package gapi + +import ( + "context" + "database/sql" + "errors" + "log" + "time" + + "github.com/itsscb/df/bff/pb" + "github.com/itsscb/df/bff/val" + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +func (server *Server) RefreshToken(ctx context.Context, req *pb.RefreshTokenRequest) (*pb.RefreshTokenResponse, error) { + violations := validateRefreshTokenRequest(req) + if violations != nil { + return nil, invalidArgumentError(violations) + } + + log.Println(req.GetRefreshToken(), len(req.GetRefreshToken())) + refreshPayload, err := server.tokenMaker.VerifyToken(req.GetRefreshToken()) + if err != nil { + return nil, status.Error(codes.PermissionDenied, "invalid session token") + + } + + session, err := server.store.GetSession(ctx, refreshPayload.ID) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, status.Error(codes.NotFound, "session not found") + } + return nil, status.Error(codes.Internal, "cannot find session") + } + + if session.IsBlocked { + return nil, status.Error(codes.PermissionDenied, "session is blocked") + } + + if session.Email != refreshPayload.Email { + return nil, status.Error(codes.PermissionDenied, "invalid account session") + + } + + if session.RefreshToken != req.RefreshToken { + return nil, status.Error(codes.PermissionDenied, "mismatched session token") + + } + + if time.Now().After(session.ExpiresAt) { + return nil, status.Error(codes.PermissionDenied, "session expired") + } + + accessToken, accessPayload, err := server.tokenMaker.CreateToken( + refreshPayload.Email, + server.config.AccessTokenDuration, + ) + if err != nil { + return nil, status.Error(codes.Internal, "cannot create session token") + } + + rsp := &pb.RefreshTokenResponse{ + AccessToken: accessToken, + AccessTokenExpiresAt: timestamppb.New(accessPayload.ExpiredAt), + } + return rsp, nil +} + +func validateRefreshTokenRequest(req *pb.RefreshTokenRequest) (violations []*errdetails.BadRequest_FieldViolation) { + if err := val.ValidateString(req.GetRefreshToken(), 200, 400); err != nil { + violations = append(violations, fieldViolation("refresh_token", err)) + } + + return violations +} diff --git a/bff/gapi/rpc_update_account.go b/bff/gapi/rpc_update_account.go new file mode 100644 index 0000000..186200e --- /dev/null +++ b/bff/gapi/rpc_update_account.go @@ -0,0 +1,127 @@ +package gapi + +import ( + "context" + "database/sql" + + db "github.com/itsscb/df/bff/db/sqlc" + "github.com/itsscb/df/bff/pb" + "github.com/itsscb/df/bff/util" + "github.com/itsscb/df/bff/val" + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (server *Server) UpdateAccount(ctx context.Context, req *pb.UpdateAccountRequest) (*pb.UpdateAccountResponse, error) { + authPayload, err := server.authorizeUser(ctx) + if err != nil { + return nil, unauthenticatedError(err) + } + + violations := validateUpdateAccountRequest(req) + if violations != nil { + return nil, invalidArgumentError(violations) + } + + if authPayload.Email != req.GetEmail() { + if !server.isAdmin(ctx, authPayload) { + return nil, status.Error(codes.NotFound, "account not found") + } + } + + arg := db.UpdateAccountTxParams{ + Changer: authPayload.Email, + Email: sql.NullString{ + Valid: req.GetEmail() != "", + String: req.GetEmail(), + }, + Firstname: sql.NullString{ + Valid: req.GetFirstname() != "", + String: req.GetFirstname(), + }, + Lastname: sql.NullString{ + Valid: req.GetLastname() != "", + String: req.GetLastname(), + }, + City: sql.NullString{ + Valid: req.GetCity() != "", + String: req.GetCity(), + }, + Zip: sql.NullString{ + Valid: req.GetZip() != "", + String: req.GetZip(), + }, + Street: sql.NullString{ + Valid: req.GetStreet() != "", + String: req.GetStreet(), + }, + Country: sql.NullString{ + Valid: req.GetCountry() != "", + String: req.GetCountry(), + }, + Phone: sql.NullString{ + Valid: req.GetPhone() != "", + String: req.GetPhone(), + }, + Birthday: sql.NullTime{ + Valid: req.GetBirthday().IsValid(), + Time: req.GetBirthday().AsTime(), + }, + } + + if req.Password != nil { + hashedPassword, err := util.HashPassword(req.GetPassword()) + if err != nil { + return nil, status.Error(codes.Internal, "failed to hash password") + } + + arg.Passwordhash = sql.NullString{ + Valid: true, + String: hashedPassword, + } + } + + account, err := server.store.UpdateAccountTx(ctx, arg) + if err != nil { + return nil, status.Error(codes.Internal, "failed to update account") + } + + rsp := &pb.UpdateAccountResponse{ + Account: convertAccount(account), + } + + return rsp, nil +} + +func validateUpdateAccountRequest(req *pb.UpdateAccountRequest) (violations []*errdetails.BadRequest_FieldViolation) { + if err := val.ValidateEmail(req.GetEmail()); err != nil { + violations = append(violations, fieldViolation("email", err)) + } + + if err := val.ValidatePassword(req.GetPassword()); err != nil { + violations = append(violations, fieldViolation("password", err)) + } + + if err := val.ValidateName(req.GetFirstname()); err != nil { + violations = append(violations, fieldViolation("first_name", err)) + } + + if err := val.ValidateName(req.GetLastname()); err != nil { + violations = append(violations, fieldViolation("last_name", err)) + } + + if err := val.ValidateName(req.GetCity()); err != nil { + violations = append(violations, fieldViolation("city", err)) + } + + if err := val.ValidateName(req.GetZip()); err != nil { + violations = append(violations, fieldViolation("zip", err)) + } + + if err := val.ValidateName(req.GetStreet()); err != nil { + violations = append(violations, fieldViolation("street", err)) + } + + return violations +} diff --git a/bff/gapi/rpc_update_account_privacy.go b/bff/gapi/rpc_update_account_privacy.go new file mode 100644 index 0000000..459cdaf --- /dev/null +++ b/bff/gapi/rpc_update_account_privacy.go @@ -0,0 +1,66 @@ +package gapi + +import ( + "context" + "database/sql" + "errors" + "fmt" + + db "github.com/itsscb/df/bff/db/sqlc" + "github.com/itsscb/df/bff/pb" + "github.com/itsscb/df/bff/val" + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (server *Server) UpdateAccountPrivacy(ctx context.Context, req *pb.UpdateAccountPrivacyRequest) (*pb.UpdateAccountPrivacyResponse, error) { + authPayload, err := server.authorizeUser(ctx) + if err != nil { + return nil, unauthenticatedError(err) + } + + violations := validateUpdateAccountPrivacyRequest(req) + if violations != nil { + return nil, invalidArgumentError(violations) + } + + account, err := server.store.GetAccount(ctx, req.GetId()) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, status.Errorf(codes.NotFound, "account not found") + } + return nil, status.Errorf(codes.Internal, "failed to get account") + } + + if authPayload.Email != account.Email { + if !server.isAdmin(ctx, authPayload) { + return nil, status.Error(codes.NotFound, "account not found") + } + } + privacyAccepted := req.GetPrivacyAccepted() + + arg := db.UpdateAccountPrivacyTxParams{ + Changer: authPayload.Email, + ID: req.GetId(), + PrivacyAccepted: &privacyAccepted, + } + + account, err = server.store.UpdateAccountPrivacyTx(ctx, arg) + if err != nil { + return nil, status.Error(codes.Internal, "failed to update account privacy") + } + + rsp := &pb.UpdateAccountPrivacyResponse{ + Account: convertAccount(account), + } + + return rsp, nil +} + +func validateUpdateAccountPrivacyRequest(req *pb.UpdateAccountPrivacyRequest) (violations []*errdetails.BadRequest_FieldViolation) { + if err := val.ValidateString(fmt.Sprint(req.GetId()), 30, 70); err != nil { + violations = append(violations, fieldViolation("id", err)) + } + return violations +} diff --git a/bff/gapi/server.go b/bff/gapi/server.go new file mode 100644 index 0000000..ee99629 --- /dev/null +++ b/bff/gapi/server.go @@ -0,0 +1,56 @@ +package gapi + +import ( + "context" + "fmt" + "log" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + db "github.com/itsscb/df/bff/db/sqlc" + "github.com/itsscb/df/bff/pb" + "github.com/itsscb/df/bff/token" + "github.com/itsscb/df/bff/util" + "google.golang.org/grpc" + "google.golang.org/grpc/reflection" +) + +// Server serves gRPC requests for df service +type Server struct { + pb.UnimplementedAccountsServer + pb.UnimplementedSessionsServer + store db.Store + config util.Config + tokenMaker token.Maker +} + +func NewServer(config util.Config, store db.Store) (*Server, error) { + tokenMaker, err := token.NewPasetoMaker(config.TokenPrivateKeyHex) + if err != nil { + return nil, fmt.Errorf("cannot create token maker: %w", err) + } + + server := &Server{ + store: store, + config: config, + tokenMaker: tokenMaker, + } + + return server, nil +} + +func (server *Server) RegisterServer(grpcServer *grpc.Server) { + pb.RegisterAccountsServer(grpcServer, server) + pb.RegisterSessionsServer(grpcServer, server) + reflection.Register(grpcServer) +} + +func (server *Server) RegisterHandler(ctx context.Context, mux *runtime.ServeMux) { + err := pb.RegisterAccountsHandlerServer(ctx, mux, server) + if err != nil { + log.Fatal("cannot register handler server") + } + err = pb.RegisterSessionsHandlerServer(ctx, mux, server) + if err != nil { + log.Fatal("cannot register handler server") + } +} diff --git a/bff/go.mod b/bff/go.mod index 1223675..2fafb8a 100644 --- a/bff/go.mod +++ b/bff/go.mod @@ -7,13 +7,17 @@ toolchain go1.21.1 require ( aidanwoods.dev/go-paseto v1.5.0 github.com/gin-gonic/gin v1.9.1 - github.com/google/uuid v1.1.2 + github.com/google/uuid v1.3.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 github.com/lib/pq v1.10.9 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 go.uber.org/mock v0.3.0 golang.org/x/crypto v0.13.0 - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 + google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d + google.golang.org/grpc v1.58.0 + google.golang.org/protobuf v1.31.0 ) require ( @@ -29,6 +33,7 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.15.4 // indirect github.com/goccy/go-json v0.10.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect @@ -51,7 +56,7 @@ require ( golang.org/x/net v0.15.0 // indirect golang.org/x/sys v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/bff/go.sum b/bff/go.sum index 52c8813..2066888 100644 --- a/bff/go.sum +++ b/bff/go.sum @@ -93,6 +93,8 @@ github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QX github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= +github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -118,6 +120,8 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -147,11 +151,14 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -264,8 +271,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -509,6 +514,12 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8= +google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q= +google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -525,6 +536,8 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o= +google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -536,11 +549,13 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/bff/main.go b/bff/main.go index 69e51ac..8be1523 100644 --- a/bff/main.go +++ b/bff/main.go @@ -1,16 +1,22 @@ package main import ( + "context" "database/sql" "embed" "io/fs" "log" + "net" "net/http" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/itsscb/df/bff/api" db "github.com/itsscb/df/bff/db/sqlc" + "github.com/itsscb/df/bff/gapi" "github.com/itsscb/df/bff/util" _ "github.com/lib/pq" + "google.golang.org/grpc" + "google.golang.org/protobuf/encoding/protojson" ) //go:embed doc/swagger @@ -27,6 +33,8 @@ func main() { log.Fatalf("could not connect to DB: %s", err) } + store := db.NewStore(conn) + if config.Environment == "development" { subDir, err := fs.Sub(swaggerFiles, "doc/swagger") if err != nil { @@ -35,13 +43,78 @@ func main() { swaggerFS = http.FS(subDir) } - store := db.NewStore(conn) + go runGatewayServer(config, store, swaggerFS) + runGRPCServer(config, store) +} + +func runGRPCServer(config util.Config, store db.Store) { + server, err := gapi.NewServer(config, store) + if err != nil { + log.Fatalf("could not start server: %s", err) + } + + grpcServer := grpc.NewServer() + server.RegisterServer(grpcServer) + + listener, err := net.Listen("tcp", config.GRPCServerAddress) + if err != nil { + log.Fatal("cannot create gRPC server:", err) + } + + log.Printf("start gRPC server at %s", listener.Addr().String()) + err = grpcServer.Serve(listener) + if err != nil { + log.Fatal("cannot start gRPC server:", err) + } +} + +func runGatewayServer(config util.Config, store db.Store, swaggerFS http.FileSystem) { + server, err := gapi.NewServer(config, store) + if err != nil { + log.Fatal("cannot create server") + } + + jsonOption := runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{ + MarshalOptions: protojson.MarshalOptions{ + UseProtoNames: true, + }, + UnmarshalOptions: protojson.UnmarshalOptions{ + DiscardUnknown: true, + }, + }) + + grpcMux := runtime.NewServeMux(jsonOption) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + server.RegisterHandler(ctx, grpcMux) + + mux := http.NewServeMux() + mux.Handle("/", grpcMux) + + swaggerHandler := http.StripPrefix("/swagger/", http.FileServer(swaggerFS)) + mux.Handle("/swagger/", swaggerHandler) + + listener, err := net.Listen("tcp", config.HTTPServerAddress) + if err != nil { + log.Fatal("cannot create listener") + } + + log.Printf("start HTTP gateway server at %s\n", listener.Addr().String()) + err = http.Serve(listener, mux) + if err != nil { + log.Fatal("cannot start HTTP gateway server") + } +} + +func runHTTPServer(config util.Config, store db.Store, swaggerFS http.FileSystem) { server, err := api.NewServer(config, store, swaggerFS) if err != nil { log.Fatalf("could not start server: %s", err) } - err = server.Start(config.ServerAddress) + err = server.Start(config.HTTPServerAddress) if err != nil { log.Fatal("cannot start server:", err) } diff --git a/bff/pb/account.pb.go b/bff/pb/account.pb.go new file mode 100644 index 0000000..b6d203a --- /dev/null +++ b/bff/pb/account.pb.go @@ -0,0 +1,345 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: account.proto + +package pb + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Account struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` + Firstname string `protobuf:"bytes,3,opt,name=firstname,proto3" json:"firstname,omitempty"` + Lastname string `protobuf:"bytes,4,opt,name=lastname,proto3" json:"lastname,omitempty"` + Street string `protobuf:"bytes,5,opt,name=street,proto3" json:"street,omitempty"` + City string `protobuf:"bytes,6,opt,name=city,proto3" json:"city,omitempty"` + Zip string `protobuf:"bytes,7,opt,name=zip,proto3" json:"zip,omitempty"` + Country string `protobuf:"bytes,8,opt,name=country,proto3" json:"country,omitempty"` + Birthday *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=birthday,proto3" json:"birthday,omitempty"` + Phone string `protobuf:"bytes,10,opt,name=phone,proto3" json:"phone,omitempty"` + PrivacyAccepted bool `protobuf:"varint,11,opt,name=privacy_accepted,json=privacyAccepted,proto3" json:"privacy_accepted,omitempty"` + PrivacyAcceptedDate *timestamppb.Timestamp `protobuf:"bytes,12,opt,name=privacy_accepted_date,json=privacyAcceptedDate,proto3" json:"privacy_accepted_date,omitempty"` + PermissionLevel int32 `protobuf:"varint,13,opt,name=permission_level,json=permissionLevel,proto3" json:"permission_level,omitempty"` + Creator string `protobuf:"bytes,14,opt,name=creator,proto3" json:"creator,omitempty"` + Created *timestamppb.Timestamp `protobuf:"bytes,15,opt,name=created,proto3" json:"created,omitempty"` + Changer string `protobuf:"bytes,16,opt,name=changer,proto3" json:"changer,omitempty"` + Changed *timestamppb.Timestamp `protobuf:"bytes,17,opt,name=changed,proto3" json:"changed,omitempty"` +} + +func (x *Account) Reset() { + *x = Account{} + if protoimpl.UnsafeEnabled { + mi := &file_account_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Account) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Account) ProtoMessage() {} + +func (x *Account) ProtoReflect() protoreflect.Message { + mi := &file_account_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Account.ProtoReflect.Descriptor instead. +func (*Account) Descriptor() ([]byte, []int) { + return file_account_proto_rawDescGZIP(), []int{0} +} + +func (x *Account) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Account) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *Account) GetFirstname() string { + if x != nil { + return x.Firstname + } + return "" +} + +func (x *Account) GetLastname() string { + if x != nil { + return x.Lastname + } + return "" +} + +func (x *Account) GetStreet() string { + if x != nil { + return x.Street + } + return "" +} + +func (x *Account) GetCity() string { + if x != nil { + return x.City + } + return "" +} + +func (x *Account) GetZip() string { + if x != nil { + return x.Zip + } + return "" +} + +func (x *Account) GetCountry() string { + if x != nil { + return x.Country + } + return "" +} + +func (x *Account) GetBirthday() *timestamppb.Timestamp { + if x != nil { + return x.Birthday + } + return nil +} + +func (x *Account) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *Account) GetPrivacyAccepted() bool { + if x != nil { + return x.PrivacyAccepted + } + return false +} + +func (x *Account) GetPrivacyAcceptedDate() *timestamppb.Timestamp { + if x != nil { + return x.PrivacyAcceptedDate + } + return nil +} + +func (x *Account) GetPermissionLevel() int32 { + if x != nil { + return x.PermissionLevel + } + return 0 +} + +func (x *Account) GetCreator() string { + if x != nil { + return x.Creator + } + return "" +} + +func (x *Account) GetCreated() *timestamppb.Timestamp { + if x != nil { + return x.Created + } + return nil +} + +func (x *Account) GetChanger() string { + if x != nil { + return x.Changer + } + return "" +} + +func (x *Account) GetChanged() *timestamppb.Timestamp { + if x != nil { + return x.Changed + } + return nil +} + +var File_account_proto protoreflect.FileDescriptor + +var file_account_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x02, 0x70, 0x62, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, + 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 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, 0x94, 0x08, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x69, 0x72, 0x73, 0x74, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x72, 0x73, 0x74, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x74, 0x79, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x7a, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x7a, 0x69, 0x70, 0x12, 0x18, + 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x36, 0x0a, 0x08, 0x62, 0x69, 0x72, 0x74, + 0x68, 0x64, 0x61, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, + 0x79, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, + 0x64, 0x12, 0x4e, 0x0a, 0x15, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x5f, 0x61, 0x63, 0x63, + 0x65, 0x70, 0x74, 0x65, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x70, 0x72, + 0x69, 0x76, 0x61, 0x63, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x44, 0x61, 0x74, + 0x65, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, + 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x70, 0x65, 0x72, + 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x18, 0x0a, 0x07, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x34, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x72, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x3a, 0xbc, 0x03, 0x92, + 0x41, 0xb8, 0x03, 0x0a, 0x09, 0x2a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0xaa, + 0x03, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x31, 0x38, 0x35, 0x2c, 0x22, 0x65, 0x6d, 0x61, + 0x69, 0x6c, 0x22, 0x3a, 0x20, 0x22, 0x6a, 0x6f, 0x68, 0x6e, 0x2e, 0x64, 0x6f, 0x65, 0x40, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x22, 0x2c, 0x20, 0x22, 0x66, 0x69, + 0x72, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x4a, 0x6f, 0x68, 0x6e, 0x22, + 0x2c, 0x20, 0x22, 0x6c, 0x61, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x44, + 0x6f, 0x65, 0x22, 0x2c, 0x20, 0x22, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x22, + 0x2c, 0x20, 0x22, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x44, 0x65, 0x61, + 0x74, 0x68, 0x20, 0x53, 0x74, 0x61, 0x72, 0x20, 0x32, 0x22, 0x2c, 0x20, 0x22, 0x7a, 0x69, 0x70, + 0x22, 0x3a, 0x20, 0x22, 0x30, 0x38, 0x31, 0x35, 0x22, 0x2c, 0x20, 0x22, 0x63, 0x69, 0x74, 0x79, + 0x22, 0x3a, 0x20, 0x22, 0x4e, 0x65, 0x77, 0x20, 0x59, 0x6f, 0x72, 0x6b, 0x22, 0x2c, 0x20, 0x22, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x3a, 0x20, 0x22, 0x55, 0x53, 0x41, 0x22, 0x2c, + 0x20, 0x22, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x79, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x39, + 0x39, 0x30, 0x2d, 0x31, 0x30, 0x2d, 0x30, 0x35, 0x54, 0x30, 0x30, 0x3a, 0x30, 0x30, 0x3a, 0x30, + 0x5a, 0x22, 0x2c, 0x20, 0x22, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x5f, 0x61, 0x63, 0x63, + 0x65, 0x70, 0x74, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x20, 0x22, + 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, + 0x5f, 0x64, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x30, 0x30, 0x30, 0x31, 0x2d, 0x30, 0x31, + 0x2d, 0x30, 0x31, 0x54, 0x30, 0x30, 0x3a, 0x30, 0x30, 0x3a, 0x30, 0x30, 0x5a, 0x22, 0x2c, 0x20, + 0x22, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x3a, 0x20, 0x22, 0x6a, 0x6f, 0x68, 0x6e, + 0x2e, 0x64, 0x6f, 0x65, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, + 0x22, 0x2c, 0x20, 0x22, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x32, + 0x30, 0x32, 0x33, 0x2d, 0x31, 0x30, 0x2d, 0x30, 0x35, 0x54, 0x30, 0x32, 0x3a, 0x33, 0x30, 0x3a, + 0x35, 0x33, 0x5a, 0x22, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x72, 0x22, 0x3a, + 0x20, 0x22, 0x6a, 0x6f, 0x68, 0x6e, 0x2e, 0x64, 0x6f, 0x65, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x22, 0x2c, 0x20, 0x22, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x64, 0x22, 0x3a, 0x20, 0x22, 0x32, 0x30, 0x32, 0x33, 0x2d, 0x31, 0x30, 0x2d, 0x30, 0x35, 0x54, + 0x30, 0x32, 0x3a, 0x33, 0x30, 0x3a, 0x35, 0x33, 0x5a, 0x22, 0x7d, 0x42, 0x19, 0x5a, 0x17, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, + 0x2f, 0x64, 0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_account_proto_rawDescOnce sync.Once + file_account_proto_rawDescData = file_account_proto_rawDesc +) + +func file_account_proto_rawDescGZIP() []byte { + file_account_proto_rawDescOnce.Do(func() { + file_account_proto_rawDescData = protoimpl.X.CompressGZIP(file_account_proto_rawDescData) + }) + return file_account_proto_rawDescData +} + +var file_account_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_account_proto_goTypes = []interface{}{ + (*Account)(nil), // 0: pb.Account + (*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp +} +var file_account_proto_depIdxs = []int32{ + 1, // 0: pb.Account.birthday:type_name -> google.protobuf.Timestamp + 1, // 1: pb.Account.privacy_accepted_date:type_name -> google.protobuf.Timestamp + 1, // 2: pb.Account.created:type_name -> google.protobuf.Timestamp + 1, // 3: pb.Account.changed:type_name -> google.protobuf.Timestamp + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_account_proto_init() } +func file_account_proto_init() { + if File_account_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Account); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_account_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_account_proto_goTypes, + DependencyIndexes: file_account_proto_depIdxs, + MessageInfos: file_account_proto_msgTypes, + }.Build() + File_account_proto = out.File + file_account_proto_rawDesc = nil + file_account_proto_goTypes = nil + file_account_proto_depIdxs = nil +} diff --git a/bff/pb/rpc_block_session.pb.go b/bff/pb/rpc_block_session.pb.go new file mode 100644 index 0000000..b3a5f24 --- /dev/null +++ b/bff/pb/rpc_block_session.pb.go @@ -0,0 +1,241 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: rpc_block_session.proto + +package pb + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type BlockSessionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` +} + +func (x *BlockSessionRequest) Reset() { + *x = BlockSessionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_block_session_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BlockSessionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockSessionRequest) ProtoMessage() {} + +func (x *BlockSessionRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_block_session_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlockSessionRequest.ProtoReflect.Descriptor instead. +func (*BlockSessionRequest) Descriptor() ([]byte, []int) { + return file_rpc_block_session_proto_rawDescGZIP(), []int{0} +} + +func (x *BlockSessionRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +type BlockSessionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + Blocked bool `protobuf:"varint,2,opt,name=blocked,proto3" json:"blocked,omitempty"` +} + +func (x *BlockSessionResponse) Reset() { + *x = BlockSessionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_block_session_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BlockSessionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockSessionResponse) ProtoMessage() {} + +func (x *BlockSessionResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_block_session_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlockSessionResponse.ProtoReflect.Descriptor instead. +func (*BlockSessionResponse) Descriptor() ([]byte, []int) { + return file_rpc_block_session_proto_rawDescGZIP(), []int{1} +} + +func (x *BlockSessionResponse) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *BlockSessionResponse) GetBlocked() bool { + if x != nil { + return x.Blocked + } + return false +} + +var File_rpc_block_session_proto protoreflect.FileDescriptor + +var file_rpc_block_session_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 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, 0xd4, 0x01, + 0x0a, 0x13, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x51, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x32, 0x92, 0x41, 0x2f, 0x4a, 0x26, + 0x22, 0x35, 0x65, 0x31, 0x64, 0x36, 0x37, 0x64, 0x61, 0x2d, 0x37, 0x63, 0x39, 0x62, 0x2d, 0x34, + 0x33, 0x36, 0x35, 0x2d, 0x61, 0x34, 0x64, 0x35, 0x2d, 0x33, 0x63, 0x63, 0x30, 0x61, 0x30, 0x35, + 0x31, 0x32, 0x34, 0x31, 0x65, 0x22, 0xa2, 0x02, 0x04, 0x75, 0x75, 0x69, 0x64, 0x52, 0x09, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x3a, 0x6a, 0x92, 0x41, 0x67, 0x0a, 0x2d, 0x2a, + 0x0d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0x0f, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xd2, + 0x01, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x32, 0x36, 0x7b, 0x22, + 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x35, 0x65, + 0x31, 0x64, 0x36, 0x37, 0x64, 0x61, 0x2d, 0x37, 0x63, 0x39, 0x62, 0x2d, 0x34, 0x33, 0x36, 0x35, + 0x2d, 0x61, 0x34, 0x64, 0x35, 0x2d, 0x33, 0x63, 0x63, 0x30, 0x61, 0x30, 0x35, 0x31, 0x32, 0x34, + 0x31, 0x65, 0x22, 0x7d, 0x22, 0xef, 0x01, 0x0a, 0x14, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, 0x0a, + 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x32, 0x92, 0x41, 0x2f, 0x4a, 0x26, 0x22, 0x35, 0x65, 0x31, 0x64, 0x36, 0x37, 0x64, + 0x61, 0x2d, 0x37, 0x63, 0x39, 0x62, 0x2d, 0x34, 0x33, 0x36, 0x35, 0x2d, 0x61, 0x34, 0x64, 0x35, + 0x2d, 0x33, 0x63, 0x63, 0x30, 0x61, 0x30, 0x35, 0x31, 0x32, 0x34, 0x31, 0x65, 0x22, 0xa2, 0x02, + 0x04, 0x75, 0x75, 0x69, 0x64, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, + 0x12, 0x23, 0x0a, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x08, 0x42, 0x09, 0x92, 0x41, 0x06, 0x4a, 0x04, 0x74, 0x72, 0x75, 0x65, 0x52, 0x07, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x3a, 0x5f, 0x92, 0x41, 0x5c, 0x0a, 0x11, 0x2a, 0x0f, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x20, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0x47, 0x7b, + 0x22, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x35, + 0x65, 0x31, 0x64, 0x36, 0x37, 0x64, 0x61, 0x2d, 0x37, 0x63, 0x39, 0x62, 0x2d, 0x34, 0x33, 0x36, + 0x35, 0x2d, 0x61, 0x34, 0x64, 0x35, 0x2d, 0x33, 0x63, 0x63, 0x30, 0x61, 0x30, 0x35, 0x31, 0x32, + 0x34, 0x31, 0x65, 0x22, 0x2c, 0x20, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x22, 0x3a, + 0x20, 0x74, 0x72, 0x75, 0x65, 0x7d, 0x42, 0x19, 0x5a, 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x2f, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_block_session_proto_rawDescOnce sync.Once + file_rpc_block_session_proto_rawDescData = file_rpc_block_session_proto_rawDesc +) + +func file_rpc_block_session_proto_rawDescGZIP() []byte { + file_rpc_block_session_proto_rawDescOnce.Do(func() { + file_rpc_block_session_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_block_session_proto_rawDescData) + }) + return file_rpc_block_session_proto_rawDescData +} + +var file_rpc_block_session_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_rpc_block_session_proto_goTypes = []interface{}{ + (*BlockSessionRequest)(nil), // 0: pb.BlockSessionRequest + (*BlockSessionResponse)(nil), // 1: pb.BlockSessionResponse +} +var file_rpc_block_session_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_rpc_block_session_proto_init() } +func file_rpc_block_session_proto_init() { + if File_rpc_block_session_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_rpc_block_session_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BlockSessionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_block_session_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BlockSessionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_block_session_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rpc_block_session_proto_goTypes, + DependencyIndexes: file_rpc_block_session_proto_depIdxs, + MessageInfos: file_rpc_block_session_proto_msgTypes, + }.Build() + File_rpc_block_session_proto = out.File + file_rpc_block_session_proto_rawDesc = nil + file_rpc_block_session_proto_goTypes = nil + file_rpc_block_session_proto_depIdxs = nil +} diff --git a/bff/pb/rpc_create_account.pb.go b/bff/pb/rpc_create_account.pb.go new file mode 100644 index 0000000..0cb3907 --- /dev/null +++ b/bff/pb/rpc_create_account.pb.go @@ -0,0 +1,351 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: rpc_create_account.proto + +package pb + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CreateAccountRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + Firstname string `protobuf:"bytes,3,opt,name=firstname,proto3" json:"firstname,omitempty"` + Lastname string `protobuf:"bytes,4,opt,name=lastname,proto3" json:"lastname,omitempty"` + Street string `protobuf:"bytes,5,opt,name=street,proto3" json:"street,omitempty"` + City string `protobuf:"bytes,6,opt,name=city,proto3" json:"city,omitempty"` + Zip string `protobuf:"bytes,7,opt,name=zip,proto3" json:"zip,omitempty"` + Country string `protobuf:"bytes,8,opt,name=country,proto3" json:"country,omitempty"` + Phone string `protobuf:"bytes,9,opt,name=phone,proto3" json:"phone,omitempty"` + Birthday *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=birthday,proto3" json:"birthday,omitempty"` + PrivacyAccepted *bool `protobuf:"varint,11,opt,name=privacy_accepted,json=privacyAccepted,proto3,oneof" json:"privacy_accepted,omitempty"` +} + +func (x *CreateAccountRequest) Reset() { + *x = CreateAccountRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_create_account_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateAccountRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateAccountRequest) ProtoMessage() {} + +func (x *CreateAccountRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_create_account_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateAccountRequest.ProtoReflect.Descriptor instead. +func (*CreateAccountRequest) Descriptor() ([]byte, []int) { + return file_rpc_create_account_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateAccountRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *CreateAccountRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *CreateAccountRequest) GetFirstname() string { + if x != nil { + return x.Firstname + } + return "" +} + +func (x *CreateAccountRequest) GetLastname() string { + if x != nil { + return x.Lastname + } + return "" +} + +func (x *CreateAccountRequest) GetStreet() string { + if x != nil { + return x.Street + } + return "" +} + +func (x *CreateAccountRequest) GetCity() string { + if x != nil { + return x.City + } + return "" +} + +func (x *CreateAccountRequest) GetZip() string { + if x != nil { + return x.Zip + } + return "" +} + +func (x *CreateAccountRequest) GetCountry() string { + if x != nil { + return x.Country + } + return "" +} + +func (x *CreateAccountRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *CreateAccountRequest) GetBirthday() *timestamppb.Timestamp { + if x != nil { + return x.Birthday + } + return nil +} + +func (x *CreateAccountRequest) GetPrivacyAccepted() bool { + if x != nil && x.PrivacyAccepted != nil { + return *x.PrivacyAccepted + } + return false +} + +// \"1990-10-05T00:00:0Z\" +type CreateAccountResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *CreateAccountResponse) Reset() { + *x = CreateAccountResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_create_account_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateAccountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateAccountResponse) ProtoMessage() {} + +func (x *CreateAccountResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_create_account_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateAccountResponse.ProtoReflect.Descriptor instead. +func (*CreateAccountResponse) Descriptor() ([]byte, []int) { + return file_rpc_create_account_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateAccountResponse) GetAccount() *Account { + if x != nil { + return x.Account + } + return nil +} + +var File_rpc_create_account_proto protoreflect.FileDescriptor + +var file_rpc_create_account_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x72, 0x70, 0x63, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x1f, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, + 0x61, 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, 0x1a, + 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf9, + 0x05, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 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, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x69, 0x72, + 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, + 0x72, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, + 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x7a, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x7a, 0x69, + 0x70, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x70, + 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, + 0x65, 0x12, 0x52, 0x0a, 0x08, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x79, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, + 0x1a, 0x92, 0x41, 0x17, 0x4a, 0x15, 0x22, 0x31, 0x39, 0x39, 0x30, 0x2d, 0x31, 0x30, 0x2d, 0x30, + 0x35, 0x54, 0x30, 0x30, 0x3a, 0x30, 0x30, 0x3a, 0x30, 0x5a, 0x22, 0x52, 0x08, 0x62, 0x69, 0x72, + 0x74, 0x68, 0x64, 0x61, 0x79, 0x12, 0x39, 0x0a, 0x10, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, + 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x42, + 0x09, 0x92, 0x41, 0x06, 0x4a, 0x04, 0x74, 0x72, 0x75, 0x65, 0x48, 0x00, 0x52, 0x0f, 0x70, 0x72, + 0x69, 0x76, 0x61, 0x63, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x88, 0x01, 0x01, + 0x3a, 0xe2, 0x02, 0x92, 0x41, 0xde, 0x02, 0x0a, 0x78, 0x2a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x20, 0x61, 0x6e, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0xd2, 0x01, 0x05, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0xd2, 0x01, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0xd2, + 0x01, 0x09, 0x66, 0x69, 0x72, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0xd2, 0x01, 0x08, 0x6c, 0x61, + 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0xd2, 0x01, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0xd2, + 0x01, 0x04, 0x63, 0x69, 0x74, 0x79, 0xd2, 0x01, 0x03, 0x7a, 0x69, 0x70, 0xd2, 0x01, 0x07, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0xd2, 0x01, 0x08, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, + 0x79, 0x32, 0xe1, 0x01, 0x7b, 0x22, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x3a, 0x20, 0x22, 0x6a, + 0x6f, 0x68, 0x6e, 0x2e, 0x64, 0x6f, 0x65, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, + 0x63, 0x6f, 0x6d, 0x22, 0x2c, 0x20, 0x22, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, + 0x3a, 0x20, 0x22, 0x4d, 0x61, 0x79, 0x54, 0x68, 0x65, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x42, 0x65, + 0x57, 0x69, 0x74, 0x68, 0x59, 0x6f, 0x75, 0x21, 0x22, 0x2c, 0x20, 0x22, 0x66, 0x69, 0x72, 0x73, + 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x4a, 0x6f, 0x68, 0x6e, 0x22, 0x2c, 0x20, + 0x22, 0x6c, 0x61, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x44, 0x6f, 0x65, + 0x22, 0x2c, 0x20, 0x22, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x4d, 0x61, + 0x69, 0x6e, 0x20, 0x53, 0x74, 0x72, 0x65, 0x65, 0x74, 0x20, 0x31, 0x22, 0x2c, 0x20, 0x22, 0x7a, + 0x69, 0x70, 0x22, 0x3a, 0x20, 0x22, 0x30, 0x38, 0x31, 0x35, 0x22, 0x2c, 0x20, 0x22, 0x63, 0x69, + 0x74, 0x79, 0x22, 0x3a, 0x20, 0x22, 0x4e, 0x65, 0x77, 0x20, 0x59, 0x6f, 0x72, 0x6b, 0x22, 0x2c, + 0x20, 0x22, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x3a, 0x20, 0x22, 0x55, 0x53, 0x41, + 0x22, 0x2c, 0x20, 0x22, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x79, 0x22, 0x3a, 0x20, 0x22, + 0x31, 0x39, 0x39, 0x30, 0x2d, 0x31, 0x30, 0x2d, 0x30, 0x35, 0x54, 0x30, 0x30, 0x3a, 0x30, 0x30, + 0x3a, 0x30, 0x5a, 0x22, 0x7d, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, + 0x79, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x22, 0x78, 0x0a, 0x15, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x42, 0x03, 0x92, 0x41, 0x00, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x3a, + 0x33, 0x92, 0x41, 0x30, 0x0a, 0x2e, 0x2a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x1b, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x19, 0x5a, 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x2f, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_create_account_proto_rawDescOnce sync.Once + file_rpc_create_account_proto_rawDescData = file_rpc_create_account_proto_rawDesc +) + +func file_rpc_create_account_proto_rawDescGZIP() []byte { + file_rpc_create_account_proto_rawDescOnce.Do(func() { + file_rpc_create_account_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_create_account_proto_rawDescData) + }) + return file_rpc_create_account_proto_rawDescData +} + +var file_rpc_create_account_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_rpc_create_account_proto_goTypes = []interface{}{ + (*CreateAccountRequest)(nil), // 0: pb.CreateAccountRequest + (*CreateAccountResponse)(nil), // 1: pb.CreateAccountResponse + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp + (*Account)(nil), // 3: pb.Account +} +var file_rpc_create_account_proto_depIdxs = []int32{ + 2, // 0: pb.CreateAccountRequest.birthday:type_name -> google.protobuf.Timestamp + 3, // 1: pb.CreateAccountResponse.account:type_name -> pb.Account + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_rpc_create_account_proto_init() } +func file_rpc_create_account_proto_init() { + if File_rpc_create_account_proto != nil { + return + } + file_account_proto_init() + if !protoimpl.UnsafeEnabled { + file_rpc_create_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateAccountRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_create_account_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateAccountResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_rpc_create_account_proto_msgTypes[0].OneofWrappers = []interface{}{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_create_account_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rpc_create_account_proto_goTypes, + DependencyIndexes: file_rpc_create_account_proto_depIdxs, + MessageInfos: file_rpc_create_account_proto_msgTypes, + }.Build() + File_rpc_create_account_proto = out.File + file_rpc_create_account_proto_rawDesc = nil + file_rpc_create_account_proto_goTypes = nil + file_rpc_create_account_proto_depIdxs = nil +} diff --git a/bff/pb/rpc_login.pb.go b/bff/pb/rpc_login.pb.go new file mode 100644 index 0000000..7ba4713 --- /dev/null +++ b/bff/pb/rpc_login.pb.go @@ -0,0 +1,342 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: rpc_login.proto + +package pb + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type LoginRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *LoginRequest) Reset() { + *x = LoginRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_login_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginRequest) ProtoMessage() {} + +func (x *LoginRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_login_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. +func (*LoginRequest) Descriptor() ([]byte, []int) { + return file_rpc_login_proto_rawDescGZIP(), []int{0} +} + +func (x *LoginRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *LoginRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type LoginResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + AccessTokenExpiresAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=access_token_expires_at,json=accessTokenExpiresAt,proto3" json:"access_token_expires_at,omitempty"` + RefreshToken string `protobuf:"bytes,4,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` + RefreshTokenExpiresAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=refresh_token_expires_at,json=refreshTokenExpiresAt,proto3" json:"refresh_token_expires_at,omitempty"` + Email string `protobuf:"bytes,6,opt,name=email,proto3" json:"email,omitempty"` +} + +func (x *LoginResponse) Reset() { + *x = LoginResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_login_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginResponse) ProtoMessage() {} + +func (x *LoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_login_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. +func (*LoginResponse) Descriptor() ([]byte, []int) { + return file_rpc_login_proto_rawDescGZIP(), []int{1} +} + +func (x *LoginResponse) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *LoginResponse) GetAccessToken() string { + if x != nil { + return x.AccessToken + } + return "" +} + +func (x *LoginResponse) GetAccessTokenExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.AccessTokenExpiresAt + } + return nil +} + +func (x *LoginResponse) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + +func (x *LoginResponse) GetRefreshTokenExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.RefreshTokenExpiresAt + } + return nil +} + +func (x *LoginResponse) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +var File_rpc_login_proto protoreflect.FileDescriptor + +var file_rpc_login_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x72, 0x70, 0x63, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, + 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 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, 0x89, 0x02, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x23, 0x92, 0x41, 0x20, 0x4a, 0x16, 0x22, 0x6a, 0x6f, + 0x68, 0x6e, 0x2e, 0x64, 0x6f, 0x65, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, + 0x6f, 0x6d, 0x22, 0xa2, 0x02, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x05, 0x65, 0x6d, 0x61, + 0x69, 0x6c, 0x12, 0x43, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0x92, 0x41, 0x24, 0x4a, 0x17, 0x22, 0x4d, 0x61, 0x79, 0x54, + 0x68, 0x65, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x42, 0x65, 0x57, 0x69, 0x74, 0x68, 0x59, 0x6f, 0x75, + 0x21, 0x22, 0xa2, 0x02, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x08, 0x70, + 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x3a, 0x79, 0x92, 0x41, 0x76, 0x0a, 0x2c, 0x2a, 0x05, + 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x32, 0x10, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x20, 0x61, 0x6e, 0x20, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0xd2, 0x01, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0xd2, + 0x01, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x32, 0x46, 0x7b, 0x22, 0x65, 0x6d, + 0x61, 0x69, 0x6c, 0x22, 0x3a, 0x20, 0x22, 0x6a, 0x6f, 0x68, 0x6e, 0x2e, 0x64, 0x6f, 0x65, 0x40, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x22, 0x2c, 0x20, 0x22, 0x70, + 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x4d, 0x61, 0x79, 0x54, 0x68, + 0x65, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x42, 0x65, 0x57, 0x69, 0x74, 0x68, 0x59, 0x6f, 0x75, 0x21, + 0x22, 0x7d, 0x22, 0xb6, 0x08, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x32, 0x92, 0x41, 0x2f, 0x4a, 0x26, 0x22, + 0x35, 0x65, 0x31, 0x64, 0x36, 0x37, 0x64, 0x61, 0x2d, 0x37, 0x63, 0x39, 0x62, 0x2d, 0x34, 0x33, + 0x36, 0x35, 0x2d, 0x61, 0x34, 0x64, 0x35, 0x2d, 0x33, 0x63, 0x63, 0x30, 0x61, 0x30, 0x35, 0x31, + 0x32, 0x34, 0x31, 0x65, 0x22, 0xa2, 0x02, 0x04, 0x75, 0x75, 0x69, 0x64, 0x52, 0x09, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0xe9, 0x02, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, + 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0xc5, + 0x02, 0x92, 0x41, 0xc1, 0x02, 0x4a, 0xbe, 0x02, 0x22, 0x76, 0x34, 0x2e, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x2e, 0x65, 0x79, 0x4a, 0x6c, 0x62, 0x57, 0x46, 0x70, 0x62, 0x43, 0x49, 0x36, 0x49, + 0x6d, 0x45, 0x79, 0x51, 0x47, 0x49, 0x75, 0x5a, 0x47, 0x55, 0x69, 0x4c, 0x43, 0x4a, 0x6c, 0x65, + 0x48, 0x41, 0x69, 0x4f, 0x69, 0x49, 0x79, 0x4d, 0x44, 0x49, 0x7a, 0x4c, 0x54, 0x45, 0x77, 0x4c, + 0x54, 0x41, 0x31, 0x56, 0x44, 0x41, 0x78, 0x4f, 0x6a, 0x45, 0x33, 0x4f, 0x6a, 0x41, 0x35, 0x4b, + 0x7a, 0x41, 0x79, 0x4f, 0x6a, 0x41, 0x77, 0x49, 0x69, 0x77, 0x69, 0x61, 0x57, 0x46, 0x30, 0x49, + 0x6a, 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, 0x79, 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, + 0x56, 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, + 0x6a, 0x6f, 0x77, 0x4d, 0x43, 0x49, 0x73, 0x49, 0x6d, 0x6c, 0x6b, 0x49, 0x6a, 0x6f, 0x69, 0x5a, + 0x6a, 0x6c, 0x68, 0x4d, 0x6a, 0x45, 0x32, 0x4f, 0x57, 0x51, 0x74, 0x4d, 0x57, 0x59, 0x78, 0x59, + 0x53, 0x30, 0x30, 0x59, 0x54, 0x68, 0x69, 0x4c, 0x54, 0x67, 0x7a, 0x5a, 0x57, 0x45, 0x74, 0x4e, + 0x7a, 0x6b, 0x78, 0x4d, 0x7a, 0x59, 0x35, 0x59, 0x6a, 0x59, 0x33, 0x5a, 0x6d, 0x59, 0x78, 0x49, + 0x69, 0x77, 0x69, 0x62, 0x6d, 0x4a, 0x6d, 0x49, 0x6a, 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, + 0x79, 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, 0x56, 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, + 0x6a, 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4d, 0x43, 0x4a, 0x39, 0x41, + 0x68, 0x30, 0x62, 0x56, 0x62, 0x78, 0x39, 0x53, 0x31, 0x4c, 0x52, 0x2d, 0x70, 0x66, 0x38, 0x68, + 0x4c, 0x57, 0x56, 0x52, 0x51, 0x50, 0x55, 0x66, 0x4b, 0x39, 0x7a, 0x72, 0x48, 0x5a, 0x76, 0x41, + 0x37, 0x41, 0x70, 0x4a, 0x35, 0x61, 0x5a, 0x58, 0x77, 0x68, 0x41, 0x37, 0x48, 0x31, 0x6a, 0x2d, + 0x6b, 0x48, 0x68, 0x63, 0x63, 0x42, 0x6a, 0x4f, 0x41, 0x47, 0x59, 0x58, 0x5a, 0x51, 0x54, 0x2d, + 0x74, 0x73, 0x37, 0x4a, 0x71, 0x33, 0x53, 0x4a, 0x6c, 0x7a, 0x6f, 0x35, 0x76, 0x74, 0x55, 0x6a, + 0x47, 0x42, 0x74, 0x44, 0x67, 0x22, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x12, 0x51, 0x0a, 0x17, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x14, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x45, 0x78, 0x70, + 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x12, 0xeb, 0x02, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, + 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0xc5, + 0x02, 0x92, 0x41, 0xc1, 0x02, 0x4a, 0xbe, 0x02, 0x22, 0x76, 0x34, 0x2e, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x2e, 0x65, 0x79, 0x4a, 0x6c, 0x62, 0x57, 0x46, 0x70, 0x62, 0x43, 0x49, 0x36, 0x49, + 0x6d, 0x45, 0x79, 0x51, 0x47, 0x49, 0x75, 0x5a, 0x47, 0x55, 0x69, 0x4c, 0x43, 0x4a, 0x6c, 0x65, + 0x48, 0x41, 0x69, 0x4f, 0x69, 0x49, 0x79, 0x4d, 0x44, 0x49, 0x7a, 0x4c, 0x54, 0x45, 0x77, 0x4c, + 0x54, 0x41, 0x32, 0x56, 0x44, 0x41, 0x78, 0x4f, 0x6a, 0x41, 0x79, 0x4f, 0x6a, 0x41, 0x35, 0x4b, + 0x7a, 0x41, 0x79, 0x4f, 0x6a, 0x41, 0x77, 0x49, 0x69, 0x77, 0x69, 0x61, 0x57, 0x46, 0x30, 0x49, + 0x6a, 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, 0x79, 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, + 0x56, 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, + 0x6a, 0x6f, 0x77, 0x4d, 0x43, 0x49, 0x73, 0x49, 0x6d, 0x6c, 0x6b, 0x49, 0x6a, 0x6f, 0x69, 0x4e, + 0x57, 0x55, 0x78, 0x5a, 0x44, 0x59, 0x33, 0x5a, 0x47, 0x45, 0x74, 0x4e, 0x32, 0x4d, 0x35, 0x59, + 0x69, 0x30, 0x30, 0x4d, 0x7a, 0x59, 0x31, 0x4c, 0x57, 0x45, 0x30, 0x5a, 0x44, 0x55, 0x74, 0x4d, + 0x32, 0x4e, 0x6a, 0x4d, 0x47, 0x45, 0x77, 0x4e, 0x54, 0x45, 0x79, 0x4e, 0x44, 0x46, 0x6c, 0x49, + 0x69, 0x77, 0x69, 0x62, 0x6d, 0x4a, 0x6d, 0x49, 0x6a, 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, + 0x79, 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, 0x56, 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, + 0x6a, 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4d, 0x43, 0x4a, 0x39, 0x42, + 0x6f, 0x58, 0x33, 0x36, 0x77, 0x30, 0x70, 0x6f, 0x31, 0x76, 0x76, 0x48, 0x53, 0x6a, 0x73, 0x42, + 0x50, 0x5f, 0x4b, 0x57, 0x65, 0x46, 0x78, 0x56, 0x31, 0x78, 0x52, 0x62, 0x51, 0x61, 0x79, 0x71, + 0x62, 0x4a, 0x75, 0x49, 0x6f, 0x4b, 0x32, 0x6a, 0x4b, 0x71, 0x79, 0x31, 0x42, 0x74, 0x32, 0x52, + 0x6f, 0x48, 0x79, 0x4a, 0x62, 0x4c, 0x6f, 0x43, 0x45, 0x4f, 0x31, 0x35, 0x43, 0x52, 0x54, 0x35, + 0x44, 0x6e, 0x51, 0x36, 0x50, 0x30, 0x41, 0x48, 0x6c, 0x42, 0x7a, 0x6a, 0x73, 0x58, 0x74, 0x36, + 0x31, 0x61, 0x44, 0x44, 0x77, 0x22, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x53, 0x0a, 0x18, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x15, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x05, 0x65, 0x6d, 0x61, + 0x69, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x23, 0x92, 0x41, 0x20, 0x4a, 0x16, 0x22, + 0x6a, 0x6f, 0x68, 0x6e, 0x2e, 0x64, 0x6f, 0x65, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x2e, 0x63, 0x6f, 0x6d, 0x22, 0xa2, 0x02, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x05, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0x3a, 0x15, 0x92, 0x41, 0x12, 0x0a, 0x10, 0x2a, 0x0e, 0x4c, 0x6f, 0x67, + 0x69, 0x6e, 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x19, 0x5a, 0x17, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, + 0x2f, 0x64, 0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_login_proto_rawDescOnce sync.Once + file_rpc_login_proto_rawDescData = file_rpc_login_proto_rawDesc +) + +func file_rpc_login_proto_rawDescGZIP() []byte { + file_rpc_login_proto_rawDescOnce.Do(func() { + file_rpc_login_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_login_proto_rawDescData) + }) + return file_rpc_login_proto_rawDescData +} + +var file_rpc_login_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_rpc_login_proto_goTypes = []interface{}{ + (*LoginRequest)(nil), // 0: pb.LoginRequest + (*LoginResponse)(nil), // 1: pb.LoginResponse + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp +} +var file_rpc_login_proto_depIdxs = []int32{ + 2, // 0: pb.LoginResponse.access_token_expires_at:type_name -> google.protobuf.Timestamp + 2, // 1: pb.LoginResponse.refresh_token_expires_at:type_name -> google.protobuf.Timestamp + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_rpc_login_proto_init() } +func file_rpc_login_proto_init() { + if File_rpc_login_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_rpc_login_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_login_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_login_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rpc_login_proto_goTypes, + DependencyIndexes: file_rpc_login_proto_depIdxs, + MessageInfos: file_rpc_login_proto_msgTypes, + }.Build() + File_rpc_login_proto = out.File + file_rpc_login_proto_rawDesc = nil + file_rpc_login_proto_goTypes = nil + file_rpc_login_proto_depIdxs = nil +} diff --git a/bff/pb/rpc_refresh_token.pb.go b/bff/pb/rpc_refresh_token.pb.go new file mode 100644 index 0000000..9988238 --- /dev/null +++ b/bff/pb/rpc_refresh_token.pb.go @@ -0,0 +1,303 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: rpc_refresh_token.proto + +package pb + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type RefreshTokenRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` +} + +func (x *RefreshTokenRequest) Reset() { + *x = RefreshTokenRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_refresh_token_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RefreshTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshTokenRequest) ProtoMessage() {} + +func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_refresh_token_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshTokenRequest.ProtoReflect.Descriptor instead. +func (*RefreshTokenRequest) Descriptor() ([]byte, []int) { + return file_rpc_refresh_token_proto_rawDescGZIP(), []int{0} +} + +func (x *RefreshTokenRequest) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + +type RefreshTokenResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + AccessTokenExpiresAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=access_token_expires_at,json=accessTokenExpiresAt,proto3" json:"access_token_expires_at,omitempty"` +} + +func (x *RefreshTokenResponse) Reset() { + *x = RefreshTokenResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_refresh_token_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RefreshTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshTokenResponse) ProtoMessage() {} + +func (x *RefreshTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_refresh_token_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshTokenResponse.ProtoReflect.Descriptor instead. +func (*RefreshTokenResponse) Descriptor() ([]byte, []int) { + return file_rpc_refresh_token_proto_rawDescGZIP(), []int{1} +} + +func (x *RefreshTokenResponse) GetAccessToken() string { + if x != nil { + return x.AccessToken + } + return "" +} + +func (x *RefreshTokenResponse) GetAccessTokenExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.AccessTokenExpiresAt + } + return nil +} + +var File_rpc_refresh_token_proto protoreflect.FileDescriptor + +var file_rpc_refresh_token_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x72, 0x70, 0x63, 0x5f, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x1f, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, + 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, 0xce, + 0x06, 0x0a, 0x13, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0xfa, 0x02, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, + 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0xd4, + 0x02, 0x92, 0x41, 0xd0, 0x02, 0x2a, 0x0d, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x20, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x4a, 0xbe, 0x02, 0x22, 0x76, 0x34, 0x2e, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x2e, 0x65, 0x79, 0x4a, 0x6c, 0x62, 0x57, 0x46, 0x70, 0x62, 0x43, 0x49, 0x36, 0x49, 0x6d, + 0x45, 0x79, 0x51, 0x47, 0x49, 0x75, 0x5a, 0x47, 0x55, 0x69, 0x4c, 0x43, 0x4a, 0x6c, 0x65, 0x48, + 0x41, 0x69, 0x4f, 0x69, 0x49, 0x79, 0x4d, 0x44, 0x49, 0x7a, 0x4c, 0x54, 0x45, 0x77, 0x4c, 0x54, + 0x41, 0x32, 0x56, 0x44, 0x41, 0x78, 0x4f, 0x6a, 0x41, 0x79, 0x4f, 0x6a, 0x41, 0x35, 0x4b, 0x7a, + 0x41, 0x79, 0x4f, 0x6a, 0x41, 0x77, 0x49, 0x69, 0x77, 0x69, 0x61, 0x57, 0x46, 0x30, 0x49, 0x6a, + 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, 0x79, 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, 0x56, + 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, 0x6a, + 0x6f, 0x77, 0x4d, 0x43, 0x49, 0x73, 0x49, 0x6d, 0x6c, 0x6b, 0x49, 0x6a, 0x6f, 0x69, 0x4e, 0x57, + 0x55, 0x78, 0x5a, 0x44, 0x59, 0x33, 0x5a, 0x47, 0x45, 0x74, 0x4e, 0x32, 0x4d, 0x35, 0x59, 0x69, + 0x30, 0x30, 0x4d, 0x7a, 0x59, 0x31, 0x4c, 0x57, 0x45, 0x30, 0x5a, 0x44, 0x55, 0x74, 0x4d, 0x32, + 0x4e, 0x6a, 0x4d, 0x47, 0x45, 0x77, 0x4e, 0x54, 0x45, 0x79, 0x4e, 0x44, 0x46, 0x6c, 0x49, 0x69, + 0x77, 0x69, 0x62, 0x6d, 0x4a, 0x6d, 0x49, 0x6a, 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, 0x79, + 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, 0x56, 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, 0x6a, + 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4d, 0x43, 0x4a, 0x39, 0x42, 0x6f, + 0x58, 0x33, 0x36, 0x77, 0x30, 0x70, 0x6f, 0x31, 0x76, 0x76, 0x48, 0x53, 0x6a, 0x73, 0x42, 0x50, + 0x5f, 0x4b, 0x57, 0x65, 0x46, 0x78, 0x56, 0x31, 0x78, 0x52, 0x62, 0x51, 0x61, 0x79, 0x71, 0x62, + 0x4a, 0x75, 0x49, 0x6f, 0x4b, 0x32, 0x6a, 0x4b, 0x71, 0x79, 0x31, 0x42, 0x74, 0x32, 0x52, 0x6f, + 0x48, 0x79, 0x4a, 0x62, 0x4c, 0x6f, 0x43, 0x45, 0x4f, 0x31, 0x35, 0x43, 0x52, 0x54, 0x35, 0x44, + 0x6e, 0x51, 0x36, 0x50, 0x30, 0x41, 0x48, 0x6c, 0x42, 0x7a, 0x6a, 0x73, 0x58, 0x74, 0x36, 0x31, + 0x61, 0x44, 0x44, 0x77, 0x22, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x3a, 0xb9, 0x03, 0x92, 0x41, 0xb5, 0x03, 0x0a, 0x5f, 0x2a, 0x15, 0x52, 0x65, + 0x66, 0x72, 0x65, 0x73, 0x68, 0x20, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x32, 0x36, 0x47, 0x65, 0x74, 0x20, 0x61, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x41, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x20, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x62, 0x79, 0x20, 0x73, + 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x52, 0x65, + 0x66, 0x72, 0x65, 0x73, 0x68, 0x20, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0xd2, 0x01, 0x0d, 0x72, 0x65, + 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0xd1, 0x02, 0x7b, 0x22, + 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x3a, 0x20, + 0x22, 0x76, 0x34, 0x2e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x2e, 0x65, 0x79, 0x4a, 0x6c, 0x62, + 0x57, 0x46, 0x70, 0x62, 0x43, 0x49, 0x36, 0x49, 0x6d, 0x45, 0x79, 0x51, 0x47, 0x49, 0x75, 0x5a, + 0x47, 0x55, 0x69, 0x4c, 0x43, 0x4a, 0x6c, 0x65, 0x48, 0x41, 0x69, 0x4f, 0x69, 0x49, 0x79, 0x4d, + 0x44, 0x49, 0x7a, 0x4c, 0x54, 0x45, 0x77, 0x4c, 0x54, 0x41, 0x32, 0x56, 0x44, 0x41, 0x78, 0x4f, + 0x6a, 0x41, 0x79, 0x4f, 0x6a, 0x41, 0x35, 0x4b, 0x7a, 0x41, 0x79, 0x4f, 0x6a, 0x41, 0x77, 0x49, + 0x69, 0x77, 0x69, 0x61, 0x57, 0x46, 0x30, 0x49, 0x6a, 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, + 0x79, 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, 0x56, 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, + 0x6a, 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4d, 0x43, 0x49, 0x73, 0x49, + 0x6d, 0x6c, 0x6b, 0x49, 0x6a, 0x6f, 0x69, 0x4e, 0x57, 0x55, 0x78, 0x5a, 0x44, 0x59, 0x33, 0x5a, + 0x47, 0x45, 0x74, 0x4e, 0x32, 0x4d, 0x35, 0x59, 0x69, 0x30, 0x30, 0x4d, 0x7a, 0x59, 0x31, 0x4c, + 0x57, 0x45, 0x30, 0x5a, 0x44, 0x55, 0x74, 0x4d, 0x32, 0x4e, 0x6a, 0x4d, 0x47, 0x45, 0x77, 0x4e, + 0x54, 0x45, 0x79, 0x4e, 0x44, 0x46, 0x6c, 0x49, 0x69, 0x77, 0x69, 0x62, 0x6d, 0x4a, 0x6d, 0x49, + 0x6a, 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, 0x79, 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, + 0x56, 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, + 0x6a, 0x6f, 0x77, 0x4d, 0x43, 0x4a, 0x39, 0x42, 0x6f, 0x58, 0x33, 0x36, 0x77, 0x30, 0x70, 0x6f, + 0x31, 0x76, 0x76, 0x48, 0x53, 0x6a, 0x73, 0x42, 0x50, 0x5f, 0x4b, 0x57, 0x65, 0x46, 0x78, 0x56, + 0x31, 0x78, 0x52, 0x62, 0x51, 0x61, 0x79, 0x71, 0x62, 0x4a, 0x75, 0x49, 0x6f, 0x4b, 0x32, 0x6a, + 0x4b, 0x71, 0x79, 0x31, 0x42, 0x74, 0x32, 0x52, 0x6f, 0x48, 0x79, 0x4a, 0x62, 0x4c, 0x6f, 0x43, + 0x45, 0x4f, 0x31, 0x35, 0x43, 0x52, 0x54, 0x35, 0x44, 0x6e, 0x51, 0x36, 0x50, 0x30, 0x41, 0x48, + 0x6c, 0x42, 0x7a, 0x6a, 0x73, 0x58, 0x74, 0x36, 0x31, 0x61, 0x44, 0x44, 0x77, 0x22, 0x7d, 0x22, + 0x82, 0x04, 0x0a, 0x14, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0xf7, 0x02, 0x0a, 0x0c, 0x61, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, + 0xd3, 0x02, 0x92, 0x41, 0xcf, 0x02, 0x2a, 0x0c, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x20, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x4a, 0xbe, 0x02, 0x22, 0x76, 0x34, 0x2e, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x2e, 0x65, 0x79, 0x4a, 0x6c, 0x62, 0x57, 0x46, 0x70, 0x62, 0x43, 0x49, 0x36, 0x49, 0x6d, + 0x45, 0x79, 0x51, 0x47, 0x49, 0x75, 0x5a, 0x47, 0x55, 0x69, 0x4c, 0x43, 0x4a, 0x6c, 0x65, 0x48, + 0x41, 0x69, 0x4f, 0x69, 0x49, 0x79, 0x4d, 0x44, 0x49, 0x7a, 0x4c, 0x54, 0x45, 0x77, 0x4c, 0x54, + 0x41, 0x31, 0x56, 0x44, 0x41, 0x78, 0x4f, 0x6a, 0x45, 0x33, 0x4f, 0x6a, 0x41, 0x35, 0x4b, 0x7a, + 0x41, 0x79, 0x4f, 0x6a, 0x41, 0x77, 0x49, 0x69, 0x77, 0x69, 0x61, 0x57, 0x46, 0x30, 0x49, 0x6a, + 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, 0x79, 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, 0x56, + 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, 0x6a, + 0x6f, 0x77, 0x4d, 0x43, 0x49, 0x73, 0x49, 0x6d, 0x6c, 0x6b, 0x49, 0x6a, 0x6f, 0x69, 0x5a, 0x6a, + 0x6c, 0x68, 0x4d, 0x6a, 0x45, 0x32, 0x4f, 0x57, 0x51, 0x74, 0x4d, 0x57, 0x59, 0x78, 0x59, 0x53, + 0x30, 0x30, 0x59, 0x54, 0x68, 0x69, 0x4c, 0x54, 0x67, 0x7a, 0x5a, 0x57, 0x45, 0x74, 0x4e, 0x7a, + 0x6b, 0x78, 0x4d, 0x7a, 0x59, 0x35, 0x59, 0x6a, 0x59, 0x33, 0x5a, 0x6d, 0x59, 0x78, 0x49, 0x69, + 0x77, 0x69, 0x62, 0x6d, 0x4a, 0x6d, 0x49, 0x6a, 0x6f, 0x69, 0x4d, 0x6a, 0x41, 0x79, 0x4d, 0x79, + 0x30, 0x78, 0x4d, 0x43, 0x30, 0x77, 0x4e, 0x56, 0x51, 0x77, 0x4d, 0x54, 0x6f, 0x77, 0x4d, 0x6a, + 0x6f, 0x77, 0x4f, 0x53, 0x73, 0x77, 0x4d, 0x6a, 0x6f, 0x77, 0x4d, 0x43, 0x4a, 0x39, 0x41, 0x68, + 0x30, 0x62, 0x56, 0x62, 0x78, 0x39, 0x53, 0x31, 0x4c, 0x52, 0x2d, 0x70, 0x66, 0x38, 0x68, 0x4c, + 0x57, 0x56, 0x52, 0x51, 0x50, 0x55, 0x66, 0x4b, 0x39, 0x7a, 0x72, 0x48, 0x5a, 0x76, 0x41, 0x37, + 0x41, 0x70, 0x4a, 0x35, 0x61, 0x5a, 0x58, 0x77, 0x68, 0x41, 0x37, 0x48, 0x31, 0x6a, 0x2d, 0x6b, + 0x48, 0x68, 0x63, 0x63, 0x42, 0x6a, 0x4f, 0x41, 0x47, 0x59, 0x58, 0x5a, 0x51, 0x54, 0x2d, 0x74, + 0x73, 0x37, 0x4a, 0x71, 0x33, 0x53, 0x4a, 0x6c, 0x7a, 0x6f, 0x35, 0x76, 0x74, 0x55, 0x6a, 0x47, + 0x42, 0x74, 0x44, 0x67, 0x22, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x12, 0x51, 0x0a, 0x17, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, + 0x65, 0x6e, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x14, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x45, 0x78, 0x70, 0x69, + 0x72, 0x65, 0x73, 0x41, 0x74, 0x3a, 0x1d, 0x92, 0x41, 0x1a, 0x0a, 0x18, 0x2a, 0x16, 0x52, 0x65, + 0x66, 0x72, 0x65, 0x73, 0x68, 0x20, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x19, 0x5a, 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x2f, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_refresh_token_proto_rawDescOnce sync.Once + file_rpc_refresh_token_proto_rawDescData = file_rpc_refresh_token_proto_rawDesc +) + +func file_rpc_refresh_token_proto_rawDescGZIP() []byte { + file_rpc_refresh_token_proto_rawDescOnce.Do(func() { + file_rpc_refresh_token_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_refresh_token_proto_rawDescData) + }) + return file_rpc_refresh_token_proto_rawDescData +} + +var file_rpc_refresh_token_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_rpc_refresh_token_proto_goTypes = []interface{}{ + (*RefreshTokenRequest)(nil), // 0: pb.RefreshTokenRequest + (*RefreshTokenResponse)(nil), // 1: pb.RefreshTokenResponse + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp +} +var file_rpc_refresh_token_proto_depIdxs = []int32{ + 2, // 0: pb.RefreshTokenResponse.access_token_expires_at:type_name -> google.protobuf.Timestamp + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_rpc_refresh_token_proto_init() } +func file_rpc_refresh_token_proto_init() { + if File_rpc_refresh_token_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_rpc_refresh_token_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RefreshTokenRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_refresh_token_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RefreshTokenResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_refresh_token_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rpc_refresh_token_proto_goTypes, + DependencyIndexes: file_rpc_refresh_token_proto_depIdxs, + MessageInfos: file_rpc_refresh_token_proto_msgTypes, + }.Build() + File_rpc_refresh_token_proto = out.File + file_rpc_refresh_token_proto_rawDesc = nil + file_rpc_refresh_token_proto_goTypes = nil + file_rpc_refresh_token_proto_depIdxs = nil +} diff --git a/bff/pb/rpc_update_account.pb.go b/bff/pb/rpc_update_account.pb.go new file mode 100644 index 0000000..5cba6de --- /dev/null +++ b/bff/pb/rpc_update_account.pb.go @@ -0,0 +1,339 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: rpc_update_account.proto + +package pb + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdateAccountRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Email *string `protobuf:"bytes,2,opt,name=email,proto3,oneof" json:"email,omitempty"` + Password *string `protobuf:"bytes,3,opt,name=password,proto3,oneof" json:"password,omitempty"` + Firstname *string `protobuf:"bytes,4,opt,name=firstname,proto3,oneof" json:"firstname,omitempty"` + Lastname *string `protobuf:"bytes,5,opt,name=lastname,proto3,oneof" json:"lastname,omitempty"` + Street *string `protobuf:"bytes,6,opt,name=street,proto3,oneof" json:"street,omitempty"` + City *string `protobuf:"bytes,7,opt,name=city,proto3,oneof" json:"city,omitempty"` + Zip *string `protobuf:"bytes,8,opt,name=zip,proto3,oneof" json:"zip,omitempty"` + Country *string `protobuf:"bytes,9,opt,name=country,proto3,oneof" json:"country,omitempty"` + Phone *string `protobuf:"bytes,10,opt,name=phone,proto3,oneof" json:"phone,omitempty"` + Birthday *timestamppb.Timestamp `protobuf:"bytes,11,opt,name=birthday,proto3,oneof" json:"birthday,omitempty"` +} + +func (x *UpdateAccountRequest) Reset() { + *x = UpdateAccountRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_update_account_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateAccountRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateAccountRequest) ProtoMessage() {} + +func (x *UpdateAccountRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_update_account_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateAccountRequest.ProtoReflect.Descriptor instead. +func (*UpdateAccountRequest) Descriptor() ([]byte, []int) { + return file_rpc_update_account_proto_rawDescGZIP(), []int{0} +} + +func (x *UpdateAccountRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateAccountRequest) GetEmail() string { + if x != nil && x.Email != nil { + return *x.Email + } + return "" +} + +func (x *UpdateAccountRequest) GetPassword() string { + if x != nil && x.Password != nil { + return *x.Password + } + return "" +} + +func (x *UpdateAccountRequest) GetFirstname() string { + if x != nil && x.Firstname != nil { + return *x.Firstname + } + return "" +} + +func (x *UpdateAccountRequest) GetLastname() string { + if x != nil && x.Lastname != nil { + return *x.Lastname + } + return "" +} + +func (x *UpdateAccountRequest) GetStreet() string { + if x != nil && x.Street != nil { + return *x.Street + } + return "" +} + +func (x *UpdateAccountRequest) GetCity() string { + if x != nil && x.City != nil { + return *x.City + } + return "" +} + +func (x *UpdateAccountRequest) GetZip() string { + if x != nil && x.Zip != nil { + return *x.Zip + } + return "" +} + +func (x *UpdateAccountRequest) GetCountry() string { + if x != nil && x.Country != nil { + return *x.Country + } + return "" +} + +func (x *UpdateAccountRequest) GetPhone() string { + if x != nil && x.Phone != nil { + return *x.Phone + } + return "" +} + +func (x *UpdateAccountRequest) GetBirthday() *timestamppb.Timestamp { + if x != nil { + return x.Birthday + } + return nil +} + +type UpdateAccountResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *UpdateAccountResponse) Reset() { + *x = UpdateAccountResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_update_account_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateAccountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateAccountResponse) ProtoMessage() {} + +func (x *UpdateAccountResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_update_account_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateAccountResponse.ProtoReflect.Descriptor instead. +func (*UpdateAccountResponse) Descriptor() ([]byte, []int) { + return file_rpc_update_account_proto_rawDescGZIP(), []int{1} +} + +func (x *UpdateAccountResponse) GetAccount() *Account { + if x != nil { + return x.Account + } + return nil +} + +var File_rpc_update_account_proto protoreflect.FileDescriptor + +var file_rpc_update_account_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x72, 0x70, 0x63, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x1f, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, + 0x61, 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, 0x1a, + 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, + 0x04, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x88, + 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, + 0x88, 0x01, 0x01, 0x12, 0x21, 0x0a, 0x09, 0x66, 0x69, 0x72, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x09, 0x66, 0x69, 0x72, 0x73, 0x74, 0x6e, + 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x03, 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, + 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, + 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x04, 0x52, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, + 0x74, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x63, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x09, 0x48, 0x05, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x12, 0x15, 0x0a, + 0x03, 0x7a, 0x69, 0x70, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x48, 0x06, 0x52, 0x03, 0x7a, 0x69, + 0x70, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x09, 0x48, 0x07, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, + 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x09, 0x48, 0x08, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x88, 0x01, 0x01, 0x12, 0x57, + 0x0a, 0x08, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x1a, 0x92, 0x41, + 0x17, 0x4a, 0x15, 0x22, 0x31, 0x39, 0x39, 0x30, 0x2d, 0x31, 0x30, 0x2d, 0x30, 0x35, 0x54, 0x30, + 0x30, 0x3a, 0x30, 0x30, 0x3a, 0x30, 0x5a, 0x22, 0x48, 0x09, 0x52, 0x08, 0x62, 0x69, 0x72, 0x74, + 0x68, 0x64, 0x61, 0x79, 0x88, 0x01, 0x01, 0x3a, 0x54, 0x92, 0x41, 0x51, 0x0a, 0x28, 0x2a, 0x0e, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x11, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x20, 0x61, 0x6e, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0xd2, 0x01, 0x02, 0x69, 0x64, 0x32, 0x25, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x31, + 0x39, 0x35, 0x2c, 0x20, 0x22, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x44, + 0x65, 0x61, 0x74, 0x68, 0x20, 0x53, 0x74, 0x61, 0x72, 0x20, 0x32, 0x22, 0x7d, 0x42, 0x08, 0x0a, + 0x06, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x70, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x66, 0x69, 0x72, 0x73, 0x74, 0x6e, 0x61, + 0x6d, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x6c, 0x61, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x42, + 0x09, 0x0a, 0x07, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x63, + 0x69, 0x74, 0x79, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x7a, 0x69, 0x70, 0x42, 0x0a, 0x0a, 0x08, 0x5f, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x70, 0x68, 0x6f, 0x6e, + 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x79, 0x22, 0x78, + 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x03, 0x92, 0x41, 0x00, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x3a, 0x33, 0x92, 0x41, 0x30, 0x0a, 0x2e, 0x2a, 0x0f, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x64, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x1b, 0x52, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, + 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x19, 0x5a, 0x17, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, + 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_update_account_proto_rawDescOnce sync.Once + file_rpc_update_account_proto_rawDescData = file_rpc_update_account_proto_rawDesc +) + +func file_rpc_update_account_proto_rawDescGZIP() []byte { + file_rpc_update_account_proto_rawDescOnce.Do(func() { + file_rpc_update_account_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_update_account_proto_rawDescData) + }) + return file_rpc_update_account_proto_rawDescData +} + +var file_rpc_update_account_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_rpc_update_account_proto_goTypes = []interface{}{ + (*UpdateAccountRequest)(nil), // 0: pb.UpdateAccountRequest + (*UpdateAccountResponse)(nil), // 1: pb.UpdateAccountResponse + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp + (*Account)(nil), // 3: pb.Account +} +var file_rpc_update_account_proto_depIdxs = []int32{ + 2, // 0: pb.UpdateAccountRequest.birthday:type_name -> google.protobuf.Timestamp + 3, // 1: pb.UpdateAccountResponse.account:type_name -> pb.Account + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_rpc_update_account_proto_init() } +func file_rpc_update_account_proto_init() { + if File_rpc_update_account_proto != nil { + return + } + file_account_proto_init() + if !protoimpl.UnsafeEnabled { + file_rpc_update_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateAccountRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_update_account_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateAccountResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_rpc_update_account_proto_msgTypes[0].OneofWrappers = []interface{}{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_update_account_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rpc_update_account_proto_goTypes, + DependencyIndexes: file_rpc_update_account_proto_depIdxs, + MessageInfos: file_rpc_update_account_proto_msgTypes, + }.Build() + File_rpc_update_account_proto = out.File + file_rpc_update_account_proto_rawDesc = nil + file_rpc_update_account_proto_goTypes = nil + file_rpc_update_account_proto_depIdxs = nil +} diff --git a/bff/pb/rpc_update_account_privacy.pb.go b/bff/pb/rpc_update_account_privacy.pb.go new file mode 100644 index 0000000..999033b --- /dev/null +++ b/bff/pb/rpc_update_account_privacy.pb.go @@ -0,0 +1,245 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: rpc_update_account_privacy.proto + +package pb + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdateAccountPrivacyRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + PrivacyAccepted *bool `protobuf:"varint,2,opt,name=privacy_accepted,json=privacyAccepted,proto3,oneof" json:"privacy_accepted,omitempty"` +} + +func (x *UpdateAccountPrivacyRequest) Reset() { + *x = UpdateAccountPrivacyRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_update_account_privacy_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateAccountPrivacyRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateAccountPrivacyRequest) ProtoMessage() {} + +func (x *UpdateAccountPrivacyRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_update_account_privacy_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateAccountPrivacyRequest.ProtoReflect.Descriptor instead. +func (*UpdateAccountPrivacyRequest) Descriptor() ([]byte, []int) { + return file_rpc_update_account_privacy_proto_rawDescGZIP(), []int{0} +} + +func (x *UpdateAccountPrivacyRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateAccountPrivacyRequest) GetPrivacyAccepted() bool { + if x != nil && x.PrivacyAccepted != nil { + return *x.PrivacyAccepted + } + return false +} + +type UpdateAccountPrivacyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *UpdateAccountPrivacyResponse) Reset() { + *x = UpdateAccountPrivacyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_update_account_privacy_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateAccountPrivacyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateAccountPrivacyResponse) ProtoMessage() {} + +func (x *UpdateAccountPrivacyResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_update_account_privacy_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateAccountPrivacyResponse.ProtoReflect.Descriptor instead. +func (*UpdateAccountPrivacyResponse) Descriptor() ([]byte, []int) { + return file_rpc_update_account_privacy_proto_rawDescGZIP(), []int{1} +} + +func (x *UpdateAccountPrivacyResponse) GetAccount() *Account { + if x != nil { + return x.Account + } + return nil +} + +var File_rpc_update_account_privacy_proto protoreflect.FileDescriptor + +var file_rpc_update_account_privacy_proto_rawDesc = []byte{ + 0x0a, 0x20, 0x72, 0x70, 0x63, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, + 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 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, 0x1a, 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa2, 0x02, 0x0a, 0x1b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x42, 0x10, 0x92, 0x41, 0x0d, 0x4a, 0x03, 0x31, 0x38, 0x35, 0xa2, 0x02, 0x05, 0x69, 0x6e, + 0x74, 0x36, 0x34, 0x52, 0x02, 0x69, 0x64, 0x12, 0x39, 0x0a, 0x10, 0x70, 0x72, 0x69, 0x76, 0x61, + 0x63, 0x79, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x08, 0x42, 0x09, 0x92, 0x41, 0x06, 0x4a, 0x04, 0x74, 0x72, 0x75, 0x65, 0x48, 0x00, 0x52, 0x0f, + 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x88, + 0x01, 0x01, 0x3a, 0x90, 0x01, 0x92, 0x41, 0x8c, 0x01, 0x0a, 0x62, 0x2a, 0x1e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x50, 0x72, 0x69, 0x76, + 0x61, 0x63, 0x79, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x32, 0x28, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x50, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x20, + 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0xd2, 0x01, 0x02, 0x69, 0x64, 0xd2, 0x01, 0x10, 0x70, 0x72, 0x69, + 0x76, 0x61, 0x63, 0x79, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x32, 0x26, 0x7b, + 0x22, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x31, 0x38, 0x35, 0x2c, 0x20, 0x22, 0x70, 0x72, 0x69, 0x76, + 0x61, 0x63, 0x79, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x74, + 0x72, 0x75, 0x65, 0x20, 0x7d, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, + 0x79, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x22, 0x83, 0x01, 0x0a, 0x1c, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x72, 0x69, 0x76, + 0x61, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, + 0x62, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x14, 0x92, 0x41, 0x11, 0x2a, 0x0f, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x26, 0x92, 0x41, 0x23, 0x0a, 0x21, 0x2a, + 0x1f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x20, + 0x50, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x42, 0x19, 0x5a, 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, + 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_update_account_privacy_proto_rawDescOnce sync.Once + file_rpc_update_account_privacy_proto_rawDescData = file_rpc_update_account_privacy_proto_rawDesc +) + +func file_rpc_update_account_privacy_proto_rawDescGZIP() []byte { + file_rpc_update_account_privacy_proto_rawDescOnce.Do(func() { + file_rpc_update_account_privacy_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_update_account_privacy_proto_rawDescData) + }) + return file_rpc_update_account_privacy_proto_rawDescData +} + +var file_rpc_update_account_privacy_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_rpc_update_account_privacy_proto_goTypes = []interface{}{ + (*UpdateAccountPrivacyRequest)(nil), // 0: pb.UpdateAccountPrivacyRequest + (*UpdateAccountPrivacyResponse)(nil), // 1: pb.UpdateAccountPrivacyResponse + (*Account)(nil), // 2: pb.Account +} +var file_rpc_update_account_privacy_proto_depIdxs = []int32{ + 2, // 0: pb.UpdateAccountPrivacyResponse.account:type_name -> pb.Account + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_rpc_update_account_privacy_proto_init() } +func file_rpc_update_account_privacy_proto_init() { + if File_rpc_update_account_privacy_proto != nil { + return + } + file_account_proto_init() + if !protoimpl.UnsafeEnabled { + file_rpc_update_account_privacy_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateAccountPrivacyRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_update_account_privacy_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateAccountPrivacyResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_rpc_update_account_privacy_proto_msgTypes[0].OneofWrappers = []interface{}{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_update_account_privacy_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rpc_update_account_privacy_proto_goTypes, + DependencyIndexes: file_rpc_update_account_privacy_proto_depIdxs, + MessageInfos: file_rpc_update_account_privacy_proto_msgTypes, + }.Build() + File_rpc_update_account_privacy_proto = out.File + file_rpc_update_account_privacy_proto_rawDesc = nil + file_rpc_update_account_privacy_proto_goTypes = nil + file_rpc_update_account_privacy_proto_depIdxs = nil +} diff --git a/bff/pb/service_df.pb.go b/bff/pb/service_df.pb.go new file mode 100644 index 0000000..e69c23c --- /dev/null +++ b/bff/pb/service_df.pb.go @@ -0,0 +1,162 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: service_df.proto + +package pb + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_service_df_proto protoreflect.FileDescriptor + +var file_service_df_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x64, 0x66, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, + 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 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, 0x1a, 0x18, 0x72, 0x70, 0x63, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, + 0x72, 0x70, 0x63, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x20, 0x72, 0x70, 0x63, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x72, 0x70, 0x63, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x72, 0x70, 0x63, 0x5f, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, + 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xb4, 0x02, + 0x0a, 0x08, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x42, 0x0a, 0x05, 0x4c, 0x6f, + 0x67, 0x69, 0x6e, 0x12, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, + 0x3a, 0x01, 0x2a, 0x22, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x5f, + 0x0a, 0x0c, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x17, + 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x66, + 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x76, + 0x31, 0x2f, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, + 0x74, 0x0a, 0x0c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x17, 0x2e, 0x70, 0x62, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x31, 0x92, 0x41, 0x12, 0x62, 0x10, 0x0a, 0x0e, 0x0a, 0x0a, 0x42, 0x65, 0x61, + 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x3a, + 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x0d, 0x92, 0x41, 0x0a, 0x12, 0x08, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x32, 0x8f, 0x03, 0x0a, 0x08, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x73, 0x12, 0x63, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, + 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, + 0x01, 0x2a, 0x22, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x78, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x92, 0x41, + 0x12, 0x62, 0x10, 0x0a, 0x0e, 0x0a, 0x0a, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, + 0x68, 0x12, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x01, 0x2a, 0x22, 0x12, 0x2f, 0x76, + 0x31, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x95, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x50, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x12, 0x1f, 0x2e, 0x70, 0x62, 0x2e, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x72, 0x69, 0x76, + 0x61, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x62, 0x2e, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x72, 0x69, + 0x76, 0x61, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3a, 0x92, 0x41, + 0x12, 0x62, 0x10, 0x0a, 0x0e, 0x0a, 0x0a, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, + 0x68, 0x12, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x01, 0x2a, 0x22, 0x1a, 0x2f, 0x76, + 0x31, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x5f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x63, 0x79, 0x1a, 0x0c, 0x92, 0x41, 0x09, 0x12, 0x07, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x9f, 0x01, 0x92, 0x41, 0x82, 0x01, 0x12, 0x44, 0x0a, + 0x06, 0x64, 0x66, 0x20, 0x41, 0x50, 0x49, 0x22, 0x35, 0x0a, 0x06, 0x69, 0x74, 0x73, 0x73, 0x63, + 0x62, 0x12, 0x1c, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x1a, + 0x0d, 0x64, 0x65, 0x76, 0x40, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2e, 0x64, 0x65, 0x32, 0x03, + 0x31, 0x2e, 0x30, 0x2a, 0x02, 0x01, 0x02, 0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x5a, 0x12, 0x0a, 0x10, 0x0a, + 0x0a, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x02, 0x08, 0x02, 0x5a, + 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, + 0x63, 0x62, 0x2f, 0x64, 0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_service_df_proto_goTypes = []interface{}{ + (*LoginRequest)(nil), // 0: pb.LoginRequest + (*RefreshTokenRequest)(nil), // 1: pb.RefreshTokenRequest + (*BlockSessionRequest)(nil), // 2: pb.BlockSessionRequest + (*CreateAccountRequest)(nil), // 3: pb.CreateAccountRequest + (*UpdateAccountRequest)(nil), // 4: pb.UpdateAccountRequest + (*UpdateAccountPrivacyRequest)(nil), // 5: pb.UpdateAccountPrivacyRequest + (*LoginResponse)(nil), // 6: pb.LoginResponse + (*RefreshTokenResponse)(nil), // 7: pb.RefreshTokenResponse + (*BlockSessionResponse)(nil), // 8: pb.BlockSessionResponse + (*CreateAccountResponse)(nil), // 9: pb.CreateAccountResponse + (*UpdateAccountResponse)(nil), // 10: pb.UpdateAccountResponse + (*UpdateAccountPrivacyResponse)(nil), // 11: pb.UpdateAccountPrivacyResponse +} +var file_service_df_proto_depIdxs = []int32{ + 0, // 0: pb.Sessions.Login:input_type -> pb.LoginRequest + 1, // 1: pb.Sessions.RefreshToken:input_type -> pb.RefreshTokenRequest + 2, // 2: pb.Sessions.BlockSession:input_type -> pb.BlockSessionRequest + 3, // 3: pb.Accounts.CreateAccount:input_type -> pb.CreateAccountRequest + 4, // 4: pb.Accounts.UpdateAccount:input_type -> pb.UpdateAccountRequest + 5, // 5: pb.Accounts.UpdateAccountPrivacy:input_type -> pb.UpdateAccountPrivacyRequest + 6, // 6: pb.Sessions.Login:output_type -> pb.LoginResponse + 7, // 7: pb.Sessions.RefreshToken:output_type -> pb.RefreshTokenResponse + 8, // 8: pb.Sessions.BlockSession:output_type -> pb.BlockSessionResponse + 9, // 9: pb.Accounts.CreateAccount:output_type -> pb.CreateAccountResponse + 10, // 10: pb.Accounts.UpdateAccount:output_type -> pb.UpdateAccountResponse + 11, // 11: pb.Accounts.UpdateAccountPrivacy:output_type -> pb.UpdateAccountPrivacyResponse + 6, // [6:12] is the sub-list for method output_type + 0, // [0:6] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_service_df_proto_init() } +func file_service_df_proto_init() { + if File_service_df_proto != nil { + return + } + file_rpc_create_account_proto_init() + file_rpc_update_account_proto_init() + file_rpc_block_session_proto_init() + file_rpc_update_account_privacy_proto_init() + file_rpc_login_proto_init() + file_rpc_refresh_token_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_service_df_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 2, + }, + GoTypes: file_service_df_proto_goTypes, + DependencyIndexes: file_service_df_proto_depIdxs, + }.Build() + File_service_df_proto = out.File + file_service_df_proto_rawDesc = nil + file_service_df_proto_goTypes = nil + file_service_df_proto_depIdxs = nil +} diff --git a/bff/pb/service_df.pb.gw.go b/bff/pb/service_df.pb.gw.go new file mode 100644 index 0000000..30a3b15 --- /dev/null +++ b/bff/pb/service_df.pb.gw.go @@ -0,0 +1,650 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: service_df.proto + +/* +Package pb is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package pb + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +func request_Sessions_Login_0(ctx context.Context, marshaler runtime.Marshaler, client SessionsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LoginRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Sessions_Login_0(ctx context.Context, marshaler runtime.Marshaler, server SessionsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LoginRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Login(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Sessions_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, client SessionsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RefreshTokenRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RefreshToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Sessions_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, server SessionsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RefreshTokenRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RefreshToken(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Sessions_BlockSession_0(ctx context.Context, marshaler runtime.Marshaler, client SessionsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq BlockSessionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.BlockSession(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Sessions_BlockSession_0(ctx context.Context, marshaler runtime.Marshaler, server SessionsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq BlockSessionRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.BlockSession(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Accounts_CreateAccount_0(ctx context.Context, marshaler runtime.Marshaler, client AccountsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateAccountRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Accounts_CreateAccount_0(ctx context.Context, marshaler runtime.Marshaler, server AccountsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateAccountRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreateAccount(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Accounts_UpdateAccount_0(ctx context.Context, marshaler runtime.Marshaler, client AccountsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateAccountRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UpdateAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Accounts_UpdateAccount_0(ctx context.Context, marshaler runtime.Marshaler, server AccountsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateAccountRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UpdateAccount(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Accounts_UpdateAccountPrivacy_0(ctx context.Context, marshaler runtime.Marshaler, client AccountsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateAccountPrivacyRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UpdateAccountPrivacy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Accounts_UpdateAccountPrivacy_0(ctx context.Context, marshaler runtime.Marshaler, server AccountsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateAccountPrivacyRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UpdateAccountPrivacy(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterSessionsHandlerServer registers the http handlers for service Sessions to "mux". +// UnaryRPC :call SessionsServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSessionsHandlerFromEndpoint instead. +func RegisterSessionsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SessionsServer) error { + + mux.Handle("POST", pattern_Sessions_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Sessions/Login", runtime.WithHTTPPathPattern("/v1/login")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Sessions_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Sessions_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Sessions_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Sessions/RefreshToken", runtime.WithHTTPPathPattern("/v1/refresh_token")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Sessions_RefreshToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Sessions_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Sessions_BlockSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Sessions/BlockSession", runtime.WithHTTPPathPattern("/v1/block_session")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Sessions_BlockSession_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Sessions_BlockSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterAccountsHandlerServer registers the http handlers for service Accounts to "mux". +// UnaryRPC :call AccountsServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAccountsHandlerFromEndpoint instead. +func RegisterAccountsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AccountsServer) error { + + mux.Handle("POST", pattern_Accounts_CreateAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Accounts/CreateAccount", runtime.WithHTTPPathPattern("/v1/create_account")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Accounts_CreateAccount_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_CreateAccount_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Accounts_UpdateAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Accounts/UpdateAccount", runtime.WithHTTPPathPattern("/v1/update_account")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Accounts_UpdateAccount_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_UpdateAccount_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Accounts_UpdateAccountPrivacy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Accounts/UpdateAccountPrivacy", runtime.WithHTTPPathPattern("/v1/update_account_privacy")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Accounts_UpdateAccountPrivacy_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_UpdateAccountPrivacy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterSessionsHandlerFromEndpoint is same as RegisterSessionsHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterSessionsHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.DialContext(ctx, endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterSessionsHandler(ctx, mux, conn) +} + +// RegisterSessionsHandler registers the http handlers for service Sessions to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterSessionsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterSessionsHandlerClient(ctx, mux, NewSessionsClient(conn)) +} + +// RegisterSessionsHandlerClient registers the http handlers for service Sessions +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SessionsClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SessionsClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "SessionsClient" to call the correct interceptors. +func RegisterSessionsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SessionsClient) error { + + mux.Handle("POST", pattern_Sessions_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Sessions/Login", runtime.WithHTTPPathPattern("/v1/login")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Sessions_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Sessions_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Sessions_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Sessions/RefreshToken", runtime.WithHTTPPathPattern("/v1/refresh_token")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Sessions_RefreshToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Sessions_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Sessions_BlockSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Sessions/BlockSession", runtime.WithHTTPPathPattern("/v1/block_session")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Sessions_BlockSession_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Sessions_BlockSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Sessions_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "login"}, "")) + + pattern_Sessions_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "refresh_token"}, "")) + + pattern_Sessions_BlockSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "block_session"}, "")) +) + +var ( + forward_Sessions_Login_0 = runtime.ForwardResponseMessage + + forward_Sessions_RefreshToken_0 = runtime.ForwardResponseMessage + + forward_Sessions_BlockSession_0 = runtime.ForwardResponseMessage +) + +// RegisterAccountsHandlerFromEndpoint is same as RegisterAccountsHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterAccountsHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.DialContext(ctx, endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterAccountsHandler(ctx, mux, conn) +} + +// RegisterAccountsHandler registers the http handlers for service Accounts to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterAccountsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterAccountsHandlerClient(ctx, mux, NewAccountsClient(conn)) +} + +// RegisterAccountsHandlerClient registers the http handlers for service Accounts +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AccountsClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AccountsClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "AccountsClient" to call the correct interceptors. +func RegisterAccountsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AccountsClient) error { + + mux.Handle("POST", pattern_Accounts_CreateAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Accounts/CreateAccount", runtime.WithHTTPPathPattern("/v1/create_account")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Accounts_CreateAccount_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_CreateAccount_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Accounts_UpdateAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Accounts/UpdateAccount", runtime.WithHTTPPathPattern("/v1/update_account")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Accounts_UpdateAccount_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_UpdateAccount_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Accounts_UpdateAccountPrivacy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Accounts/UpdateAccountPrivacy", runtime.WithHTTPPathPattern("/v1/update_account_privacy")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Accounts_UpdateAccountPrivacy_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_UpdateAccountPrivacy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Accounts_CreateAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "create_account"}, "")) + + pattern_Accounts_UpdateAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "update_account"}, "")) + + pattern_Accounts_UpdateAccountPrivacy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "update_account_privacy"}, "")) +) + +var ( + forward_Accounts_CreateAccount_0 = runtime.ForwardResponseMessage + + forward_Accounts_UpdateAccount_0 = runtime.ForwardResponseMessage + + forward_Accounts_UpdateAccountPrivacy_0 = runtime.ForwardResponseMessage +) diff --git a/bff/pb/service_df_grpc.pb.go b/bff/pb/service_df_grpc.pb.go new file mode 100644 index 0000000..2c4f06f --- /dev/null +++ b/bff/pb/service_df_grpc.pb.go @@ -0,0 +1,347 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.19.6 +// source: service_df.proto + +package pb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Sessions_Login_FullMethodName = "/pb.Sessions/Login" + Sessions_RefreshToken_FullMethodName = "/pb.Sessions/RefreshToken" + Sessions_BlockSession_FullMethodName = "/pb.Sessions/BlockSession" +) + +// SessionsClient is the client API for Sessions service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type SessionsClient interface { + Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) + RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) + BlockSession(ctx context.Context, in *BlockSessionRequest, opts ...grpc.CallOption) (*BlockSessionResponse, error) +} + +type sessionsClient struct { + cc grpc.ClientConnInterface +} + +func NewSessionsClient(cc grpc.ClientConnInterface) SessionsClient { + return &sessionsClient{cc} +} + +func (c *sessionsClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { + out := new(LoginResponse) + err := c.cc.Invoke(ctx, Sessions_Login_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sessionsClient) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) { + out := new(RefreshTokenResponse) + err := c.cc.Invoke(ctx, Sessions_RefreshToken_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sessionsClient) BlockSession(ctx context.Context, in *BlockSessionRequest, opts ...grpc.CallOption) (*BlockSessionResponse, error) { + out := new(BlockSessionResponse) + err := c.cc.Invoke(ctx, Sessions_BlockSession_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SessionsServer is the server API for Sessions service. +// All implementations must embed UnimplementedSessionsServer +// for forward compatibility +type SessionsServer interface { + Login(context.Context, *LoginRequest) (*LoginResponse, error) + RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) + BlockSession(context.Context, *BlockSessionRequest) (*BlockSessionResponse, error) + mustEmbedUnimplementedSessionsServer() +} + +// UnimplementedSessionsServer must be embedded to have forward compatible implementations. +type UnimplementedSessionsServer struct { +} + +func (UnimplementedSessionsServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") +} +func (UnimplementedSessionsServer) RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefreshToken not implemented") +} +func (UnimplementedSessionsServer) BlockSession(context.Context, *BlockSessionRequest) (*BlockSessionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BlockSession not implemented") +} +func (UnimplementedSessionsServer) mustEmbedUnimplementedSessionsServer() {} + +// UnsafeSessionsServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SessionsServer will +// result in compilation errors. +type UnsafeSessionsServer interface { + mustEmbedUnimplementedSessionsServer() +} + +func RegisterSessionsServer(s grpc.ServiceRegistrar, srv SessionsServer) { + s.RegisterService(&Sessions_ServiceDesc, srv) +} + +func _Sessions_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoginRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SessionsServer).Login(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Sessions_Login_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SessionsServer).Login(ctx, req.(*LoginRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Sessions_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RefreshTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SessionsServer).RefreshToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Sessions_RefreshToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SessionsServer).RefreshToken(ctx, req.(*RefreshTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Sessions_BlockSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BlockSessionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SessionsServer).BlockSession(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Sessions_BlockSession_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SessionsServer).BlockSession(ctx, req.(*BlockSessionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Sessions_ServiceDesc is the grpc.ServiceDesc for Sessions service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Sessions_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "pb.Sessions", + HandlerType: (*SessionsServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Login", + Handler: _Sessions_Login_Handler, + }, + { + MethodName: "RefreshToken", + Handler: _Sessions_RefreshToken_Handler, + }, + { + MethodName: "BlockSession", + Handler: _Sessions_BlockSession_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "service_df.proto", +} + +const ( + Accounts_CreateAccount_FullMethodName = "/pb.Accounts/CreateAccount" + Accounts_UpdateAccount_FullMethodName = "/pb.Accounts/UpdateAccount" + Accounts_UpdateAccountPrivacy_FullMethodName = "/pb.Accounts/UpdateAccountPrivacy" +) + +// AccountsClient is the client API for Accounts service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AccountsClient interface { + CreateAccount(ctx context.Context, in *CreateAccountRequest, opts ...grpc.CallOption) (*CreateAccountResponse, error) + UpdateAccount(ctx context.Context, in *UpdateAccountRequest, opts ...grpc.CallOption) (*UpdateAccountResponse, error) + UpdateAccountPrivacy(ctx context.Context, in *UpdateAccountPrivacyRequest, opts ...grpc.CallOption) (*UpdateAccountPrivacyResponse, error) +} + +type accountsClient struct { + cc grpc.ClientConnInterface +} + +func NewAccountsClient(cc grpc.ClientConnInterface) AccountsClient { + return &accountsClient{cc} +} + +func (c *accountsClient) CreateAccount(ctx context.Context, in *CreateAccountRequest, opts ...grpc.CallOption) (*CreateAccountResponse, error) { + out := new(CreateAccountResponse) + err := c.cc.Invoke(ctx, Accounts_CreateAccount_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *accountsClient) UpdateAccount(ctx context.Context, in *UpdateAccountRequest, opts ...grpc.CallOption) (*UpdateAccountResponse, error) { + out := new(UpdateAccountResponse) + err := c.cc.Invoke(ctx, Accounts_UpdateAccount_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *accountsClient) UpdateAccountPrivacy(ctx context.Context, in *UpdateAccountPrivacyRequest, opts ...grpc.CallOption) (*UpdateAccountPrivacyResponse, error) { + out := new(UpdateAccountPrivacyResponse) + err := c.cc.Invoke(ctx, Accounts_UpdateAccountPrivacy_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AccountsServer is the server API for Accounts service. +// All implementations must embed UnimplementedAccountsServer +// for forward compatibility +type AccountsServer interface { + CreateAccount(context.Context, *CreateAccountRequest) (*CreateAccountResponse, error) + UpdateAccount(context.Context, *UpdateAccountRequest) (*UpdateAccountResponse, error) + UpdateAccountPrivacy(context.Context, *UpdateAccountPrivacyRequest) (*UpdateAccountPrivacyResponse, error) + mustEmbedUnimplementedAccountsServer() +} + +// UnimplementedAccountsServer must be embedded to have forward compatible implementations. +type UnimplementedAccountsServer struct { +} + +func (UnimplementedAccountsServer) CreateAccount(context.Context, *CreateAccountRequest) (*CreateAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateAccount not implemented") +} +func (UnimplementedAccountsServer) UpdateAccount(context.Context, *UpdateAccountRequest) (*UpdateAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateAccount not implemented") +} +func (UnimplementedAccountsServer) UpdateAccountPrivacy(context.Context, *UpdateAccountPrivacyRequest) (*UpdateAccountPrivacyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateAccountPrivacy not implemented") +} +func (UnimplementedAccountsServer) mustEmbedUnimplementedAccountsServer() {} + +// UnsafeAccountsServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AccountsServer will +// result in compilation errors. +type UnsafeAccountsServer interface { + mustEmbedUnimplementedAccountsServer() +} + +func RegisterAccountsServer(s grpc.ServiceRegistrar, srv AccountsServer) { + s.RegisterService(&Accounts_ServiceDesc, srv) +} + +func _Accounts_CreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateAccountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccountsServer).CreateAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Accounts_CreateAccount_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccountsServer).CreateAccount(ctx, req.(*CreateAccountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Accounts_UpdateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateAccountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccountsServer).UpdateAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Accounts_UpdateAccount_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccountsServer).UpdateAccount(ctx, req.(*UpdateAccountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Accounts_UpdateAccountPrivacy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateAccountPrivacyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccountsServer).UpdateAccountPrivacy(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Accounts_UpdateAccountPrivacy_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccountsServer).UpdateAccountPrivacy(ctx, req.(*UpdateAccountPrivacyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Accounts_ServiceDesc is the grpc.ServiceDesc for Accounts service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Accounts_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "pb.Accounts", + HandlerType: (*AccountsServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateAccount", + Handler: _Accounts_CreateAccount_Handler, + }, + { + MethodName: "UpdateAccount", + Handler: _Accounts_UpdateAccount_Handler, + }, + { + MethodName: "UpdateAccountPrivacy", + Handler: _Accounts_UpdateAccountPrivacy_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "service_df.proto", +} diff --git a/bff/proto/account.proto b/bff/proto/account.proto new file mode 100644 index 0000000..ea090dc --- /dev/null +++ b/bff/proto/account.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package pb; + +import "google/protobuf/timestamp.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +option go_package = "github.com/itsscb/df/pb"; + +message Account { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Account"; + }; + example: "{\"id\": 185,\"email\": \"john.doe@example.com\", \"firstname\": \"John\", \"lastname\": \"Doe\", \"phone\": \"\", \"street\": \"Death Star 2\", \"zip\": \"0815\", \"city\": \"New York\", \"country\": \"USA\", \"birthday\": \"1990-10-05T00:00:0Z\", \"privacy_accepted\": false, \"privacy_accepted_date\": \"0001-01-01T00:00:00Z\", \"creator\": \"john.doe@example.com\", \"created\": \"2023-10-05T02:30:53Z\", \"changer\": \"john.doe@example.com\", \"changed\": \"2023-10-05T02:30:53Z\"}"; + }; + int64 id = 1; + string email = 2; + string firstname = 3; + string lastname = 4; + string street = 5; + string city = 6; + string zip = 7; + string country = 8; + google.protobuf.Timestamp birthday = 9; + string phone = 10; + bool privacy_accepted = 11; + google.protobuf.Timestamp privacy_accepted_date = 12; + int32 permission_level = 13; + string creator = 14; + google.protobuf.Timestamp created = 15; + string changer = 16; + google.protobuf.Timestamp changed = 17; +} \ No newline at end of file diff --git a/bff/proto/google/api/annotations.proto b/bff/proto/google/api/annotations.proto new file mode 100644 index 0000000..8ff4209 --- /dev/null +++ b/bff/proto/google/api/annotations.proto @@ -0,0 +1,31 @@ +// Copyright 2015 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/api/http.proto"; +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "AnnotationsProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.MethodOptions { + // See `HttpRule`. + HttpRule http = 72295728; +} \ No newline at end of file diff --git a/bff/proto/google/api/field_behavior.proto b/bff/proto/google/api/field_behavior.proto new file mode 100644 index 0000000..128799c --- /dev/null +++ b/bff/proto/google/api/field_behavior.proto @@ -0,0 +1,104 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "FieldBehaviorProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.FieldOptions { + // A designation of a specific field behavior (required, output only, etc.) + // in protobuf messages. + // + // Examples: + // + // string name = 1 [(google.api.field_behavior) = REQUIRED]; + // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + // google.protobuf.Duration ttl = 1 + // [(google.api.field_behavior) = INPUT_ONLY]; + // google.protobuf.Timestamp expire_time = 1 + // [(google.api.field_behavior) = OUTPUT_ONLY, + // (google.api.field_behavior) = IMMUTABLE]; + repeated google.api.FieldBehavior field_behavior = 1052; +} + +// An indicator of the behavior of a given field (for example, that a field +// is required in requests, or given as output but ignored as input). +// This **does not** change the behavior in protocol buffers itself; it only +// denotes the behavior and may affect how API tooling handles the field. +// +// Note: This enum **may** receive new values in the future. +enum FieldBehavior { + // Conventional default for enums. Do not use this. + FIELD_BEHAVIOR_UNSPECIFIED = 0; + + // Specifically denotes a field as optional. + // While all fields in protocol buffers are optional, this may be specified + // for emphasis if appropriate. + OPTIONAL = 1; + + // Denotes a field as required. + // This indicates that the field **must** be provided as part of the request, + // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). + REQUIRED = 2; + + // Denotes a field as output only. + // This indicates that the field is provided in responses, but including the + // field in a request does nothing (the server *must* ignore it and + // *must not* throw an error as a result of the field's presence). + OUTPUT_ONLY = 3; + + // Denotes a field as input only. + // This indicates that the field is provided in requests, and the + // corresponding field is not included in output. + INPUT_ONLY = 4; + + // Denotes a field as immutable. + // This indicates that the field may be set once in a request to create a + // resource, but may not be changed thereafter. + IMMUTABLE = 5; + + // Denotes that a (repeated) field is an unordered list. + // This indicates that the service may provide the elements of the list + // in any arbitrary order, rather than the order the user originally + // provided. Additionally, the list's order may or may not be stable. + UNORDERED_LIST = 6; + + // Denotes that this field returns a non-empty default value if not set. + // This indicates that if the user provides the empty value in a request, + // a non-empty value will be returned. The user will not be aware of what + // non-empty value to expect. + NON_EMPTY_DEFAULT = 7; + + // Denotes that the field in a resource (a message annotated with + // google.api.resource) is used in the resource name to uniquely identify the + // resource. For AIP-compliant APIs, this should only be applied to the + // `name` field on the resource. + // + // This behavior should not be applied to references to other resources within + // the message. + // + // The identifier field of resources often have different field behavior + // depending on the request it is embedded in (e.g. for Create methods name + // is optional and unused, while for Update methods it is required). Instead + // of method-specific annotations, only `IDENTIFIER` is required. + IDENTIFIER = 8; +} \ No newline at end of file diff --git a/bff/proto/google/api/http.proto b/bff/proto/google/api/http.proto new file mode 100644 index 0000000..c839238 --- /dev/null +++ b/bff/proto/google/api/http.proto @@ -0,0 +1,379 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "HttpProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// Defines the HTTP configuration for an API service. It contains a list of +// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method +// to one or more HTTP REST API methods. +message Http { + // A list of HTTP configuration rules that apply to individual API methods. + // + // **NOTE:** All service configuration rules follow "last one wins" order. + repeated HttpRule rules = 1; + + // When set to true, URL path parameters will be fully URI-decoded except in + // cases of single segment matches in reserved expansion, where "%2F" will be + // left encoded. + // + // The default behavior is to not decode RFC 6570 reserved characters in multi + // segment matches. + bool fully_decode_reserved_expansion = 2; +} + +// # gRPC Transcoding +// +// gRPC Transcoding is a feature for mapping between a gRPC method and one or +// more HTTP REST endpoints. It allows developers to build a single API service +// that supports both gRPC APIs and REST APIs. Many systems, including [Google +// APIs](https://github.com/googleapis/googleapis), +// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC +// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), +// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature +// and use it for large scale production services. +// +// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies +// how different portions of the gRPC request message are mapped to the URL +// path, URL query parameters, and HTTP request body. It also controls how the +// gRPC response message is mapped to the HTTP response body. `HttpRule` is +// typically specified as an `google.api.http` annotation on the gRPC method. +// +// Each mapping specifies a URL path template and an HTTP method. The path +// template may refer to one or more fields in the gRPC request message, as long +// as each field is a non-repeated field with a primitive (non-message) type. +// The path template controls how fields of the request message are mapped to +// the URL path. +// +// Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/{name=messages/*}" +// }; +// } +// } +// message GetMessageRequest { +// string name = 1; // Mapped to URL path. +// } +// message Message { +// string text = 1; // The resource content. +// } +// +// This enables an HTTP REST to gRPC mapping as below: +// +// HTTP | gRPC +// -----|----- +// `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")` +// +// Any fields in the request message which are not bound by the path template +// automatically become HTTP query parameters if there is no HTTP request body. +// For example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get:"/v1/messages/{message_id}" +// }; +// } +// } +// message GetMessageRequest { +// message SubMessage { +// string subfield = 1; +// } +// string message_id = 1; // Mapped to URL path. +// int64 revision = 2; // Mapped to URL query parameter `revision`. +// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. +// } +// +// This enables a HTTP JSON to RPC mapping as below: +// +// HTTP | gRPC +// -----|----- +// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | +// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: +// "foo"))` +// +// Note that fields which are mapped to URL query parameters must have a +// primitive type or a repeated primitive type or a non-repeated message type. +// In the case of a repeated type, the parameter can be repeated in the URL +// as `...?param=A¶m=B`. In the case of a message type, each field of the +// message is mapped to a separate parameter, such as +// `...?foo.a=A&foo.b=B&foo.c=C`. +// +// For HTTP methods that allow a request body, the `body` field +// specifies the mapping. Consider a REST update method on the +// message resource collection: +// +// service Messaging { +// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "message" +// }; +// } +// } +// message UpdateMessageRequest { +// string message_id = 1; // mapped to the URL +// Message message = 2; // mapped to the body +// } +// +// The following HTTP JSON to RPC mapping is enabled, where the +// representation of the JSON in the request body is determined by +// protos JSON encoding: +// +// HTTP | gRPC +// -----|----- +// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: +// "123456" message { text: "Hi!" })` +// +// The special name `*` can be used in the body mapping to define that +// every field not bound by the path template should be mapped to the +// request body. This enables the following alternative definition of +// the update method: +// +// service Messaging { +// rpc UpdateMessage(Message) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "*" +// }; +// } +// } +// message Message { +// string message_id = 1; +// string text = 2; +// } +// +// +// The following HTTP JSON to RPC mapping is enabled: +// +// HTTP | gRPC +// -----|----- +// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: +// "123456" text: "Hi!")` +// +// Note that when using `*` in the body mapping, it is not possible to +// have HTTP parameters, as all fields not bound by the path end in +// the body. This makes this option more rarely used in practice when +// defining REST APIs. The common usage of `*` is in custom methods +// which don't use the URL at all for transferring data. +// +// It is possible to define multiple HTTP methods for one RPC by using +// the `additional_bindings` option. Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/messages/{message_id}" +// additional_bindings { +// get: "/v1/users/{user_id}/messages/{message_id}" +// } +// }; +// } +// } +// message GetMessageRequest { +// string message_id = 1; +// string user_id = 2; +// } +// +// This enables the following two alternative HTTP JSON to RPC mappings: +// +// HTTP | gRPC +// -----|----- +// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` +// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: +// "123456")` +// +// ## Rules for HTTP mapping +// +// 1. Leaf request fields (recursive expansion nested messages in the request +// message) are classified into three categories: +// - Fields referred by the path template. They are passed via the URL path. +// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They +// are passed via the HTTP +// request body. +// - All other fields are passed via the URL query parameters, and the +// parameter name is the field path in the request message. A repeated +// field can be represented as multiple query parameters under the same +// name. +// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL +// query parameter, all fields +// are passed via URL path and HTTP request body. +// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP +// request body, all +// fields are passed via URL path and URL query parameters. +// +// ### Path template syntax +// +// Template = "/" Segments [ Verb ] ; +// Segments = Segment { "/" Segment } ; +// Segment = "*" | "**" | LITERAL | Variable ; +// Variable = "{" FieldPath [ "=" Segments ] "}" ; +// FieldPath = IDENT { "." IDENT } ; +// Verb = ":" LITERAL ; +// +// The syntax `*` matches a single URL path segment. The syntax `**` matches +// zero or more URL path segments, which must be the last part of the URL path +// except the `Verb`. +// +// The syntax `Variable` matches part of the URL path as specified by its +// template. A variable template must not contain other variables. If a variable +// matches a single path segment, its template may be omitted, e.g. `{var}` +// is equivalent to `{var=*}`. +// +// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` +// contains any reserved character, such characters should be percent-encoded +// before the matching. +// +// If a variable contains exactly one path segment, such as `"{var}"` or +// `"{var=*}"`, when such a variable is expanded into a URL path on the client +// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The +// server side does the reverse decoding. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{var}`. +// +// If a variable contains multiple path segments, such as `"{var=foo/*}"` +// or `"{var=**}"`, when such a variable is expanded into a URL path on the +// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. +// The server side does the reverse decoding, except "%2F" and "%2f" are left +// unchanged. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{+var}`. +// +// ## Using gRPC API Service Configuration +// +// gRPC API Service Configuration (service config) is a configuration language +// for configuring a gRPC service to become a user-facing product. The +// service config is simply the YAML representation of the `google.api.Service` +// proto message. +// +// As an alternative to annotating your proto file, you can configure gRPC +// transcoding in your service config YAML files. You do this by specifying a +// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same +// effect as the proto annotation. This can be particularly useful if you +// have a proto that is reused in multiple services. Note that any transcoding +// specified in the service config will override any matching transcoding +// configuration in the proto. +// +// Example: +// +// http: +// rules: +// # Selects a gRPC method and applies HttpRule to it. +// - selector: example.v1.Messaging.GetMessage +// get: /v1/messages/{message_id}/{sub.subfield} +// +// ## Special notes +// +// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the +// proto to JSON conversion must follow the [proto3 +// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). +// +// While the single segment variable follows the semantics of +// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String +// Expansion, the multi segment variable **does not** follow RFC 6570 Section +// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion +// does not expand special characters like `?` and `#`, which would lead +// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding +// for multi segment variables. +// +// The path variables **must not** refer to any repeated or mapped field, +// because client libraries are not capable of handling such variable expansion. +// +// The path variables **must not** capture the leading "/" character. The reason +// is that the most common use case "{var}" does not capture the leading "/" +// character. For consistency, all path variables must share the same behavior. +// +// Repeated message fields must not be mapped to URL query parameters, because +// no client library can support such complicated mapping. +// +// If an API needs to use a JSON array for request or response body, it can map +// the request or response body to a repeated field. However, some gRPC +// Transcoding implementations may not support this feature. +message HttpRule { + // Selects a method to which this rule applies. + // + // Refer to [selector][google.api.DocumentationRule.selector] for syntax + // details. + string selector = 1; + + // Determines the URL pattern is matched by this rules. This pattern can be + // used with any of the {get|put|post|delete|patch} methods. A custom method + // can be defined using the 'custom' field. + oneof pattern { + // Maps to HTTP GET. Used for listing and getting information about + // resources. + string get = 2; + + // Maps to HTTP PUT. Used for replacing a resource. + string put = 3; + + // Maps to HTTP POST. Used for creating a resource or performing an action. + string post = 4; + + // Maps to HTTP DELETE. Used for deleting a resource. + string delete = 5; + + // Maps to HTTP PATCH. Used for updating a resource. + string patch = 6; + + // The custom pattern is used for specifying an HTTP method that is not + // included in the `pattern` field, such as HEAD, or "*" to leave the + // HTTP method unspecified for this rule. The wild-card rule is useful + // for services that provide content to Web (HTML) clients. + CustomHttpPattern custom = 8; + } + + // The name of the request field whose value is mapped to the HTTP request + // body, or `*` for mapping all request fields not captured by the path + // pattern to the HTTP body, or omitted for not having any HTTP request body. + // + // NOTE: the referred field must be present at the top-level of the request + // message type. + string body = 7; + + // Optional. The name of the response field whose value is mapped to the HTTP + // response body. When omitted, the entire response message will be used + // as the HTTP response body. + // + // NOTE: The referred field must be present at the top-level of the response + // message type. + string response_body = 12; + + // Additional HTTP bindings for the selector. Nested bindings must + // not contain an `additional_bindings` field themselves (that is, + // the nesting may only be one level deep). + repeated HttpRule additional_bindings = 11; +} + +// A custom pattern is used for defining custom HTTP verb. +message CustomHttpPattern { + // The name of this custom HTTP verb. + string kind = 1; + + // The path matched by this custom verb. + string path = 2; +} \ No newline at end of file diff --git a/bff/proto/google/api/httpbody.proto b/bff/proto/google/api/httpbody.proto new file mode 100644 index 0000000..e11a050 --- /dev/null +++ b/bff/proto/google/api/httpbody.proto @@ -0,0 +1,81 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/any.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; +option java_multiple_files = true; +option java_outer_classname = "HttpBodyProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// Message that represents an arbitrary HTTP body. It should only be used for +// payload formats that can't be represented as JSON, such as raw binary or +// an HTML page. +// +// +// This message can be used both in streaming and non-streaming API methods in +// the request as well as the response. +// +// It can be used as a top-level request field, which is convenient if one +// wants to extract parameters from either the URL or HTTP template into the +// request fields and also want access to the raw HTTP body. +// +// Example: +// +// message GetResourceRequest { +// // A unique request id. +// string request_id = 1; +// +// // The raw HTTP body is bound to this field. +// google.api.HttpBody http_body = 2; +// +// } +// +// service ResourceService { +// rpc GetResource(GetResourceRequest) +// returns (google.api.HttpBody); +// rpc UpdateResource(google.api.HttpBody) +// returns (google.protobuf.Empty); +// +// } +// +// Example with streaming methods: +// +// service CaldavService { +// rpc GetCalendar(stream google.api.HttpBody) +// returns (stream google.api.HttpBody); +// rpc UpdateCalendar(stream google.api.HttpBody) +// returns (stream google.api.HttpBody); +// +// } +// +// Use of this type only changes how the request and response bodies are +// handled, all other features will continue to work unchanged. +message HttpBody { + // The HTTP Content-Type header value specifying the content type of the body. + string content_type = 1; + + // The HTTP request/response body as raw binary. + bytes data = 2; + + // Application specific response metadata. Must be set in the first response + // for streaming APIs. + repeated google.protobuf.Any extensions = 3; +} \ No newline at end of file diff --git a/bff/proto/protoc-gen-openapiv2/options/annotations.proto b/bff/proto/protoc-gen-openapiv2/options/annotations.proto new file mode 100644 index 0000000..9d4f4c9 --- /dev/null +++ b/bff/proto/protoc-gen-openapiv2/options/annotations.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +package grpc.gateway.protoc_gen_openapiv2.options; + +import "google/protobuf/descriptor.proto"; +import "protoc-gen-openapiv2/options/openapiv2.proto"; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; + +extend google.protobuf.FileOptions { + // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + Swagger openapiv2_swagger = 1042; +} +extend google.protobuf.MethodOptions { + // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + Operation openapiv2_operation = 1042; +} +extend google.protobuf.MessageOptions { + // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + Schema openapiv2_schema = 1042; +} +extend google.protobuf.ServiceOptions { + // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + Tag openapiv2_tag = 1042; +} +extend google.protobuf.FieldOptions { + // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. + JSONSchema openapiv2_field = 1042; +} \ No newline at end of file diff --git a/bff/proto/protoc-gen-openapiv2/options/openapiv2.proto b/bff/proto/protoc-gen-openapiv2/options/openapiv2.proto new file mode 100644 index 0000000..2a5d40d --- /dev/null +++ b/bff/proto/protoc-gen-openapiv2/options/openapiv2.proto @@ -0,0 +1,720 @@ +syntax = "proto3"; + +package grpc.gateway.protoc_gen_openapiv2.options; + +import "google/protobuf/struct.proto"; + +option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; + +// Scheme describes the schemes supported by the OpenAPI Swagger +// and Operation objects. +enum Scheme { + UNKNOWN = 0; + HTTP = 1; + HTTPS = 2; + WS = 3; + WSS = 4; +} + +// `Swagger` is a representation of OpenAPI v2 specification's Swagger object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject +// +// Example: +// +// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { +// info: { +// title: "Echo API"; +// version: "1.0"; +// description: ""; +// contact: { +// name: "gRPC-Gateway project"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway"; +// email: "none@example.com"; +// }; +// license: { +// name: "BSD 3-Clause License"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; +// }; +// }; +// schemes: HTTPS; +// consumes: "application/json"; +// produces: "application/json"; +// }; +// +message Swagger { + // Specifies the OpenAPI Specification version being used. It can be + // used by the OpenAPI UI and other clients to interpret the API listing. The + // value MUST be "2.0". + string swagger = 1; + // Provides metadata about the API. The metadata can be used by the + // clients if needed. + Info info = 2; + // The host (name or ip) serving the API. This MUST be the host only and does + // not include the scheme nor sub-paths. It MAY include a port. If the host is + // not included, the host serving the documentation is to be used (including + // the port). The host does not support path templating. + string host = 3; + // The base path on which the API is served, which is relative to the host. If + // it is not included, the API is served directly under the host. The value + // MUST start with a leading slash (/). The basePath does not support path + // templating. + // Note that using `base_path` does not change the endpoint paths that are + // generated in the resulting OpenAPI file. If you wish to use `base_path` + // with relatively generated OpenAPI paths, the `base_path` prefix must be + // manually removed from your `google.api.http` paths and your code changed to + // serve the API from the `base_path`. + string base_path = 4; + // The transfer protocol of the API. Values MUST be from the list: "http", + // "https", "ws", "wss". If the schemes is not included, the default scheme to + // be used is the one used to access the OpenAPI definition itself. + repeated Scheme schemes = 5; + // A list of MIME types the APIs can consume. This is global to all APIs but + // can be overridden on specific API calls. Value MUST be as described under + // Mime Types. + repeated string consumes = 6; + // A list of MIME types the APIs can produce. This is global to all APIs but + // can be overridden on specific API calls. Value MUST be as described under + // Mime Types. + repeated string produces = 7; + // field 8 is reserved for 'paths'. + reserved 8; + // field 9 is reserved for 'definitions', which at this time are already + // exposed as and customizable as proto messages. + reserved 9; + // An object to hold responses that can be used across operations. This + // property does not define global responses for all operations. + map responses = 10; + // Security scheme definitions that can be used across the specification. + SecurityDefinitions security_definitions = 11; + // A declaration of which security schemes are applied for the API as a whole. + // The list of values describes alternative security schemes that can be used + // (that is, there is a logical OR between the security requirements). + // Individual operations can override this definition. + repeated SecurityRequirement security = 12; + // A list of tags for API documentation control. Tags can be used for logical + // grouping of operations by resources or any other qualifier. + repeated Tag tags = 13; + // Additional external documentation. + ExternalDocumentation external_docs = 14; + // Custom properties that start with "x-" such as "x-foo" used to describe + // extra functionality that is not covered by the standard OpenAPI Specification. + // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ + map extensions = 15; +} + +// `Operation` is a representation of OpenAPI v2 specification's Operation object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject +// +// Example: +// +// service EchoService { +// rpc Echo(SimpleMessage) returns (SimpleMessage) { +// option (google.api.http) = { +// get: "/v1/example/echo/{id}" +// }; +// +// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { +// summary: "Get a message."; +// operation_id: "getMessage"; +// tags: "echo"; +// responses: { +// key: "200" +// value: { +// description: "OK"; +// } +// } +// }; +// } +// } +message Operation { + // A list of tags for API documentation control. Tags can be used for logical + // grouping of operations by resources or any other qualifier. + repeated string tags = 1; + // A short summary of what the operation does. For maximum readability in the + // swagger-ui, this field SHOULD be less than 120 characters. + string summary = 2; + // A verbose explanation of the operation behavior. GFM syntax can be used for + // rich text representation. + string description = 3; + // Additional external documentation for this operation. + ExternalDocumentation external_docs = 4; + // Unique string used to identify the operation. The id MUST be unique among + // all operations described in the API. Tools and libraries MAY use the + // operationId to uniquely identify an operation, therefore, it is recommended + // to follow common programming naming conventions. + string operation_id = 5; + // A list of MIME types the operation can consume. This overrides the consumes + // definition at the OpenAPI Object. An empty value MAY be used to clear the + // global definition. Value MUST be as described under Mime Types. + repeated string consumes = 6; + // A list of MIME types the operation can produce. This overrides the produces + // definition at the OpenAPI Object. An empty value MAY be used to clear the + // global definition. Value MUST be as described under Mime Types. + repeated string produces = 7; + // field 8 is reserved for 'parameters'. + reserved 8; + // The list of possible responses as they are returned from executing this + // operation. + map responses = 9; + // The transfer protocol for the operation. Values MUST be from the list: + // "http", "https", "ws", "wss". The value overrides the OpenAPI Object + // schemes definition. + repeated Scheme schemes = 10; + // Declares this operation to be deprecated. Usage of the declared operation + // should be refrained. Default value is false. + bool deprecated = 11; + // A declaration of which security schemes are applied for this operation. The + // list of values describes alternative security schemes that can be used + // (that is, there is a logical OR between the security requirements). This + // definition overrides any declared top-level security. To remove a top-level + // security declaration, an empty array can be used. + repeated SecurityRequirement security = 12; + // Custom properties that start with "x-" such as "x-foo" used to describe + // extra functionality that is not covered by the standard OpenAPI Specification. + // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ + map extensions = 13; + // Custom parameters such as HTTP request headers. + // See: https://swagger.io/docs/specification/2-0/describing-parameters/ + // and https://swagger.io/specification/v2/#parameter-object. + Parameters parameters = 14; +} + +// `Parameters` is a representation of OpenAPI v2 specification's parameters object. +// Note: This technically breaks compatibility with the OpenAPI 2 definition structure as we only +// allow header parameters to be set here since we do not want users specifying custom non-header +// parameters beyond those inferred from the Protobuf schema. +// See: https://swagger.io/specification/v2/#parameter-object +message Parameters { + // `Headers` is one or more HTTP header parameter. + // See: https://swagger.io/docs/specification/2-0/describing-parameters/#header-parameters + repeated HeaderParameter headers = 1; +} + +// `HeaderParameter` a HTTP header parameter. +// See: https://swagger.io/specification/v2/#parameter-object +message HeaderParameter { + // `Type` is a a supported HTTP header type. + // See https://swagger.io/specification/v2/#parameterType. + enum Type { + UNKNOWN = 0; + STRING = 1; + NUMBER = 2; + INTEGER = 3; + BOOLEAN = 4; + } + + // `Name` is the header name. + string name = 1; + // `Description` is a short description of the header. + string description = 2; + // `Type` is the type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. + // See: https://swagger.io/specification/v2/#parameterType. + Type type = 3; + // `Format` The extending format for the previously mentioned type. + string format = 4; + // `Required` indicates if the header is optional + bool required = 5; + // field 6 is reserved for 'items', but in OpenAPI-specific way. + reserved 6; + // field 7 is reserved `Collection Format`. Determines the format of the array if type array is used. + reserved 7; +} + +// `Header` is a representation of OpenAPI v2 specification's Header object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#headerObject +// +message Header { + // `Description` is a short description of the header. + string description = 1; + // The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. + string type = 2; + // `Format` The extending format for the previously mentioned type. + string format = 3; + // field 4 is reserved for 'items', but in OpenAPI-specific way. + reserved 4; + // field 5 is reserved `Collection Format` Determines the format of the array if type array is used. + reserved 5; + // `Default` Declares the value of the header that the server will use if none is provided. + // See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. + // Unlike JSON Schema this value MUST conform to the defined type for the header. + string default = 6; + // field 7 is reserved for 'maximum'. + reserved 7; + // field 8 is reserved for 'exclusiveMaximum'. + reserved 8; + // field 9 is reserved for 'minimum'. + reserved 9; + // field 10 is reserved for 'exclusiveMinimum'. + reserved 10; + // field 11 is reserved for 'maxLength'. + reserved 11; + // field 12 is reserved for 'minLength'. + reserved 12; + // 'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3. + string pattern = 13; + // field 14 is reserved for 'maxItems'. + reserved 14; + // field 15 is reserved for 'minItems'. + reserved 15; + // field 16 is reserved for 'uniqueItems'. + reserved 16; + // field 17 is reserved for 'enum'. + reserved 17; + // field 18 is reserved for 'multipleOf'. + reserved 18; +} + +// `Response` is a representation of OpenAPI v2 specification's Response object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject +// +message Response { + // `Description` is a short description of the response. + // GFM syntax can be used for rich text representation. + string description = 1; + // `Schema` optionally defines the structure of the response. + // If `Schema` is not provided, it means there is no content to the response. + Schema schema = 2; + // `Headers` A list of headers that are sent with the response. + // `Header` name is expected to be a string in the canonical format of the MIME header key + // See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey + map headers = 3; + // `Examples` gives per-mimetype response examples. + // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object + map examples = 4; + // Custom properties that start with "x-" such as "x-foo" used to describe + // extra functionality that is not covered by the standard OpenAPI Specification. + // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ + map extensions = 5; +} + +// `Info` is a representation of OpenAPI v2 specification's Info object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject +// +// Example: +// +// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { +// info: { +// title: "Echo API"; +// version: "1.0"; +// description: ""; +// contact: { +// name: "gRPC-Gateway project"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway"; +// email: "none@example.com"; +// }; +// license: { +// name: "BSD 3-Clause License"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; +// }; +// }; +// ... +// }; +// +message Info { + // The title of the application. + string title = 1; + // A short description of the application. GFM syntax can be used for rich + // text representation. + string description = 2; + // The Terms of Service for the API. + string terms_of_service = 3; + // The contact information for the exposed API. + Contact contact = 4; + // The license information for the exposed API. + License license = 5; + // Provides the version of the application API (not to be confused + // with the specification version). + string version = 6; + // Custom properties that start with "x-" such as "x-foo" used to describe + // extra functionality that is not covered by the standard OpenAPI Specification. + // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ + map extensions = 7; +} + +// `Contact` is a representation of OpenAPI v2 specification's Contact object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject +// +// Example: +// +// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { +// info: { +// ... +// contact: { +// name: "gRPC-Gateway project"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway"; +// email: "none@example.com"; +// }; +// ... +// }; +// ... +// }; +// +message Contact { + // The identifying name of the contact person/organization. + string name = 1; + // The URL pointing to the contact information. MUST be in the format of a + // URL. + string url = 2; + // The email address of the contact person/organization. MUST be in the format + // of an email address. + string email = 3; +} + +// `License` is a representation of OpenAPI v2 specification's License object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject +// +// Example: +// +// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { +// info: { +// ... +// license: { +// name: "BSD 3-Clause License"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; +// }; +// ... +// }; +// ... +// }; +// +message License { + // The license name used for the API. + string name = 1; + // A URL to the license used for the API. MUST be in the format of a URL. + string url = 2; +} + +// `ExternalDocumentation` is a representation of OpenAPI v2 specification's +// ExternalDocumentation object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject +// +// Example: +// +// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { +// ... +// external_docs: { +// description: "More about gRPC-Gateway"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway"; +// } +// ... +// }; +// +message ExternalDocumentation { + // A short description of the target documentation. GFM syntax can be used for + // rich text representation. + string description = 1; + // The URL for the target documentation. Value MUST be in the format + // of a URL. + string url = 2; +} + +// `Schema` is a representation of OpenAPI v2 specification's Schema object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +message Schema { + JSONSchema json_schema = 1; + // Adds support for polymorphism. The discriminator is the schema property + // name that is used to differentiate between other schema that inherit this + // schema. The property name used MUST be defined at this schema and it MUST + // be in the required property list. When used, the value MUST be the name of + // this schema or any schema that inherits it. + string discriminator = 2; + // Relevant only for Schema "properties" definitions. Declares the property as + // "read only". This means that it MAY be sent as part of a response but MUST + // NOT be sent as part of the request. Properties marked as readOnly being + // true SHOULD NOT be in the required list of the defined schema. Default + // value is false. + bool read_only = 3; + // field 4 is reserved for 'xml'. + reserved 4; + // Additional external documentation for this schema. + ExternalDocumentation external_docs = 5; + // A free-form property to include an example of an instance for this schema in JSON. + // This is copied verbatim to the output. + string example = 6; +} + +// `JSONSchema` represents properties from JSON Schema taken, and as used, in +// the OpenAPI v2 spec. +// +// This includes changes made by OpenAPI v2. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// See also: https://cswr.github.io/JsonSchema/spec/basic_types/, +// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json +// +// Example: +// +// message SimpleMessage { +// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { +// json_schema: { +// title: "SimpleMessage" +// description: "A simple message." +// required: ["id"] +// } +// }; +// +// // Id represents the message identifier. +// string id = 1; [ +// (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { +// description: "The unique identifier of the simple message." +// }]; +// } +// +message JSONSchema { + // field 1 is reserved for '$id', omitted from OpenAPI v2. + reserved 1; + // field 2 is reserved for '$schema', omitted from OpenAPI v2. + reserved 2; + // Ref is used to define an external reference to include in the message. + // This could be a fully qualified proto message reference, and that type must + // be imported into the protofile. If no message is identified, the Ref will + // be used verbatim in the output. + // For example: + // `ref: ".google.protobuf.Timestamp"`. + string ref = 3; + // field 4 is reserved for '$comment', omitted from OpenAPI v2. + reserved 4; + // The title of the schema. + string title = 5; + // A short description of the schema. + string description = 6; + string default = 7; + bool read_only = 8; + // A free-form property to include a JSON example of this field. This is copied + // verbatim to the output swagger.json. Quotes must be escaped. + // This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject + string example = 9; + double multiple_of = 10; + // Maximum represents an inclusive upper limit for a numeric instance. The + // value of MUST be a number, + double maximum = 11; + bool exclusive_maximum = 12; + // minimum represents an inclusive lower limit for a numeric instance. The + // value of MUST be a number, + double minimum = 13; + bool exclusive_minimum = 14; + uint64 max_length = 15; + uint64 min_length = 16; + string pattern = 17; + // field 18 is reserved for 'additionalItems', omitted from OpenAPI v2. + reserved 18; + // field 19 is reserved for 'items', but in OpenAPI-specific way. + // TODO(ivucica): add 'items'? + reserved 19; + uint64 max_items = 20; + uint64 min_items = 21; + bool unique_items = 22; + // field 23 is reserved for 'contains', omitted from OpenAPI v2. + reserved 23; + uint64 max_properties = 24; + uint64 min_properties = 25; + repeated string required = 26; + // field 27 is reserved for 'additionalProperties', but in OpenAPI-specific + // way. TODO(ivucica): add 'additionalProperties'? + reserved 27; + // field 28 is reserved for 'definitions', omitted from OpenAPI v2. + reserved 28; + // field 29 is reserved for 'properties', but in OpenAPI-specific way. + // TODO(ivucica): add 'additionalProperties'? + reserved 29; + // following fields are reserved, as the properties have been omitted from + // OpenAPI v2: + // patternProperties, dependencies, propertyNames, const + reserved 30 to 33; + // Items in 'array' must be unique. + repeated string array = 34; + + enum JSONSchemaSimpleTypes { + UNKNOWN = 0; + ARRAY = 1; + BOOLEAN = 2; + INTEGER = 3; + NULL = 4; + NUMBER = 5; + OBJECT = 6; + STRING = 7; + } + + repeated JSONSchemaSimpleTypes type = 35; + // `Format` + string format = 36; + // following fields are reserved, as the properties have been omitted from + // OpenAPI v2: contentMediaType, contentEncoding, if, then, else + reserved 37 to 41; + // field 42 is reserved for 'allOf', but in OpenAPI-specific way. + // TODO(ivucica): add 'allOf'? + reserved 42; + // following fields are reserved, as the properties have been omitted from + // OpenAPI v2: + // anyOf, oneOf, not + reserved 43 to 45; + // Items in `enum` must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 + repeated string enum = 46; + + // Additional field level properties used when generating the OpenAPI v2 file. + FieldConfiguration field_configuration = 1001; + + // 'FieldConfiguration' provides additional field level properties used when generating the OpenAPI v2 file. + // These properties are not defined by OpenAPIv2, but they are used to control the generation. + message FieldConfiguration { + // Alternative parameter name when used as path parameter. If set, this will + // be used as the complete parameter name when this field is used as a path + // parameter. Use this to avoid having auto generated path parameter names + // for overlapping paths. + string path_param_name = 47; + } + // Custom properties that start with "x-" such as "x-foo" used to describe + // extra functionality that is not covered by the standard OpenAPI Specification. + // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ + map extensions = 48; +} + +// `Tag` is a representation of OpenAPI v2 specification's Tag object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject +// +message Tag { + // The name of the tag. Use it to allow override of the name of a + // global Tag object, then use that name to reference the tag throughout the + // OpenAPI file. + string name = 1; + // A short description for the tag. GFM syntax can be used for rich text + // representation. + string description = 2; + // Additional external documentation for this tag. + ExternalDocumentation external_docs = 3; + // Custom properties that start with "x-" such as "x-foo" used to describe + // extra functionality that is not covered by the standard OpenAPI Specification. + // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ + map extensions = 4; +} + +// `SecurityDefinitions` is a representation of OpenAPI v2 specification's +// Security Definitions object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject +// +// A declaration of the security schemes available to be used in the +// specification. This does not enforce the security schemes on the operations +// and only serves to provide the relevant details for each scheme. +message SecurityDefinitions { + // A single security scheme definition, mapping a "name" to the scheme it + // defines. + map security = 1; +} + +// `SecurityScheme` is a representation of OpenAPI v2 specification's +// Security Scheme object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject +// +// Allows the definition of a security scheme that can be used by the +// operations. Supported schemes are basic authentication, an API key (either as +// a header or as a query parameter) and OAuth2's common flows (implicit, +// password, application and access code). +message SecurityScheme { + // The type of the security scheme. Valid values are "basic", + // "apiKey" or "oauth2". + enum Type { + TYPE_INVALID = 0; + TYPE_BASIC = 1; + TYPE_API_KEY = 2; + TYPE_OAUTH2 = 3; + } + + // The location of the API key. Valid values are "query" or "header". + enum In { + IN_INVALID = 0; + IN_QUERY = 1; + IN_HEADER = 2; + } + + // The flow used by the OAuth2 security scheme. Valid values are + // "implicit", "password", "application" or "accessCode". + enum Flow { + FLOW_INVALID = 0; + FLOW_IMPLICIT = 1; + FLOW_PASSWORD = 2; + FLOW_APPLICATION = 3; + FLOW_ACCESS_CODE = 4; + } + + // The type of the security scheme. Valid values are "basic", + // "apiKey" or "oauth2". + Type type = 1; + // A short description for security scheme. + string description = 2; + // The name of the header or query parameter to be used. + // Valid for apiKey. + string name = 3; + // The location of the API key. Valid values are "query" or + // "header". + // Valid for apiKey. + In in = 4; + // The flow used by the OAuth2 security scheme. Valid values are + // "implicit", "password", "application" or "accessCode". + // Valid for oauth2. + Flow flow = 5; + // The authorization URL to be used for this flow. This SHOULD be in + // the form of a URL. + // Valid for oauth2/implicit and oauth2/accessCode. + string authorization_url = 6; + // The token URL to be used for this flow. This SHOULD be in the + // form of a URL. + // Valid for oauth2/password, oauth2/application and oauth2/accessCode. + string token_url = 7; + // The available scopes for the OAuth2 security scheme. + // Valid for oauth2. + Scopes scopes = 8; + // Custom properties that start with "x-" such as "x-foo" used to describe + // extra functionality that is not covered by the standard OpenAPI Specification. + // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ + map extensions = 9; +} + +// `SecurityRequirement` is a representation of OpenAPI v2 specification's +// Security Requirement object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject +// +// Lists the required security schemes to execute this operation. The object can +// have multiple security schemes declared in it which are all required (that +// is, there is a logical AND between the schemes). +// +// The name used for each property MUST correspond to a security scheme +// declared in the Security Definitions. +message SecurityRequirement { + // If the security scheme is of type "oauth2", then the value is a list of + // scope names required for the execution. For other security scheme types, + // the array MUST be empty. + message SecurityRequirementValue { + repeated string scope = 1; + } + // Each name must correspond to a security scheme which is declared in + // the Security Definitions. If the security scheme is of type "oauth2", + // then the value is a list of scope names required for the execution. + // For other security scheme types, the array MUST be empty. + map security_requirement = 1; +} + +// `Scopes` is a representation of OpenAPI v2 specification's Scopes object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject +// +// Lists the available scopes for an OAuth2 security scheme. +message Scopes { + // Maps between a name of a scope to a short description of it (as the value + // of the property). + map scope = 1; +} \ No newline at end of file diff --git a/bff/proto/rpc_block_session.proto b/bff/proto/rpc_block_session.proto new file mode 100644 index 0000000..6c6a432 --- /dev/null +++ b/bff/proto/rpc_block_session.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; + +package pb; + +import "protoc-gen-openapiv2/options/annotations.proto"; + +option go_package = "github.com/itsscb/df/pb"; + +message BlockSessionRequest { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Block Session"; + description: "Block a Session"; + required: [ + "session_id" + ]; + }; + example: "{\"session_id\": \"5e1d67da-7c9b-4365-a4d5-3cc0a051241e\"}" + }; + string session_id = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Session ID", + format: "uuid", + example: "\"5e1d67da-7c9b-4365-a4d5-3cc0a051241e\"" + }]; +} + +message BlockSessionResponse { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Blocked Session"; + }; + example: "{\"session_id\": \"5e1d67da-7c9b-4365-a4d5-3cc0a051241e\", \"blocked\": true}" + }; + string session_id = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Session ID", + format: "uuid", + example: "\"5e1d67da-7c9b-4365-a4d5-3cc0a051241e\"" + }]; + bool blocked = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Session blocked", + example: "true" + }]; +} \ No newline at end of file diff --git a/bff/proto/rpc_create_account.proto b/bff/proto/rpc_create_account.proto new file mode 100644 index 0000000..e495d9f --- /dev/null +++ b/bff/proto/rpc_create_account.proto @@ -0,0 +1,58 @@ +syntax = "proto3"; + +package pb; + +import "google/protobuf/timestamp.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +import "account.proto"; + +option go_package = "github.com/itsscb/df/pb"; + +message CreateAccountRequest { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Create Account"; + description: "Create an Account"; + required: [ + "email", + "password", + "firstname", + "lastname", + "street", + "city", + "zip", + "country", + "birthday" + ]; + }; + example: "{\"email\": \"john.doe@example.com\", \"password\": \"MayTheForceBeWithYou!\", \"firstname\": \"John\", \"lastname\": \"Doe\", \"street\": \"Main Street 1\", \"zip\": \"0815\", \"city\": \"New York\", \"country\": \"USA\", \"birthday\": \"1990-10-05T00:00:0Z\"}"; + }; + string email = 1; + string password = 2; + string firstname = 3; + string lastname = 4; + string street = 5; + string city = 6; + string zip = 7; + string country = 8; + string phone = 9; + google.protobuf.Timestamp birthday = 10 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "\"1990-10-05T00:00:0Z\"" + }]; + optional bool privacy_accepted = 11 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "true" + }]; +} + +// \"1990-10-05T00:00:0Z\" +message CreateAccountResponse { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Created Account"; + description: "Returns the created Account"; + }; + }; + Account account = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + }]; +} \ No newline at end of file diff --git a/bff/proto/rpc_login.proto b/bff/proto/rpc_login.proto new file mode 100644 index 0000000..50c251e --- /dev/null +++ b/bff/proto/rpc_login.proto @@ -0,0 +1,61 @@ +syntax = "proto3"; + +package pb; + +import "google/protobuf/timestamp.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +option go_package = "github.com/itsscb/df/pb"; + +message LoginRequest { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Login"; + description: "Login an Account"; + required: [ + "email", + "password" + ]; + }; + example: "{\"email\": \"john.doe@example.com\", \"password\": \"MayTheForceBeWithYou!\"}"; + }; + string email = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Email Address", + format: "email", + example: "\"john.doe@example.com\"" + }]; + string password = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Password", + format: "password", + example: "\"MayTheForceBeWithYou!\"" + }]; +} + +message LoginResponse { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Login Response"; + }; + // example: "{\"email\": \"john.doe@example.com\", \"password\": \"MayTheForceBeWithYou!\"}"; + }; + string session_id = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Session ID", + format: "uuid", + example: "\"5e1d67da-7c9b-4365-a4d5-3cc0a051241e\"" + }]; + string access_token = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Access Token", + example: "\"v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA1VDAxOjE3OjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiZjlhMjE2OWQtMWYxYS00YThiLTgzZWEtNzkxMzY5YjY3ZmYxIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9Ah0bVbx9S1LR-pf8hLWVRQPUfK9zrHZvA7ApJ5aZXwhA7H1j-kHhccBjOAGYXZQT-ts7Jq3SJlzo5vtUjGBtDg\"" + }]; + google.protobuf.Timestamp access_token_expires_at = 3; + string refresh_token = 4 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Refresh Token", + example: "\"v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA2VDAxOjAyOjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiNWUxZDY3ZGEtN2M5Yi00MzY1LWE0ZDUtM2NjMGEwNTEyNDFlIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9BoX36w0po1vvHSjsBP_KWeFxV1xRbQayqbJuIoK2jKqy1Bt2RoHyJbLoCEO15CRT5DnQ6P0AHlBzjsXt61aDDw\"" + }]; + google.protobuf.Timestamp refresh_token_expires_at = 5; + string email = 6 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + // title: "Email Address", + format: "email", + example: "\"john.doe@example.com\"" + }]; +} \ No newline at end of file diff --git a/bff/proto/rpc_refresh_token.proto b/bff/proto/rpc_refresh_token.proto new file mode 100644 index 0000000..ab571ec --- /dev/null +++ b/bff/proto/rpc_refresh_token.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +package pb; + +import "google/protobuf/timestamp.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +option go_package = "github.com/itsscb/df/pb"; + +message RefreshTokenRequest { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Refresh Token Request"; + description: "Get a new Access Token by submitting the Refresh Token"; + required: [ + "refresh_token" + ]; + }; + example: "{\"refresh_token\": \"v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA2VDAxOjAyOjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiNWUxZDY3ZGEtN2M5Yi00MzY1LWE0ZDUtM2NjMGEwNTEyNDFlIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9BoX36w0po1vvHSjsBP_KWeFxV1xRbQayqbJuIoK2jKqy1Bt2RoHyJbLoCEO15CRT5DnQ6P0AHlBzjsXt61aDDw\"}" + }; + string refresh_token = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + title: "Refresh Token", + example: "\"v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA2VDAxOjAyOjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiNWUxZDY3ZGEtN2M5Yi00MzY1LWE0ZDUtM2NjMGEwNTEyNDFlIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9BoX36w0po1vvHSjsBP_KWeFxV1xRbQayqbJuIoK2jKqy1Bt2RoHyJbLoCEO15CRT5DnQ6P0AHlBzjsXt61aDDw\"" + }]; +} + +message RefreshTokenResponse { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Refresh Token Response"; + }; + // example: "{\"email\": \"john.doe@example.com\", \"password\": \"MayTheForceBeWithYou!\"}"; + }; + string access_token = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + title: "Access Token", + example: "\"v4.public.eyJlbWFpbCI6ImEyQGIuZGUiLCJleHAiOiIyMDIzLTEwLTA1VDAxOjE3OjA5KzAyOjAwIiwiaWF0IjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCIsImlkIjoiZjlhMjE2OWQtMWYxYS00YThiLTgzZWEtNzkxMzY5YjY3ZmYxIiwibmJmIjoiMjAyMy0xMC0wNVQwMTowMjowOSswMjowMCJ9Ah0bVbx9S1LR-pf8hLWVRQPUfK9zrHZvA7ApJ5aZXwhA7H1j-kHhccBjOAGYXZQT-ts7Jq3SJlzo5vtUjGBtDg\"" + }]; + google.protobuf.Timestamp access_token_expires_at = 2; +} \ No newline at end of file diff --git a/bff/proto/rpc_update_account.proto b/bff/proto/rpc_update_account.proto new file mode 100644 index 0000000..e3f32ee --- /dev/null +++ b/bff/proto/rpc_update_account.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + +package pb; + +import "google/protobuf/timestamp.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +import "account.proto"; + +option go_package = "github.com/itsscb/df/pb"; + +message UpdateAccountRequest { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Update Account"; + description: "Update an Account"; + required: [ + "id" + ]; + }; + example: "{\"id\": 195, \"street\": \"Death Star 2\"}"; + }; + int64 id = 1; + optional string email = 2; + optional string password = 3; + optional string firstname = 4; + optional string lastname = 5; + optional string street = 6; + optional string city = 7; + optional string zip = 8; + optional string country = 9; + optional string phone = 10; + optional google.protobuf.Timestamp birthday = 11 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "\"1990-10-05T00:00:0Z\"" + }]; +} + +message UpdateAccountResponse { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Updated Account"; + description: "Returns the updated Account"; + }; + }; + Account account = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + }]; +} \ No newline at end of file diff --git a/bff/proto/rpc_update_account_privacy.proto b/bff/proto/rpc_update_account_privacy.proto new file mode 100644 index 0000000..7bafa5f --- /dev/null +++ b/bff/proto/rpc_update_account_privacy.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; + +package pb; + +import "protoc-gen-openapiv2/options/annotations.proto"; + +import "account.proto"; + +option go_package = "github.com/itsscb/df/pb"; + +message UpdateAccountPrivacyRequest { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Update Account Privacy Consent"; + description: "Update the Privacy Consent of an Account"; + required: [ + "id", + "privacy_accepted" + ]; + }; + example: "{\"id\": 185, \"privacy_accepted\": true }" + }; + int64 id = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "185", + format: "int64" + }]; + optional bool privacy_accepted = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "false" + }]; +} + +message UpdateAccountPrivacyResponse { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "Update Account Privacy Response"; + }; + }; + Account account = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + title: "Updated Account" + }]; +} \ No newline at end of file diff --git a/bff/proto/service_df.proto b/bff/proto/service_df.proto new file mode 100644 index 0000000..a9ed892 --- /dev/null +++ b/bff/proto/service_df.proto @@ -0,0 +1,110 @@ +syntax = "proto3"; + +package pb; + +import "google/api/annotations.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + +import "rpc_create_account.proto"; +import "rpc_update_account.proto"; +import "rpc_block_session.proto"; +import "rpc_update_account_privacy.proto"; +import "rpc_login.proto"; +import "rpc_refresh_token.proto"; + +option go_package = "github.com/itsscb/df/pb"; + + +option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { + info: { + title: "df API"; + version: "1.0"; + contact: { + name: "itsscb"; + url: "https://github.com/itsscb/df"; + email: "dev@itsscb.de"; + }; + }; + schemes: HTTP; + schemes: HTTPS; + consumes: "application/json"; + produces: "application/json"; + security_definitions: { + security: { + key: "BearerAuth"; + value: {type: TYPE_API_KEY} + } + } +}; + +service Sessions { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = { + description: "Sessions" + }; + rpc Login (LoginRequest) returns (LoginResponse) { + option (google.api.http) = { + post: "/v1/login" + body: "*" + }; + }; + rpc RefreshToken (RefreshTokenRequest) returns (RefreshTokenResponse) { + option (google.api.http) = { + post: "/v1/refresh_token" + body: "*" + }; + }; + rpc BlockSession (BlockSessionRequest) returns (BlockSessionResponse) { + option (google.api.http) = { + post: "/v1/block_session" + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + security: { + security_requirement: { + key: "BearerAuth"; + value: {} + } + } + }; + }; +} + +service Accounts { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = { + description: "Account" + }; + rpc CreateAccount (CreateAccountRequest) returns (CreateAccountResponse) { + option (google.api.http) = { + post: "/v1/create_account" + body: "*" + }; + }; + rpc UpdateAccount (UpdateAccountRequest) returns (UpdateAccountResponse) { + option (google.api.http) = { + post: "/v1/update_account" + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + security: { + security_requirement: { + key: "BearerAuth"; + value: {} + } + } + }; + }; + rpc UpdateAccountPrivacy (UpdateAccountPrivacyRequest) returns (UpdateAccountPrivacyResponse) { + option (google.api.http) = { + post: "/v1/update_account_privacy" + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + security: { + security_requirement: { + key: "BearerAuth"; + value: {} + } + } + }; + }; +}; \ No newline at end of file diff --git a/bff/util/config.go b/bff/util/config.go index 2a38f1d..e5b71f7 100644 --- a/bff/util/config.go +++ b/bff/util/config.go @@ -9,7 +9,8 @@ import ( type Config struct { DBSource string `mapstructure:"DB_SOURCE"` DBDriver string `mapstructure:"DB_DRIVER"` - ServerAddress string `mapstructure:"SERVER_ADDRESS"` + HTTPServerAddress string `mapstructure:"HTTP_SERVER_ADDRESS"` + GRPCServerAddress string `mapstructure:"GRPC_SERVER_ADDRESS"` Environment string `mapstructure:"ENVIRONMENT"` LogOutput string `mapstructure:"LOG_OUTPUT"` TokenPrivateKeyHex string `mapstructure:"TOKEN_PRIVATEKEY_HEX"` diff --git a/bff/val/validator.go b/bff/val/validator.go new file mode 100644 index 0000000..e0f5ee6 --- /dev/null +++ b/bff/val/validator.go @@ -0,0 +1,54 @@ +package val + +import ( + "fmt" + "net/mail" + "regexp" +) + +var ( + isValidName = regexp.MustCompile(`^[a-zA-Z\s]+$`).MatchString +) + +func ValidateString(value string, minLength int, maxLength int) error { + n := len(value) + if n < minLength || n > maxLength { + return fmt.Errorf("must contain from %d-%d characters", minLength, maxLength) + } + return nil +} + +func ValidateName(value string) error { + if err := ValidateString(value, 2, 40); err != nil { + return err + } + if !isValidName(value) { + return fmt.Errorf("must contain only letters or spaces") + } + return nil +} + +func ValidatePassword(value string) error { + return ValidateString(value, 6, 100) +} + +func ValidateEmail(value string) error { + if err := ValidateString(value, 3, 200); err != nil { + return err + } + if _, err := mail.ParseAddress(value); err != nil { + return fmt.Errorf("is not a valid email address") + } + return nil +} + +func ValidateEmailId(value int64) error { + if value <= 0 { + return fmt.Errorf("must be a positive integer") + } + return nil +} + +func ValidateSecretCode(value string) error { + return ValidateString(value, 32, 128) +}