Delete requiredEntitlementPolicyKind and the policy-demand guard on the private plane
Heimdall no longer demands a caller-owned Discord role policy from ghostlight at begin or refresh; a caller-sent policy stays accepted and optional as for every other app. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
22a7f41454
commit
bd6e8d6d06
2 changed files with 1 additions and 31 deletions
|
|
@ -3,7 +3,7 @@ import {
|
|||
type CapabilityDefinition,
|
||||
type CapabilityMode,
|
||||
} from "./capability-rules.js";
|
||||
import { type AppSlug, type LinkedIdentityInput, type OAuthConnectionBinding, type OAuthEntitlementPolicy, type OAuthMode, type Provider } from "./contracts.js";
|
||||
import { type AppSlug, type LinkedIdentityInput, type OAuthConnectionBinding, type OAuthMode, type Provider } from "./contracts.js";
|
||||
import { entitlementFacts, grantFacts, identityFacts } from "./facts.js";
|
||||
|
||||
export type { CapabilityDefinition, CapabilityMode };
|
||||
|
|
@ -38,13 +38,6 @@ export interface AppProfile {
|
|||
* primitive, not a convenience. Compared by URL origin, not prefix.
|
||||
*/
|
||||
allowedReturnOrigins: readonly string[];
|
||||
/**
|
||||
* Some apps require the caller to supply an entitlement policy of a
|
||||
* specific kind on every begin/refresh (ghostlight's caller-owned Discord
|
||||
* role gate). Data instead of a per-slug branch in the private command
|
||||
* plane; absent for apps with no such requirement.
|
||||
*/
|
||||
requiredEntitlementPolicyKind?: OAuthEntitlementPolicy["kind"];
|
||||
/**
|
||||
* The app binds browser completion to its own pending attempt, and the
|
||||
* binding is the secrecy of the attempt nonce, which rides readable in the
|
||||
|
|
@ -200,7 +193,6 @@ const ghostlightProfile: AppProfile = {
|
|||
entitlementSources: ["discord"],
|
||||
managedConnectionProviders: [],
|
||||
allowedReturnOrigins: ["https://yggdrasil.gamecult.org"],
|
||||
requiredEntitlementPolicyKind: "discord_role_access",
|
||||
capabilities: [
|
||||
{
|
||||
key: "app_access",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import {
|
|||
import { type FastifyInstance } from "fastify";
|
||||
import { errorIdentity, getHeimdallRuntimeContext, refreshAppSession, startOAuthFlow, verifyRefreshToken } from "./app.js";
|
||||
import { callerFromOpenedEnvelope } from "./app-caller.js";
|
||||
import { getAppProfile } from "./app-profiles.js";
|
||||
import { executeHeimdallAccessPlugin, HEIMDALL_ACCESS_PLUGIN_ID, type EvePluginAbiRequest } from "./access-plugin.js";
|
||||
import { isAppSlug, oauthModes, providers, type AppSlug, type OAuthEntitlementPolicy, type OAuthMode, type Provider } from "./contracts.js";
|
||||
import { type HeimdallConfig } from "./config.js";
|
||||
|
|
@ -233,7 +232,6 @@ async function refreshAuth(
|
|||
// handler function the HTTP route uses rather than forging the HTTP header
|
||||
// back at itself.
|
||||
const context = getHeimdallRuntimeContext(app);
|
||||
await requireEntitlementPolicyIfProfileDemandsIt(appSlug, entitlementPolicy, "refresh");
|
||||
const result = await refreshAppSession(context, appSlug, callerFromOpenedEnvelope(appSlug), {
|
||||
refreshToken,
|
||||
...(entitlementPolicy ? { entitlementPolicy } : {}),
|
||||
|
|
@ -269,7 +267,6 @@ async function beginAuth(
|
|||
if (!providers.includes(provider) || !oauthModes.includes(mode) || !returnTo) throw new Error("Auth begin payload is incomplete.");
|
||||
const entitlementPolicy = parseEntitlementPolicy(payload.entitlementPolicy);
|
||||
const store = getHeimdallRuntimeContext(app).store;
|
||||
await requireEntitlementPolicyIfProfileDemandsIt(appSlug, entitlementPolicy, "authentication");
|
||||
const now = new Date();
|
||||
const attempt = await store.createAuthAttempt({
|
||||
handle: randomUUID(),
|
||||
|
|
@ -387,25 +384,6 @@ function parseEntitlementPolicy(value: unknown): OAuthEntitlementPolicy | undefi
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ghostlight requires its caller-owned Discord role policy on every begin and
|
||||
* refresh; that used to be a literal `appSlug === "ghostlight"` branch here.
|
||||
* The requirement is now data on the app's profile
|
||||
* (AppProfile.requiredEntitlementPolicyKind), so a future app with the same
|
||||
* need declares it in its profile instead of adding another branch.
|
||||
*/
|
||||
async function requireEntitlementPolicyIfProfileDemandsIt(
|
||||
appSlug: AppSlug,
|
||||
entitlementPolicy: OAuthEntitlementPolicy | undefined,
|
||||
action: "authentication" | "refresh",
|
||||
): Promise<void> {
|
||||
const profile = getAppProfile(appSlug);
|
||||
const requiredKind = profile?.requiredEntitlementPolicyKind;
|
||||
if (requiredKind && entitlementPolicy?.kind !== requiredKind) {
|
||||
throw new Error(`${appSlug} ${action} requires its caller-owned ${requiredKind} policy.`);
|
||||
}
|
||||
}
|
||||
|
||||
function response(
|
||||
request: CultNetOperationRequestMessage,
|
||||
status: string,
|
||||
|
|
|
|||
Loading…
Reference in a new issue