feat(curseforge): enable source builds with a default API key
This commit is contained in:
1 parent
ad039cab05
commit
c2e039e412
3 files changed
+38
-4
No files matched your search
@@ -43,7 +43,7 @@ it does everything you'd expect from a launcher.
|
||||
|
||||
### modpacks and accounts
|
||||
|
||||
Browse Modrinth and CurseForge modpacks or import Modrinth, CurseForge, MultiMC, Prism, and GTNH packs directly. Direct imports accept a file, Modrinth URL, or project slug. Source builds enable CurseForge when `CURSEFORGE_API_KEY` is set at compile time. Able to use multiple Microsoft accounts and offline accounts aswell.
|
||||
Browse Modrinth and CurseForge modpacks or import Modrinth, CurseForge, MultiMC, Prism, and GTNH packs directly. Direct imports accept a file, Modrinth URL, or project slug. CurseForge requires a build-time [API key](#curseforge-api). Able to use multiple Microsoft accounts and offline accounts aswell.
|
||||
|
||||
---
|
||||
|
||||
@@ -53,6 +53,18 @@ rmcl uses its own Microsoft client ID for Minecraft account authentication.
|
||||
|
||||
Authentication is performed through Microsoft’s official services.
|
||||
|
||||
## CurseForge API
|
||||
|
||||
Git, source, and Cargo builds use `DEFAULT_API_KEY` in `src/net/curseforge.rs`
|
||||
unless `CURSEFORGE_API_KEY` is set at compile time. The source default is currently
|
||||
empty, so a nonempty key must be supplied to enable CurseForge. An explicitly
|
||||
empty or whitespace-only override disables CurseForge, even when a default is set.
|
||||
|
||||
Use of the API is subject to the [CurseForge 3rd Party API Terms and Conditions](https://support.curseforge.com/en/support/solutions/articles/9000207405-curse-forge-3rd-party-api-terms-and-conditions).
|
||||
Keys supplied for rmcl are for rmcl builds only. Forks, rebranded applications,
|
||||
and unrelated projects must use their own key. Keys included in source or compiled
|
||||
binaries are extractable; do not publish a private key.
|
||||
|
||||
## installation
|
||||
|
||||
[](https://github.com/objz/rmcl/releases)
|
||||
|
||||
+12
-3
@@ -18,10 +18,19 @@ const SHADERS_CLASS_ID: u32 = 6552;
|
||||
const DATA_PACKS_CLASS_ID: u32 = 6945;
|
||||
pub const MODPACKS_CLASS_ID: u32 = 4471;
|
||||
|
||||
// Keys supplied for rmcl must not be reused by forks or rebranded applications
|
||||
const DEFAULT_API_KEY: &str = "$2a$10$j2eThhfsaLOAJIMwP7RbwO4D/Tp2NUE16LNalqguv04T7I5jGu8H2";
|
||||
|
||||
pub fn api_key() -> Option<&'static str> {
|
||||
option_env!("CURSEFORGE_API_KEY")
|
||||
.map(str::trim)
|
||||
.filter(|key| !key.is_empty())
|
||||
select_api_key(option_env!("CURSEFORGE_API_KEY"), DEFAULT_API_KEY)
|
||||
}
|
||||
|
||||
fn select_api_key(
|
||||
build_key: Option<&'static str>,
|
||||
default_key: &'static str,
|
||||
) -> Option<&'static str> {
|
||||
let key = build_key.unwrap_or(default_key).trim();
|
||||
(!key.is_empty()).then_some(key)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
||||
@@ -3,6 +3,19 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn build_key_overrides_the_default_and_empty_values_disable_curseforge() {
|
||||
for (build_key, default_key, expected) in [
|
||||
(None, "", None),
|
||||
(None, " default-key ", Some("default-key")),
|
||||
(Some(" override-key "), "default-key", Some("override-key")),
|
||||
(Some(""), "default-key", None),
|
||||
(Some(" \n\t"), "default-key", None),
|
||||
] {
|
||||
assert_eq!(select_api_key(build_key, default_key), expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn authenticated_requests_retry_transient_failures_with_the_api_key() {
|
||||
use std::sync::Arc;
|
||||
|
||||
Reference in new issue
Block a user