feat: Docker/gotrue (#43)
* feat: use gotrue from source instead of docker hub image * test: fix test due to gotrue upgrade * fix: update prod docker-compose * chore: cargo fmt --all
This commit is contained in:
parent
b3be09e264
commit
9fc2acbc35
|
|
@ -3,7 +3,7 @@ services:
|
|||
postgres:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile_postgres
|
||||
dockerfile: docker/postgres.Dockerfile
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
||||
- POSTGRES_DB=${POSTGRES_DB:-postgres}
|
||||
|
|
@ -20,7 +20,9 @@ services:
|
|||
- 6380:6379
|
||||
|
||||
gotrue:
|
||||
image: supabase/gotrue
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/gotrue.Dockerfile
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- postgres
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ services:
|
|||
postgres:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile_postgres
|
||||
dockerfile: docker/postgres.Dockerfile
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
||||
- POSTGRES_DB=${POSTGRES_DB:-postgres}
|
||||
|
|
@ -12,7 +12,7 @@ services:
|
|||
ports:
|
||||
- 5433:5432
|
||||
volumes:
|
||||
- ./migrations/before/:/docker-entrypoint-initdb.d
|
||||
- ./migrations/before:/docker-entrypoint-initdb.d
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
|
|
@ -20,7 +20,9 @@ services:
|
|||
- 6380:6379
|
||||
|
||||
gotrue:
|
||||
image: supabase/gotrue
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/gotrue.Dockerfile
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- postgres
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
FROM golang
|
||||
WORKDIR /go/src/supabase
|
||||
RUN git clone https://github.com/supabase/gotrue.git
|
||||
WORKDIR /go/src/supabase/gotrue
|
||||
RUN git checkout v2.95.2 && go install
|
||||
CMD ["gotrue"]
|
||||
|
|
@ -80,7 +80,7 @@ impl Client {
|
|||
access_token,
|
||||
token_type: token_type.ok_or(url_missing_param("token_type"))?,
|
||||
expires_in: expires_in.ok_or(url_missing_param("expires_in"))?,
|
||||
expires_at,
|
||||
expires_at: expires_at.ok_or(url_missing_param("expires_at"))?,
|
||||
refresh_token: refresh_token.ok_or(url_missing_param("refresh_token"))?,
|
||||
user,
|
||||
provider_access_token,
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ pub struct AccessTokenResponse {
|
|||
pub access_token: String,
|
||||
pub token_type: String,
|
||||
pub expires_in: i64,
|
||||
pub expires_at: Option<i64>, // older versions of GoTrue do not return this
|
||||
pub expires_at: i64,
|
||||
pub refresh_token: String,
|
||||
pub user: User,
|
||||
pub provider_access_token: Option<String>,
|
||||
|
|
@ -106,8 +106,8 @@ pub struct GoTrueSettings {
|
|||
pub mailer_autoconfirm: bool,
|
||||
pub phone_autoconfirm: bool,
|
||||
pub sms_provider: String,
|
||||
pub mfa_enabled: Option<bool>, // older versions of GoTrue do not return this
|
||||
pub saml_enabled: Option<bool>, // older versions of GoTrue do not return this
|
||||
pub mfa_enabled: bool,
|
||||
pub saml_enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -53,14 +53,16 @@ impl From<anyhow::Error> for AppError {
|
|||
#[cfg(feature = "cloud")]
|
||||
impl From<gotrue_entity::GoTrueError> for AppError {
|
||||
fn from(err: gotrue_entity::GoTrueError) -> Self {
|
||||
match err.code {
|
||||
401 => AppError::new(ErrorCode::OAuthError, err.msg),
|
||||
match (err.code, err.msg.as_str()) {
|
||||
(401, _) => AppError::new(ErrorCode::OAuthError, err.msg),
|
||||
(422, "New password should be different from the old password.") => {
|
||||
AppError::new(ErrorCode::InvalidPassword, err.msg)
|
||||
},
|
||||
_ => AppError::new(
|
||||
ErrorCode::Unhandled,
|
||||
format!(
|
||||
"gotrue error: {}, id: {}",
|
||||
err.code,
|
||||
err.error_id.unwrap_or("".to_string())
|
||||
"gotrue error: {}, message: {}, id: {:?}",
|
||||
err.code, err.msg, err.error_id,
|
||||
),
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,9 @@ async fn sign_in_with_url() {
|
|||
Ok(()) => panic!("should not be ok"),
|
||||
Err(e) => {
|
||||
assert_eq!(e.code, ErrorCode::OAuthError);
|
||||
assert!(e.message.starts_with("Invalid token: token is expired by"));
|
||||
assert!(e
|
||||
.message
|
||||
.starts_with("invalid JWT: unable to parse or verify signature, token is expired by"));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
use shared_entity::error_code::ErrorCode;
|
||||
|
||||
use crate::client::utils::{
|
||||
generate_unique_email, REGISTERED_EMAIL, REGISTERED_PASSWORD, REGISTERED_USER_MUTEX,
|
||||
};
|
||||
|
|
@ -20,9 +22,16 @@ async fn update_password_same_password() {
|
|||
c.sign_in_password(®ISTERED_EMAIL, ®ISTERED_PASSWORD)
|
||||
.await
|
||||
.unwrap();
|
||||
c.update(®ISTERED_EMAIL, ®ISTERED_PASSWORD)
|
||||
let err = c
|
||||
.update(®ISTERED_EMAIL, ®ISTERED_PASSWORD)
|
||||
.await
|
||||
.err()
|
||||
.unwrap();
|
||||
assert_eq!(err.code, ErrorCode::InvalidPassword);
|
||||
assert_eq!(
|
||||
err.message,
|
||||
"New password should be different from the old password."
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
|||
Loading…
Reference in New Issue