mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 12:05:53 +00:00
feat(labrinth): route to update subscriptions for archon (#6811)
* feat(labrinth): add /_internal/billing/subscriptions/manager/update_many * chore: fixes * chore: clippy * chore: fixes
This commit is contained in:
@@ -6,6 +6,7 @@ use crate::env::ENV;
|
||||
pub const ADMIN_KEY_HEADER: &str = "Modrinth-Admin";
|
||||
pub const MEDAL_KEY_HEADER: &str = "X-Medal-Access-Key";
|
||||
pub const EXTERNAL_NOTIFICATION_KEY_HEADER: &str = "External-Notification-Key";
|
||||
pub const SUBSCRIPTIONS_KEY_HEADER: &str = "Modrinth-Subscriptions-Key";
|
||||
|
||||
pub fn admin_key_guard(ctx: &GuardContext) -> bool {
|
||||
ctx.head()
|
||||
@@ -30,6 +31,20 @@ pub fn external_notification_key_guard(ctx: &GuardContext) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn subscriptions_key_guard(ctx: &GuardContext) -> bool {
|
||||
// Ensure the subs key is set and at least 32 characters
|
||||
if ENV.LABRINTH_SUBSCRIPTIONS_KEY.chars().count() < 32 {
|
||||
return false;
|
||||
}
|
||||
|
||||
ctx.head()
|
||||
.headers()
|
||||
.get(SUBSCRIPTIONS_KEY_HEADER)
|
||||
.is_some_and(|it| {
|
||||
it.as_bytes() == ENV.LABRINTH_SUBSCRIPTIONS_KEY.as_bytes()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn internal_network_guard(ctx: &GuardContext) -> bool {
|
||||
ctx.head()
|
||||
.peer_addr
|
||||
|
||||
Reference in New Issue
Block a user