Skip to content

Commit

Permalink
fix(webserver): update graphql api schema, update api doc, fix warning (
Browse files Browse the repository at this point in the history
  • Loading branch information
darknight authored Jan 16, 2024
1 parent 624f415 commit 4ee2311
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
21 changes: 21 additions & 0 deletions ee/tabby-webserver/docs/api_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,24 @@ The request will redirect to `/auth/signin` with refresh token & access token at
```
http://localhost:8080/auth/signin?refresh_token=321bc1bbb043456dae1a7abc0c447875&access_token=eyJ0eXAi......1NiJ9.eyJleHAi......bWluIjp0cnVlfQ.GvHSMUfc...S5BnwY
```

### Google

**URL:** `/oauth_callback/google`

**Method:** `GET`

**Request example:**

```shell
curl --request GET \
--url http://localhost:9090/oauth_callback/google?code=4%2F0AfJohXmJC_bdPrLp5......lZY9gTxq2eg&scope=email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=1&prompt=consent
```

**Response example:**

The request will redirect to `/auth/signin` with refresh token & access token attached.

```
http://localhost:8080/auth/signin?refresh_token=321bc1bbb043456dae1a7abc0c447875&access_token=eyJ0eXAi......1NiJ9.eyJleHAi......bWluIjp0cnVlfQ.GvHSMUfc...S5BnwY
```
5 changes: 3 additions & 2 deletions ee/tabby-webserver/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Mutation {
createInvitation(email: String!): ID!
deleteInvitation(id: Int!): Int! @deprecated
deleteInvitationNext(id: ID!): ID!
updateOauthCredential(provider: OAuthProvider!, clientId: String!, clientSecret: String, active: Boolean!): Boolean!
updateOauthCredential(provider: OAuthProvider!, clientId: String!, clientSecret: String!, redirectUri: String): Boolean!
}

"DateTime"
Expand Down Expand Up @@ -89,7 +89,7 @@ type UserConnection {
type OAuthCredential {
provider: OAuthProvider!
clientId: String!
active: Boolean!
redirectUri: String
createdAt: DateTimeUtc!
updatedAt: DateTimeUtc!
}
Expand Down Expand Up @@ -136,6 +136,7 @@ type InvitationEdge {

enum OAuthProvider {
GITHUB
GOOGLE
}

type PageInfo {
Expand Down
2 changes: 2 additions & 0 deletions ee/tabby-webserver/src/oauth/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::Deserialize;
use tabby_db::GithubOAuthCredentialDAO;

#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct GithubOAuthResponse {
#[serde(default)]
access_token: String,
Expand All @@ -20,6 +21,7 @@ struct GithubOAuthResponse {
}

#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct GithubUserEmail {
email: String,
primary: bool,
Expand Down
2 changes: 2 additions & 0 deletions ee/tabby-webserver/src/oauth/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::Deserialize;
use tabby_db::GoogleOAuthCredentialDAO;

#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct GoogleOAuthResponse {
#[serde(default)]
access_token: String,
Expand All @@ -15,6 +16,7 @@ struct GoogleOAuthResponse {
}

#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct GoogleOAuthError {
code: i32,
message: String,
Expand Down
5 changes: 1 addition & 4 deletions ee/tabby-webserver/src/oauth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ use tracing::error;

use crate::{
oauth::{github::GithubClient, google::GoogleClient},
schema::{
auth::{AuthenticationService, OAuthError, OAuthResponse},
ServiceLocator,
},
schema::auth::{AuthenticationService, OAuthError, OAuthResponse},
};

pub mod github;
Expand Down

0 comments on commit 4ee2311

Please sign in to comment.