Getting Started
Getting Started
Install SqlOS and run the example stack in five minutes.
Install the package
Add SqlOS to your app and keep your auth plus authorization runtime inside the same ASP.NET process.
Register the DbContext integration
Point SqlOS at your EF Core context so it can wire auth and FGA tables into the host application.
Map the routes
Expose the dashboard, OAuth/OIDC endpoints, hosted auth UI, and FGA admin screens through app.MapSqlOS().
Install#
dotnet add package SqlOSConfigure services#
Register SqlOS on your DbContext:
builder.AddSqlOS<AppDbContext>();Set up your DbContext#
Your context implements the SqlOS interfaces. This sample includes both auth and FGA:
public sealed class AppDbContext : DbContext,
ISqlOSAuthServerDbContext,
ISqlOSFgaDbContext
{
public DbSet<Project> Projects => Set<Project>();
public IQueryable<SqlOSFgaAccessibleResource> IsResourceAccessible(
string subjectId,
string permissionKey)
=> FromExpression(() =>
IsResourceAccessible(subjectId, permissionKey));
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.UseSqlOS(GetType());
}
}Map routes#
var app = builder.Build();
app.MapSqlOS();This gives you:
| Path | What it does |
|---|---|
/sqlos | Admin dashboard |
/sqlos/auth/* | OAuth 2.0 endpoints (authorize, token, JWKS) |
/sqlos/admin/auth | Auth management UI |
/sqlos/admin/fga | FGA management UI |
Seed a client#
Register your frontend as an OAuth client so users can sign in immediately:
builder.AddSqlOS<AppDbContext>(options =>
{
options.AuthServer.SeedOwnedWebApp(
"my-app",
"My Application",
"http://localhost:3000/auth/callback");
});That is the default story for most teams: an owned app, hosted auth, and a seeded client.
Protect the dashboard#
Set a dashboard password in appsettings.json:
{
"SqlOS": {
"Dashboard": {
"AuthMode": "Password",
"Password": "your-strong-password"
}
}
}Run the right sample#
If your first goal is hosted auth, simple FGA, and public-client onboarding, start with the Todo sample:
dotnet run --project examples/SqlOS.Todo.AppHost/SqlOS.Todo.AppHost.csprojThat sample focuses on:
- hosted auth first
- per-user tenant + todo resource hierarchy
- SQL-backed FGA filtering and simple auth checks
- headless follow-on
- protected-resource metadata
- preregistration,
CIMD, and optionalDCR
Schema management#
SqlOS runs its own SQL scripts on host startup. Your EF migrations do not own those tables.
If you migrate before the app has started SqlOS once, call SqlOSBootstrapper.InitializeAsync() first. The example API shows that pattern when your tables reference SqlOS.
Next steps#
- AuthServer Overview -- identity, sessions, and auth flows
- Todo Sample -- hosted auth, simple FGA, and MCP-oriented flows
- FGA Overview -- hierarchical authorization and query filtering
- SDK Reference -- all services and methods