diff --git a/.woodpecker/dart-generate.yaml b/.woodpecker/dart-generate.yaml new file mode 100644 index 0000000..d0c7d43 --- /dev/null +++ b/.woodpecker/dart-generate.yaml @@ -0,0 +1,41 @@ +--- +when: + event: + - push + +steps: + - name: Clone dart repo + image: alpine + environment: + GITEA_USER: devops-bot + GITEA_TOKEN: + from_secret: gitea_repo_access + commands: + - apk update && apk add git + - git clone https://$GITEA_USER:$GITEA_TOKEN@gitea.badhouseplants.net/softplayer/softplayer-dart-proto.git target + - git -C ./target config user.name "devops-bot" + - git -C ./target config user.email "bot@badhouseplants.net" + - git -C ./target checkout $CI_COMMIT_BRANCH || git -C ./target checkout -b $CI_COMMIT_BRANCH + - name: Generate code + image: bufbuild/buf + commands: + - buf generate + - rm -rf ./target/lib/src + - mkdir -p ./target/lib/src + - cp -r ./gen/dart/* ./target/ + - name: Push the dart repo + image: alpine + environment: + GITEA_USER: devops-bot + GITEA_TOKEN: + from_secret: gitea_repo_access + commands: + - apk update && apk add git + - git -C ./target add . + - |- + git -C ./target commit --allow-empty \ + -m "Update protobuf definitions: ${CI_COMMIT_SHA:0:8}" \ + -m "By ${CI_COMMIT_AUTHOR}" \ + -m "Commit link: ${CI_REPO_URL}/commit/${CI_COMMIT_SHA}" \ + -m "Pipeline link: ${CI_PIPELINE_URL}" + - git -C ./target push --set-upstream origin $CI_COMMIT_BRANCH diff --git a/.woodpecker/go-generate.yaml b/.woodpecker/go-generate.yaml index d4562bd..ed4b0d8 100644 --- a/.woodpecker/go-generate.yaml +++ b/.woodpecker/go-generate.yaml @@ -15,7 +15,8 @@ steps: - git clone https://$GITEA_USER:$GITEA_TOKEN@gitea.badhouseplants.net/softplayer/softplayer-go-proto.git target - git -C ./target config user.name "devops-bot" - git -C ./target config user.email "bot@badhouseplants.net" - - name: Generate go code + - git -C ./target checkout $CI_COMMIT_BRANCH || git -C ./target checkout -b $CI_COMMIT_BRANCH + - name: Generate code image: bufbuild/buf commands: - buf generate @@ -29,9 +30,6 @@ steps: from_secret: gitea_repo_access commands: - apk update && apk add git - - git config user.name "woodpecker-ci" - - git config user.email "bot@badhouseplants.net" - - git -C ./target checkout $CI_COMMIT_BRANCH || git -C ./target checkout -b $CI_COMMIT_BRANCH - git -C ./target add . - |- git -C ./target commit --allow-empty \ diff --git a/.woodpecker/js-generate.yaml b/.woodpecker/js-generate.yaml index 8bb0e49..fa1f5e5 100644 --- a/.woodpecker/js-generate.yaml +++ b/.woodpecker/js-generate.yaml @@ -15,13 +15,15 @@ steps: - git clone https://$GITEA_USER:$GITEA_TOKEN@gitea.badhouseplants.net/softplayer/softplayer-js-proto.git target - git -C ./target config user.name "devops-bot" - git -C ./target config user.email "bot@badhouseplants.net" - - name: Generate go code + - git -C ./target checkout $CI_COMMIT_BRANCH || git -C ./target checkout -b $CI_COMMIT_BRANCH + - name: Generate code image: bufbuild/buf commands: - buf generate - rm -rf ./target/src/api + - mkdir -p ./target/src/api - cp -r ./gen/ts/* ./target/src/api - - name: Clone go repo + - name: Push the typescript repo image: alpine environment: GITEA_USER: devops-bot @@ -29,9 +31,6 @@ steps: from_secret: gitea_repo_access commands: - apk update && apk add git - - git config user.name "woodpecker-ci" - - git config user.email "bot@badhouseplants.net" - - git -C ./target checkout $CI_COMMIT_BRANCH || git -C ./target checkout -b $CI_COMMIT_BRANCH - git -C ./target add . - |- git -C ./target commit --allow-empty \ diff --git a/README.md b/README.md index 13a6796..fc1c78d 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,17 @@ ## Table of Contents - [accounts/v1/accounts_v1.proto](#accounts_v1_accounts_v1-proto) - - [AccountData](#accounts-AccountData) - - [AccountFull](#accounts-AccountFull) - - [AccountFullWithToken](#accounts-AccountFullWithToken) - - [AccountId](#accounts-AccountId) - - [AccountPassword](#accounts-AccountPassword) - - [AccountWithPassword](#accounts-AccountWithPassword) - - [AccountWithPasswordAndCode](#accounts-AccountWithPasswordAndCode) - - [EmailVerified](#accounts-EmailVerified) + - [AccountData](#accounts-v1-AccountData) + - [AccountPassword](#accounts-v1-AccountPassword) + - [IsEmailVerifiedRequest](#accounts-v1-IsEmailVerifiedRequest) + - [IsEmailVerifiedResponse](#accounts-v1-IsEmailVerifiedResponse) + - [NewPasswordRequest](#accounts-v1-NewPasswordRequest) + - [ResetPasswordRequest](#accounts-v1-ResetPasswordRequest) + - [SignInRequest](#accounts-v1-SignInRequest) + - [SignUpRequest](#accounts-v1-SignUpRequest) - - [Accounts](#accounts-Accounts) + - [AccountAuthService](#accounts-v1-AccountAuthService) + - [AccountsNoAuthService](#accounts-v1-AccountsNoAuthService) - [applications/v1/applications_v1.proto](#applications_v1_applications_v1-proto) - [ApplicationFull](#applications-ApplicationFull) @@ -63,7 +64,8 @@ - [PongRequest](#test-v1-PongRequest) - [PongResponse](#test-v1-PongResponse) - - [TestService](#test-v1-TestService) + - [TestAuthService](#test-v1-TestAuthService) + - [TestNoAuthService](#test-v1-TestNoAuthService) - [Scalar Value Types](#scalar-value-types) @@ -73,10 +75,10 @@

