authentication
Skill108 starsChanged 5 months agoMITView on GitHub
Wire this in whenever the app uses or connects to data — records, a database, entities, per-user data, row-level security — or when the user wants sign-in, accounts, login, or protected pages. Rayfin data is always accessed as an authenticated user, so **data implies auth**; only a static page over public data skips it. The starter ships as a no-auth "hello world" that previews with no backend, and the full Fabric auth scaffolding is already in the project — this skill wires it in: AuthProvider + bootstrapAuth in main.tsx, the route guard in App.tsx, the sign-in page, sign-out, and the env/deploy requirement. Triggers: auth, authentication, sign in, sign-in, login, log in, sign out, logout, account, user, identity, protect route, require login, gated page, data, database, records, per-user, row-level security, who is the current user, Fabric auth, Entra.
We split this skill into the rules it gives an agent
1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 69
Add an AuthGuard that reads useAuth() and redirects unauthenticated users to the sign-in page, then wrap protected routes with it:
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Enabling authentication
This starter renders a no-auth hello-world page so it previews locally
(npm run preview) with no backend. The Fabric auth scaffolding is present but
not wired into the running app.
Wire it in as soon as the app uses data. Rayfin data is always accessed as an authenticated user — there is no anonymous/public data access on Fabric — so the moment you add data (records, a database, per-user rows, row-level security), or the user asks for sign-in / accounts / protected pages, wire auth in with the steps below. A static page over public data (no Rayfin data) stays no-auth.
Authentication needs a deployed Rayfin backend.
rayfin envinjects theVITE_RAYFIN_*andVITE_FABRIC_*vars at build time from the active deployment, andbootstrapAuth()throws without them — so once auth is wired in, the app must be deployed (npm run rayfin:up) to run.npm run preview(no backend) only works while the app stays no-auth.
What's already in the project
| File | Role |
src/services/IAuthService.ts | Auth contract + AuthUser type |
src/services/RayfinAuthService.ts | Fabric brokered auth (the real implementation) |
src/services/rayfinClient.ts | Typed Rayfin client singleton |
src/services/bootstrap.ts | Reads env, builds the auth service |
src/hooks/AuthContext.tsx | AuthProvider + useAuth() |
src/components/AuthPage.tsx | Sign-in UI |
Step 1 — wire the provider in src/main.tsx
import { createRoot } from 'react-dom/client';
import App from '@/App';
import { AuthProvider } from '@/hooks/AuthContext';
import { bootstrapAuth } from '@/services/bootstrap';
import './main.css';
const authService = bootstrapAuth();
createRoot(document.getElementById('root')!).render(
<AuthProvider authService={authService}>
<App />
</AuthProvider>
);Step 2 — gate routes in src/App.tsx
Add an AuthGuard that reads useAuth() and redirects unauthenticated users to
the sign-in page, then wrap protected routes with it:
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
import { AuthPage } from '@/components/AuthPage';
import { useAuth } from '@/hooks/AuthContext';
import { HomePage } from '@/pages/HomePage';
function AuthGuard({
children,
requireAuth,
}: {
children: React.ReactNode;
requireAuth: boolean;
}) {
const { isAuthenticated, loading } = useAuth();
if (loading) {
return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-gray-500">Loading...</div>
</div>
);
}
if (requireAuth && !isAuthenticated) return <Navigate to="/auth" replace />;
if (!requireAuth && isAuthenticated) return <Navigate to="/" replace />;
return <>{children}</>;
}
function App() {
return (
<BrowserRouter>
<Routes>
<Route
path="/auth"
element={
<AuthGuard requireAuth={false}>
<AuthPage />
</AuthGuard>
}
/>
<Route
path="/"
element={
<AuthGuard requireAuth={true}>
<HomePage />
</AuthGuard>
}
/>
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
</BrowserRouter>
);
}
export default App;Step 3 — use the session in components
Anywhere under AuthProvider, call useAuth():
const { user, signOut } = useAuth();
// user?.name, user?.email
// <button onClick={() => void signOut()}>Sign out</button>Adding a capability pack later?
npm run pack:add -- <pack>will not overwrite thesrc/main.tsxandsrc/App.tsxyou wired above — it keeps them and prints the kit files to merge in by hand. Merge the pack's providers inside yourAuthProviderand route guard.
Step 4 — deploy
npm run rayfin:upOnce deployed, open the app to check that sign-in works.
npm run preview no longer renders once routes require auth (there's no local
session), so preview only the parts you keep public, or preview before gating.
Other versions19 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 19
- BuilderIO/agent-native★ 7.4ksame name
- latitude-dev/latitude-llm★ 4.7ksame name
- Resgrid/Core★ 229same name
- nahid-sparktales/agent-dispatcher★ 59same name
- autosendhq/email-skills★ 18same name
- CheehooLabs/SpureeSkills★ 18same name
- zdanovichnick/dotnet-pilot★ 5same name
- pluginagentmarketplace/custom-plugin-backend★ 4same name
- thienqo/ios-skills★ 4same name
- jkaninda/okapi-skills★ 3same name
9 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use caching, monitoring and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
zebbernSkillcaching
Caching strategies — invalidation, TTL guidelines, cache keys, cache layers, and when not to cache. Use when implementing or reviewing caching logic.
Also in 4 projects that use this
cwklurksSkillmonitoring
Also in 3 projects that use this
harrissohail6Skillclean-architecture
Clean architecture and SOLID principles. Auto-activates when designing systems or refactoring code structure.
Also in 4 projects that use this
xfstudioSkillsecrets-management
Implement secure secrets management for CI/CD pipelines using Vault, AWS Secrets Manager, or native platform solutions. Use when handling sensitive credentials, rotating secrets, or securing CI/CD environments.
Also in 3 projects that use this
MicrosoftSkillerror-handling
统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。
Also in 4 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 3 projects that use this
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- templates/angular-blankapp/AGENTS.mdAGENTS.md
- templates/angular-dashboard/AGENTS.mdAGENTS.md
- templates/campus-scheduler/AGENTS.mdAGENTS.md
- templates/fabric-atlas/AGENTS.mdAGENTS.md
- templates/field-technician/AGENTS.mdAGENTS.md
- templates/finance-analytics/AGENTS.mdAGENTS.md
- templates/ibcs-trainer/AGENTS.mdAGENTS.md
- templates/maritime-insights/AGENTS.mdAGENTS.md
- templates/paragliding-insights/AGENTS.mdAGENTS.md
- templates/slide-deck/AGENTS.mdAGENTS.md
- templates/static-blankapp/AGENTS.mdAGENTS.md
- templates/todo-local-experimental/AGENTS.mdAGENTS.md
- templates/universal-app/AGENTS.mdAGENTS.md
- template-gallerySkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- analyticsSkill
- app-designSkill
- build-workflowSkill
- capability-routerSkill
- data-modelingSkill
- daxSkill
- fabric-dataSkill
- graphein-visualsSkill
- headless-previewSkill
- visualsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

