The hub as an OpenID Connect provider for T5DE Music
This commit is contained in:
1 parent
f0a9661f8e
commit
096ee32fa5
20 files changed
+6531
-29
No files matched your search
@@ -0,0 +1,42 @@
|
||||
// Another site asks to sign the person in with their T5DE account. T5DE's own sites (Music) are trusted and never get
|
||||
// here; this is for sites added later (docs/music.md, The OIDC provider).
|
||||
import type { Metadata } from "next";
|
||||
import { redirect } from "next/navigation";
|
||||
import { NarrowCard } from "@/components/narrow-card";
|
||||
import { api, getMe } from "@/lib/api";
|
||||
import { ConsentForm } from "./consent-form";
|
||||
|
||||
export const metadata: Metadata = { title: "Allow Access" };
|
||||
|
||||
/** What each scope lets a site see or do, in words. */
|
||||
const scopeText: Record<string, string> = {
|
||||
openid: "Know it's you",
|
||||
profile: "Your name and username",
|
||||
email: "Your email address",
|
||||
offline_access: "Stay signed in when you're away",
|
||||
imvu: "Your linked IMVU accounts",
|
||||
"imvu:link": "Link and unlink IMVU accounts for you",
|
||||
};
|
||||
|
||||
export default async function Consent({ searchParams }: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {
|
||||
const params = await searchParams;
|
||||
const me = await getMe();
|
||||
if (!me) redirect("/signin");
|
||||
const clientId = typeof params.client_id === "string" ? params.client_id : "";
|
||||
const site = clientId ? (await api.oauth.clients({ clientId }).get()).data : undefined;
|
||||
const name = site && "client" in site ? site.client.name : undefined;
|
||||
if (!name) return <NarrowCard title="Allow Access" description="This request isn't valid any more. Start again from the site." />;
|
||||
const scopes = (typeof params.scope === "string" ? params.scope : "").split(" ").filter((s) => s in scopeText);
|
||||
return (
|
||||
<NarrowCard title="Allow Access" description={`${name} wants to use your T5DE account, ${me.username}.`}>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-5 text-sm">
|
||||
{scopes.map((s) => (
|
||||
<li key={s}>{scopeText[s]}</li>
|
||||
))}
|
||||
</ul>
|
||||
<ConsentForm />
|
||||
</div>
|
||||
</NarrowCard>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user