Skip to content

Commit

Permalink
Auth "refactor"
Browse files Browse the repository at this point in the history
...aka just move it into its own module. Also update copyright and tidy random stuff or whatever
  • Loading branch information
andre4ik3 committed Mar 4, 2024
1 parent eda23bd commit c4f262e
Show file tree
Hide file tree
Showing 95 changed files with 1,255 additions and 318 deletions.
175 changes: 104 additions & 71 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["core", "macros", "modules/*", "silo"]
members = ["core", "modules/macros", "modules/*", "silo"]
resolver = "2"
2 changes: 1 addition & 1 deletion apps/cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/linux/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/linux/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/Launcher/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2023 andre4ik3</string>
<string>Copyright © 2023-2024 andre4ik3</string>
<key>NSMicrophoneUsageDescription</key>
<string>A mod is requesting access to the microphone.</string>
<key>SUEnableInstallerLauncherService</key>
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/Launcher/Sources/BridgingHeader.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/Launcher/Sources/LauncherApp.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/Launcher/Sources/Models/Instance.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/Launcher/Sources/Models/SettingsContainer.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/Launcher/Sources/Views/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/Launcher/Sources/Views/InstancesView.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/Launcher/Sources/Views/SettingsView.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/macos/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/game/assets.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/game/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/game/manifest/legacy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/game/manifest/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/game/manifest/v17w43a.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/game/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/game/version.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/java/adoptium.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/java/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/java/zulu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/assets.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/game.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/java/adoptium.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/java/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/java/zulu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/loaders/fabric.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/loaders/forge.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/loaders/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/tasks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion apps/metagen/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 andre4ik3
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
18 changes: 18 additions & 0 deletions modules/auth/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "launcher-auth"
version = "0.1.0"
edition = "2021"

[dependencies]
data = { path = "../data", version = "*", package = "launcher-data" }
fetch = { path = "../fetch", version = "*", package = "launcher-fetch" }
net = { path = "../net", version = "*", package = "launcher-net" }
persistence = { path = "../persistence", version = "*", package = "launcher-persistence" }
utils = { path = "../utils", version = "*", package = "launcher-utils" }

async-trait = "0.1"
chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] }
thiserror = "1"
tracing = "0.1"
url = { version = "2", features = ["serde"] }
uuid = { version = "1", features = ["v4"] }
58 changes: 58 additions & 0 deletions modules/auth/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright © 2023-2024 andre4ik3
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Launcher Authentication Module
//! ==============================
//!
//! This module deals with everything to do with online account authentication. Each authentication
//! service is divided

use async_trait::async_trait;
use thiserror::Error;

use data::auth::Account;
pub use microsoft::MicrosoftAuthenticationService;
use net::Client;
pub use offline::OfflineAuthenticationService;

pub(crate) mod microsoft;
pub(crate) mod offline;

#[derive(Debug, Error)]
pub enum Error {
#[error("wrong account type in authentication service: expected {0} but got {1}")]
WrongAccountType(&'static str, &'static str),
#[error("reauthentication is required")]
ReauthenticationRequired,
#[error("network error: {0}")]
NetworkError(#[from] net::Error),
#[error("failed decoding response from xbox api")]
DecodingError,
}

pub type Result<T> = core::result::Result<T, Error>;

/// A generic interface for interacting with an authentication service.
#[async_trait]
pub trait AuthenticationMethod {
/// The type of credentials that this authentication service accepts.
type Credentials;

/// Authenticates with the service, returning an authenticated account ready to be persisted.
async fn authenticate(client: &Client, credentials: Self::Credentials) -> Result<Account>;

/// Refreshes an expired account so that it is ready to be used again.
async fn refresh(client: &Client, account: Account) -> Result<Account>;
}
Loading

0 comments on commit c4f262e

Please sign in to comment.