Top

## accounts/v1/accounts_v1.proto -This file has messages for describing environments +Protobuf definitions for the accounts service. - + ### AccountData @@ -92,55 +94,7 @@ This file has messages for describing environments - - -### AccountFull - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| id | [AccountId](#accounts-AccountId) | | | -| data | [AccountData](#accounts-AccountData) | | | - - - - - - - - -### AccountFullWithToken - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| id | [AccountId](#accounts-AccountId) | | | -| data | [AccountData](#accounts-AccountData) | | | -| token | [string](#string) | | | - - - - - - - - -### AccountId -Represents a environment UUID only - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| id | [string](#string) | | Contour ID: UUID | - - - - - - - + ### AccountPassword @@ -155,42 +109,24 @@ Represents a environment UUID only - + -### AccountWithPassword +### IsEmailVerifiedRequest | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| data | [AccountData](#accounts-AccountData) | | | -| password | [AccountPassword](#accounts-AccountPassword) | | | +| data | [AccountData](#accounts-v1-AccountData) | | | - + -### AccountWithPasswordAndCode - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| data | [AccountData](#accounts-AccountData) | | | -| password | [AccountPassword](#accounts-AccountPassword) | | | -| code | [string](#string) | | | - - - - - - - - -### EmailVerified +### IsEmailVerifiedResponse @@ -202,6 +138,70 @@ Represents a environment UUID only + + + +### NewPasswordRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| data | [AccountData](#accounts-v1-AccountData) | | | +| password | [AccountPassword](#accounts-v1-AccountPassword) | | | +| code | [string](#string) | | | + + + + + + + + +### ResetPasswordRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| data | [AccountData](#accounts-v1-AccountData) | | | + + + + + + + + +### SignInRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| data | [AccountData](#accounts-v1-AccountData) | | | +| password | [AccountPassword](#accounts-v1-AccountPassword) | | | + + + + + + + + +### SignUpRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| data | [AccountData](#accounts-v1-AccountData) | | | +| password | [AccountPassword](#accounts-v1-AccountPassword) | | | + + + + + @@ -209,18 +209,29 @@ Represents a environment UUID only - + -### Accounts -Service for handling environments +### AccountAuthService +Service for handling accounts that do require authentication +Tokens should be sent via metadata, so the service is able to authenticate a user for a request | Method Name | Request Type | Response Type | Description | | ----------- | ------------ | ------------- | ------------| -| SignUp | [AccountWithPassword](#accounts-AccountWithPassword) | [AccountFullWithToken](#accounts-AccountFullWithToken) | | -| SignIn | [AccountWithPassword](#accounts-AccountWithPassword) | [AccountFullWithToken](#accounts-AccountFullWithToken) | | -| ResetPassword | [AccountData](#accounts-AccountData) | [.google.protobuf.Empty](#google-protobuf-Empty) | | -| NewPassword | [AccountWithPasswordAndCode](#accounts-AccountWithPasswordAndCode) | [.google.protobuf.Empty](#google-protobuf-Empty) | | -| IsEmailVerified | [AccountData](#accounts-AccountData) | [EmailVerified](#accounts-EmailVerified) | | +| IsEmailVerified | [IsEmailVerifiedRequest](#accounts-v1-IsEmailVerifiedRequest) | [IsEmailVerifiedResponse](#accounts-v1-IsEmailVerifiedResponse) | Is email for the current account verified | + + + + +### AccountsNoAuthService +Service for handling accounts that do not require authentication + +| Method Name | Request Type | Response Type | Description | +| ----------- | ------------ | ------------- | ------------| +| SignUp | [SignUpRequest](#accounts-v1-SignUpRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | Create a new user | +| SignIn | [SignInRequest](#accounts-v1-SignInRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | Sing in into an existing account | +| ResetPassword | [ResetPasswordRequest](#accounts-v1-ResetPasswordRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | Reset the password, if it was lost | +| NewPassword | [NewPasswordRequest](#accounts-v1-NewPasswordRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | Set the new password after reset | +| RefreshToken | [.google.protobuf.Empty](#google-protobuf-Empty) | [.google.protobuf.Empty](#google-protobuf-Empty) | Send the refresh token request, token should be passed in the metadata. This rpc does requier auth, but it should be handled not on the middleware level, that's why it set in the NoAuth service | @@ -844,15 +855,24 @@ Service for handling environments - + -### TestService +### TestAuthService + + +| Method Name | Request Type | Response Type | Description | +| ----------- | ------------ | ------------- | ------------| +| Pong | [PongRequest](#test-v1-PongRequest) | [PongResponse](#test-v1-PongResponse) | | + + + + +### TestNoAuthService Service for handling environments | Method Name | Request Type | Response Type | Description | | ----------- | ------------ | ------------- | ------------| | Ping | [PingRequest](#test-v1-PingRequest) | [PingResponse](#test-v1-PingResponse) | | -| Pong | [PongRequest](#test-v1-PongRequest) | [PongResponse](#test-v1-PongResponse) | | diff --git a/buf.gen.yaml b/buf.gen.yaml index 49c570a..27aba36 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -20,3 +20,7 @@ plugins: out: . opt: - markdown,README.md + - remote: buf.build/protocolbuffers/dart:v25.0.0 + out: gen/dart/lib/src + opt: + - grpc diff --git a/buf.yaml b/buf.yaml index ba5ddf5..342cd48 100644 --- a/buf.yaml +++ b/buf.yaml @@ -1,3 +1,11 @@ version: v2 modules: - path: proto + +lint: + use: + - STANDARD + enum_zero_value_suffix: _UNSPECIFIED + rpc_allow_same_request_response: true + rpc_allow_google_protobuf_empty_requests: true + rpc_allow_google_protobuf_empty_responses: true diff --git a/proto/accounts/v1/accounts_v1.proto b/proto/accounts/v1/accounts_v1.proto index 6c8fe28..af1ef9a 100644 --- a/proto/accounts/v1/accounts_v1.proto +++ b/proto/accounts/v1/accounts_v1.proto @@ -1,60 +1,60 @@ -/// This file has messages for describing environments +/// Protobuf definitions for the accounts service. syntax = "proto3"; -package accounts; +package accounts.v1; import "google/protobuf/empty.proto"; -option go_package = "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/accounts"; +option go_package = "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/accounts/v1"; /** - * Service for handling environments + * Service for handling accounts that do not require authentication */ -service Accounts { - rpc SignUp (AccountWithPassword) returns (AccountFullWithToken) {} - rpc SignIn (AccountWithPassword) returns (AccountFullWithToken) {} - rpc ResetPassword (AccountData) returns (google.protobuf.Empty) {} - rpc NewPassword (AccountWithPasswordAndCode) returns (google.protobuf.Empty) {} - rpc IsEmailVerified (AccountData) returns (EmailVerified) {} +service AccountsNoAuthService { + // Sing in into an existing account + rpc SignIn (SignInRequest) returns (google.protobuf.Empty) {} } -message EmailVerified { - bool verified = 1; -} /** - * Represents a environment UUID only + * Service for handling accounts that do require authentication + * Tokens should be sent via metadata, so the service is able to authenticate a user for a request */ -message AccountId { - string id = 1; // Contour ID: UUID +service AccountsAuthService { + // Is email for the current account verified + rpc IsEmailVerified (IsEmailVerifiedRequest) returns (IsEmailVerifiedResponse) {} + rpc RefreshToken (google.protobuf.Empty) returns (google.protobuf.Empty) {} } message AccountPassword { string password = 1; } - message AccountData { string name = 1; // Account name string email = 2; // Account email } -message AccountWithPassword { +message SignUpRequest { AccountData data = 1; AccountPassword password = 2; } -message AccountWithPasswordAndCode { +message SignInRequest { + string code = 1; + string verifier = 2; +}; + +message ResetPasswordRequest { + AccountData data = 1; +} + +message NewPasswordRequest { AccountData data = 1; AccountPassword password = 2; string code = 3; } - -message AccountFull { - AccountId id = 1; - AccountData data = 2; +message IsEmailVerifiedRequest { + AccountData data = 1; } -message AccountFullWithToken { - AccountId id = 1; - AccountData data = 2; - string token = 3; +message IsEmailVerifiedResponse { + bool verified = 1; } - diff --git a/proto/test/v1/test_v1.proto b/proto/test/v1/test_v1.proto index 149c8ed..ea26408 100644 --- a/proto/test/v1/test_v1.proto +++ b/proto/test/v1/test_v1.proto @@ -5,8 +5,11 @@ option go_package = "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg /** * Service for handling environments */ -service TestService { +service TestNoAuthService { rpc Ping (PingRequest) returns (PingResponse) {} +} + +service TestAuthService { rpc Pong (PongRequest) returns (PongResponse) {} }