From 0c5b9648de1d53bb5b0d39ce0b1a9d258dfc5b89 Mon Sep 17 00:00:00 2001 From: Emmanuel Gautier Date: Fri, 29 Mar 2024 00:34:28 +0100 Subject: [PATCH] chore: prepare for crate publishing --- .github/workflows/release.yml | 2 +- .vscode/launch.json | 6 ++-- Cargo.lock | 8 +++--- Cargo.toml | 2 +- baffao-core/Cargo.toml | 22 --------------- baffao-proxy/Cargo.toml | 7 ++--- baffao-proxy/src/main.rs | 2 +- baffao-proxy/src/oauth.rs | 2 +- baffao-proxy/src/proxy.rs | 2 +- baffao-proxy/src/session.rs | 2 +- baffao-proxy/src/settings.rs | 2 +- baffao-proxy/src/state.rs | 2 +- baffao/Cargo.toml | 28 +++++++++++++++++++ {baffao-core => baffao}/src/cookies.rs | 0 {baffao-core => baffao}/src/error.rs | 0 .../src/handlers/authorize.rs | 0 .../src/handlers/callback.rs | 0 .../src/handlers/get_session.rs | 0 {baffao-core => baffao}/src/handlers/mod.rs | 0 {baffao-core => baffao}/src/handlers/proxy.rs | 0 {baffao-core => baffao}/src/lib.rs | 0 {baffao-core => baffao}/src/oauth/client.rs | 0 {baffao-core => baffao}/src/oauth/http.rs | 0 {baffao-core => baffao}/src/oauth/mod.rs | 0 .../src/session/extract_session.rs | 0 {baffao-core => baffao}/src/session/mod.rs | 0 .../src/session/update_session.rs | 0 {baffao-core => baffao}/src/settings.rs | 0 28 files changed, 46 insertions(+), 41 deletions(-) delete mode 100644 baffao-core/Cargo.toml create mode 100644 baffao/Cargo.toml rename {baffao-core => baffao}/src/cookies.rs (100%) rename {baffao-core => baffao}/src/error.rs (100%) rename {baffao-core => baffao}/src/handlers/authorize.rs (100%) rename {baffao-core => baffao}/src/handlers/callback.rs (100%) rename {baffao-core => baffao}/src/handlers/get_session.rs (100%) rename {baffao-core => baffao}/src/handlers/mod.rs (100%) rename {baffao-core => baffao}/src/handlers/proxy.rs (100%) rename {baffao-core => baffao}/src/lib.rs (100%) rename {baffao-core => baffao}/src/oauth/client.rs (100%) rename {baffao-core => baffao}/src/oauth/http.rs (100%) rename {baffao-core => baffao}/src/oauth/mod.rs (100%) rename {baffao-core => baffao}/src/session/extract_session.rs (100%) rename {baffao-core => baffao}/src/session/mod.rs (100%) rename {baffao-core => baffao}/src/session/update_session.rs (100%) rename {baffao-core => baffao}/src/settings.rs (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75450c2..b4bb4b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,6 +89,6 @@ jobs: - name: Install stable toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 - - run: cargo publish -p baffao-core + - run: cargo publish -p baffao env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.vscode/launch.json b/.vscode/launch.json index 3afe821..45e0082 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,16 +7,16 @@ { "type": "lldb", "request": "launch", - "name": "Debug unit tests in library 'baffao-core'", + "name": "Debug unit tests in library 'baffao'", "cargo": { "args": [ "test", "--no-run", "--lib", - "--package=baffao-core" + "--package=baffao" ], "filter": { - "name": "baffao-core", + "name": "baffao", "kind": "lib" } }, diff --git a/Cargo.lock b/Cargo.lock index 2b0bd76..e28be6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,8 +158,8 @@ dependencies = [ ] [[package]] -name = "baffao-core" -version = "0.1.0" +name = "baffao" +version = "0.0.1" dependencies = [ "anyhow", "axum-extra", @@ -179,11 +179,11 @@ dependencies = [ [[package]] name = "baffao-proxy" -version = "0.1.0" +version = "0.0.1" dependencies = [ "axum", "axum-extra", - "baffao-core", + "baffao", "config", "hyper 1.2.0", "hyper-util", diff --git a/Cargo.toml b/Cargo.toml index 81ca844..eb82da2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,6 @@ resolver = "2" members = [ - "baffao-core", + "baffao", "baffao-proxy", ] diff --git a/baffao-core/Cargo.toml b/baffao-core/Cargo.toml deleted file mode 100644 index 1705fe7..0000000 --- a/baffao-core/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "baffao-core" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -anyhow = "1.0.80" -axum-extra = { version = "0.9.2", features = ["cookie"] } -base64 = "0.22.0" -chrono = "0.4.35" -config = "0.14.0" -cookie = "0.18.0" -hex = "0.4.3" -http = "1.1.0" -jsonwebtoken = "9.2.0" -oauth2 = "4.4.2" -reqwest = "0.11.24" -ring = "0.17.8" -serde = "1.0.197" -serde_json = "1.0.114" diff --git a/baffao-proxy/Cargo.toml b/baffao-proxy/Cargo.toml index a5a2456..e63e5da 100644 --- a/baffao-proxy/Cargo.toml +++ b/baffao-proxy/Cargo.toml @@ -1,14 +1,13 @@ [package] name = "baffao-proxy" -version = "0.1.0" +version = "0.0.1" edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +publish = false [dependencies] axum = "0.7.4" axum-extra = { version = "0.9.2", features = ["typed-header", "cookie"] } -baffao-core = { path = "../baffao-core" } +baffao = { path = "../baffao" } config = "0.14.0" hyper = { version = "1.2.0", features = ["full"] } hyper-util = { version = "0.1.3", features = ["client-legacy"] } diff --git a/baffao-proxy/src/main.rs b/baffao-proxy/src/main.rs index 47b65fc..10d6a8c 100644 --- a/baffao-proxy/src/main.rs +++ b/baffao-proxy/src/main.rs @@ -10,7 +10,7 @@ use axum::{ routing::{any, get}, Router, }; -use baffao_core::oauth::OAuthHttpHandler; +use baffao::oauth::OAuthHttpHandler; use hyper_util::{client::legacy::connect::HttpConnector, rt::TokioExecutor}; use std::time::Duration; use tokio::signal; diff --git a/baffao-proxy/src/oauth.rs b/baffao-proxy/src/oauth.rs index 39ccd2a..2dd0902 100644 --- a/baffao-proxy/src/oauth.rs +++ b/baffao-proxy/src/oauth.rs @@ -5,7 +5,7 @@ use axum::{ response::{IntoResponse, Redirect}, }; use axum_extra::extract::CookieJar; -use baffao_core::{ +use baffao::{ handlers::{oauth2_authorize, oauth2_callback, AuthorizationCallbackQuery, AuthorizationQuery}, oauth::OAuthHttpHandler, }; diff --git a/baffao-proxy/src/proxy.rs b/baffao-proxy/src/proxy.rs index cb7469f..91283d0 100644 --- a/baffao-proxy/src/proxy.rs +++ b/baffao-proxy/src/proxy.rs @@ -4,7 +4,7 @@ use axum::{ response::IntoResponse, }; use axum_extra::extract::CookieJar; -use baffao_core::{handlers::proxy, oauth::OAuthHttpHandler}; +use baffao::{handlers::proxy, oauth::OAuthHttpHandler}; use crate::settings::Settings; use crate::state::HttpClient; diff --git a/baffao-proxy/src/session.rs b/baffao-proxy/src/session.rs index 56ca578..6c8cd78 100644 --- a/baffao-proxy/src/session.rs +++ b/baffao-proxy/src/session.rs @@ -1,6 +1,6 @@ use axum::{extract::State, response::IntoResponse, Json}; use axum_extra::extract::cookie::CookieJar; -use baffao_core::{handlers::get_session_from_cookie, session::Session}; +use baffao::{handlers::get_session_from_cookie, session::Session}; use serde::Serialize; use crate::settings::Settings; diff --git a/baffao-proxy/src/settings.rs b/baffao-proxy/src/settings.rs index 64e2f49..7f778ae 100644 --- a/baffao-proxy/src/settings.rs +++ b/baffao-proxy/src/settings.rs @@ -2,7 +2,7 @@ use config::{Config, ConfigError, Environment, File}; use serde::Deserialize; use std::env; -use baffao_core::{ +use baffao::{ oauth::OAuthConfig, settings::{JwtConfig, ServerConfig}, }; diff --git a/baffao-proxy/src/state.rs b/baffao-proxy/src/state.rs index 2c2be9c..ef3d80d 100644 --- a/baffao-proxy/src/state.rs +++ b/baffao-proxy/src/state.rs @@ -1,5 +1,5 @@ use axum::{body::Body, extract::FromRef}; -use baffao_core::oauth::OAuthHttpHandler; +use baffao::oauth::OAuthHttpHandler; use hyper_util::client::legacy::connect::HttpConnector; use crate::settings::Settings; diff --git a/baffao/Cargo.toml b/baffao/Cargo.toml new file mode 100644 index 0000000..e23d5e3 --- /dev/null +++ b/baffao/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "baffao" +version = "0.0.1" +authors = ["CerberAuth "] +repository = "https://github.com/cerberauth/baffao" +homepage = "https://github.com/cerberauth/baffao" +documentation = "https://github.com/cerberauth/baffao" +keywords = ["proxy", "oauth2", "authentication", "authorization", "auth"] +license = "MIT" +description = "BAckend For Frontend for your SPA authentication and authorization." +edition = "2021" +readme = "../README.md" + +[dependencies] +anyhow = "1.0.80" +axum-extra = { version = "0.9.2", features = ["cookie"] } +base64 = "0.22.0" +chrono = "0.4.35" +config = "0.14.0" +cookie = "0.18.0" +hex = "0.4.3" +http = "1.1.0" +jsonwebtoken = "9.2.0" +oauth2 = "4.4.2" +reqwest = "0.11.24" +ring = "0.17.8" +serde = "1.0.197" +serde_json = "1.0.114" diff --git a/baffao-core/src/cookies.rs b/baffao/src/cookies.rs similarity index 100% rename from baffao-core/src/cookies.rs rename to baffao/src/cookies.rs diff --git a/baffao-core/src/error.rs b/baffao/src/error.rs similarity index 100% rename from baffao-core/src/error.rs rename to baffao/src/error.rs diff --git a/baffao-core/src/handlers/authorize.rs b/baffao/src/handlers/authorize.rs similarity index 100% rename from baffao-core/src/handlers/authorize.rs rename to baffao/src/handlers/authorize.rs diff --git a/baffao-core/src/handlers/callback.rs b/baffao/src/handlers/callback.rs similarity index 100% rename from baffao-core/src/handlers/callback.rs rename to baffao/src/handlers/callback.rs diff --git a/baffao-core/src/handlers/get_session.rs b/baffao/src/handlers/get_session.rs similarity index 100% rename from baffao-core/src/handlers/get_session.rs rename to baffao/src/handlers/get_session.rs diff --git a/baffao-core/src/handlers/mod.rs b/baffao/src/handlers/mod.rs similarity index 100% rename from baffao-core/src/handlers/mod.rs rename to baffao/src/handlers/mod.rs diff --git a/baffao-core/src/handlers/proxy.rs b/baffao/src/handlers/proxy.rs similarity index 100% rename from baffao-core/src/handlers/proxy.rs rename to baffao/src/handlers/proxy.rs diff --git a/baffao-core/src/lib.rs b/baffao/src/lib.rs similarity index 100% rename from baffao-core/src/lib.rs rename to baffao/src/lib.rs diff --git a/baffao-core/src/oauth/client.rs b/baffao/src/oauth/client.rs similarity index 100% rename from baffao-core/src/oauth/client.rs rename to baffao/src/oauth/client.rs diff --git a/baffao-core/src/oauth/http.rs b/baffao/src/oauth/http.rs similarity index 100% rename from baffao-core/src/oauth/http.rs rename to baffao/src/oauth/http.rs diff --git a/baffao-core/src/oauth/mod.rs b/baffao/src/oauth/mod.rs similarity index 100% rename from baffao-core/src/oauth/mod.rs rename to baffao/src/oauth/mod.rs diff --git a/baffao-core/src/session/extract_session.rs b/baffao/src/session/extract_session.rs similarity index 100% rename from baffao-core/src/session/extract_session.rs rename to baffao/src/session/extract_session.rs diff --git a/baffao-core/src/session/mod.rs b/baffao/src/session/mod.rs similarity index 100% rename from baffao-core/src/session/mod.rs rename to baffao/src/session/mod.rs diff --git a/baffao-core/src/session/update_session.rs b/baffao/src/session/update_session.rs similarity index 100% rename from baffao-core/src/session/update_session.rs rename to baffao/src/session/update_session.rs diff --git a/baffao-core/src/settings.rs b/baffao/src/settings.rs similarity index 100% rename from baffao-core/src/settings.rs rename to baffao/src/settings.rs