chore: config nginx (#93)

* chore: config nginx

* chore: update nginx
This commit is contained in:
Nathan.fooo 2023-10-04 22:11:46 +08:00 committed by GitHub
parent c0aea377d0
commit 4a279bc108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 21 deletions

1
Cargo.lock generated
View File

@ -1598,6 +1598,7 @@ dependencies = [
"serde",
"serde_json",
"tokio",
"tracing",
]
[[package]]

View File

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use std::fmt::Formatter;
use std::{collections::BTreeMap, fmt::Display};
#[derive(Debug, Serialize, Deserialize)]
@ -99,6 +100,15 @@ pub struct GoTrueError {
pub error_id: Option<String>,
}
impl Display for GoTrueError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"gotrue error: {} code: {}, error_id: {:?}",
self.msg, self.code, self.error_id
))
}
}
impl From<anyhow::Error> for GoTrueError {
fn from(value: anyhow::Error) -> Self {
GoTrueError {

View File

@ -13,4 +13,5 @@ anyhow = "1.0.75"
reqwest = { version = "0.11.20", default-features = false, features = ["json", "rustls-tls", "cookies"] }
tokio = { version = "1.0.1", features = ["sync", "macros"] }
infra = { path = "../infra" }
gotrue-entity = { path = "../gotrue-entity" }
gotrue-entity = { path = "../gotrue-entity" }
tracing = "0.1"

View File

@ -25,6 +25,7 @@ impl Client {
format!("{}/authorize?provider={}", self.base_url, provider.as_str())
}
#[tracing::instrument(skip_all, err)]
pub async fn health(&self) -> Result<(), GoTrueError> {
let url: String = format!("{}/health", self.base_url);
let resp = self
@ -36,6 +37,7 @@ impl Client {
Ok(check_response(resp).await?)
}
#[tracing::instrument(skip_all, err)]
pub async fn settings(&self) -> Result<GoTrueSettings, GoTrueError> {
let url: String = format!("{}/settings", self.base_url);
let resp = self.client.get(&url).send().await?;
@ -45,6 +47,7 @@ impl Client {
Ok(settings)
}
#[tracing::instrument(skip_all, err)]
pub async fn sign_up(&self, email: &str, password: &str) -> Result<SignUpResponse, GoTrueError> {
let payload = serde_json::json!({
"email": email,
@ -55,6 +58,7 @@ impl Client {
to_gotrue_result(resp).await
}
#[tracing::instrument(skip_all, err)]
pub async fn token(&self, grant: &Grant) -> Result<AccessTokenResponse, GoTrueError> {
let url = format!("{}/token?grant_type={}", self.base_url, grant.type_as_str());
let payload = grant.json_value();
@ -69,6 +73,7 @@ impl Client {
}
}
#[tracing::instrument(skip_all, err)]
pub async fn logout(&self, access_token: &str) -> Result<(), GoTrueError> {
let resp = self
.client
@ -79,10 +84,12 @@ impl Client {
Ok(check_response(resp).await?)
}
#[tracing::instrument(skip_all, err)]
pub async fn user_info(&self, access_token: &str) -> Result<User, GoTrueError> {
let url = format!("{}/user", self.base_url);
let resp = self
.client
.get(format!("{}/user", self.base_url))
.get(&url)
.header("Authorization", format!("Bearer {}", access_token))
.send()
.await?;

View File

@ -14,18 +14,9 @@ http {
listen 443 ssl;
# GoTrue
location /verify {
proxy_pass http://gotrue:9999;
}
location /authorize {
proxy_pass http://gotrue:9999;
}
location /callback {
proxy_pass http://gotrue:9999;
}
location /settings{
proxy_pass http://gotrue:9999;
}
location ~ ^/(verify|authorize|callback|settings|user) {
proxy_pass http://gotrue:9999;
}
# AppFlowy-Cloud
location / {

View File

@ -2,7 +2,7 @@ use gotrue_entity::OAuthProvider;
use shared_entity::error_code::ErrorCode;
use crate::{
localhost_client,
localhost_client, test_appflowy_cloud_client,
user::utils::{generate_unique_email, generate_unique_registered_user_client},
};
@ -70,10 +70,13 @@ async fn sign_up_with_google_oauth() {
.unwrap();
assert!(!url.is_empty());
// let c = test_appflowy_cloud_client();
// let url = c
// .generate_oauth_url_with_provider(&OAuthProvider::Google)
// .await
// .unwrap();
// assert!(!url.is_empty());
let c = test_appflowy_cloud_client();
let url = c
.generate_oauth_url_with_provider(&OAuthProvider::Google)
.await
.unwrap();
assert!(!url.is_empty());
// let a = r#"appflowy-flutter://#access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2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4&expires_at=1696431180&expires_in=3600&provider_token=ya29.a0AfB_byDtFDX9UfiXw3IKzGTrZeebaQCxheWpqVg3tZi5jCWdKmZRBFsh7p7k0svqxaaX8rqN0lQsFeBbdGtd7KOSYtjsfcOkpHMH0d1fMSxrlyl_KkuvlkJe9q_X4SvpsJmx0VsVZ1CMypszLd4nzZitB0KotQPMzFMaCgYKAcASARESFQGOcNnC8cf9LzY-ZeirJHIwfL9r8w0170&refresh_token=tXCWxsp3cQF8U2307mGuMQ&token_type=bearer"#;
// c.sign_in_with_url(a).await.unwrap();
}