diff --git a/compose.yaml b/compose.yaml
index 91d5e3e..cd6d6b2 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -2,7 +2,7 @@
services:
# Engine
engine:
- image: ghcr.io/v3xlabs/v3x-property-engine:master
+ image: ghcr.io/v3xlabs/v3x-property/engine:master
ports:
- "3000:3000"
env_file: .env
diff --git a/engine/.build/realm-export.json b/engine/.build/realm-export.json
index 051e6bf..3343f79 100644
--- a/engine/.build/realm-export.json
+++ b/engine/.build/realm-export.json
@@ -35,7 +35,7 @@
"alwaysDisplayInConsole": false,
"clientAuthenticatorType": "client-secret",
"secret": "v3x-property-secret",
- "redirectUris": ["http://localhost:3000/callback"],
+ "redirectUris": ["http://localhost:3000/api/callback"],
"webOrigins": ["http://localhost:5173"],
"notBefore": 0,
"bearerOnly": false,
diff --git a/engine/.env.example b/engine/.env.example
index 3e44621..a19ffa6 100644
--- a/engine/.env.example
+++ b/engine/.env.example
@@ -1,7 +1,7 @@
# OpenID Connect OAuth 2.0
OPENID_CLIENT_ID=v3x-property
OPENID_CLIENT_SECRET=v3x-property-secret
-OPENID_REDIRECT=http://localhost:3000/callback
+OPENID_REDIRECT=http://localhost:3000/api/callback
OPENID_ISSUER=http://localhost:8080/realms/v3x-property
# Postgres Database
diff --git a/engine/README.md b/engine/README.md
index eb2c790..a9da9a7 100644
--- a/engine/README.md
+++ b/engine/README.md
@@ -31,6 +31,6 @@ This can easily be done by heading to the `Clients` tab in the admin console.
Then you can click on `Create client` and create a basic new OpenID Connect client.
Choose a Client ID, and press `Next`.
-Enable `Client Authentication` and specify the `Redirect URIs` to be `http://localhost:3000/callback`.
+Enable `Client Authentication` and specify the `Redirect URIs` to be `http://localhost:3000/api/callback`.
Once done you can head to the `Credentials` tab to see your Client Secret, insert this in your `.env` file.
diff --git a/engine/src/routes/mod.rs b/engine/src/routes/mod.rs
index 19e76af..a8fa970 100644
--- a/engine/src/routes/mod.rs
+++ b/engine/src/routes/mod.rs
@@ -4,7 +4,7 @@ use instance::InstanceApi;
use items::ItemsApi;
use me::MeApi;
use media::MediaApi;
-use oauth::login::LoginApi;
+use oauth::{callback::CallbackApi, login::LoginApi};
use poem::{
get, handler, listener::TcpListener, middleware::Cors, web::Html, EndpointExt, Route, Server,
};
@@ -52,6 +52,7 @@ fn get_api() -> impl OpenApi {
SessionsApi,
InstanceApi,
LoginApi,
+ CallbackApi,
)
}
@@ -69,7 +70,6 @@ pub async fn serve(state: AppState) -> Result<(), poem::Error> {
let state = Arc::new(state);
let app = Route::new()
- .at("/callback", get(oauth::callback::callback))
.nest("/api", api_service)
.nest("/openapi.json", spec)
.at("/docs", get(get_openapi_docs))
diff --git a/engine/src/routes/oauth/callback.rs b/engine/src/routes/oauth/callback.rs
index 057e624..2a638f7 100644
--- a/engine/src/routes/oauth/callback.rs
+++ b/engine/src/routes/oauth/callback.rs
@@ -4,83 +4,96 @@ use openid::Token;
use poem::{
handler,
http::HeaderMap,
- web::{Data, Query, RealIp, Redirect, WithHeader},
+ web::{Data, RealIp, Redirect, WithHeader},
IntoResponse, Result,
};
+use poem_openapi::{
+ param::Query,
+ payload::{PlainText, Response},
+ ApiResponse, Object, OpenApi,
+};
+use serde::Deserialize;
use tracing::info;
use url::Url;
use uuid::Uuid;
+use super::super::ApiTags;
use crate::{
auth::hash::hash_session,
models::{sessions::Session, user::userentry::UserEntry},
state::AppState,
};
-#[handler]
-pub async fn callback(
- state: Query