Getting Started
Install SqlOS and run the example stack in five minutes.
Install
dotnet add package SqlOS
Configure services
Register SqlOS with your EF Core DbContext. Enable one or both modules:
builder.AddSqlOS<AppDbContext>(options =>
{
options.UseAuthServer();
options.UseFGA();
});
Set up your DbContext
Your context implements both module interfaces and registers their models:
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:
options.UseAuthServer(auth =>
{
auth.SeedBrowserClient(
"my-app",
"My Application",
"http://localhost:3000/auth/callback");
});
Protect the dashboard
Set a dashboard password in appsettings.json:
{
"SqlOS": {
"Dashboard": {
"AuthMode": "Password",
"Password": "your-strong-password"
}
}
}
Run the example stack
The repo includes a complete example with API, Next.js frontend, Angular frontend, and Expo mobile app:
cd examples/SqlOS.Example.Web && npm install
cd /path/to/SqlOS
dotnet run --project examples/SqlOS.Example.AppHost/SqlOS.Example.AppHost.csproj
| URL | App |
|---|---|
http://localhost:5062/sqlos/ | Dashboard |
http://localhost:5062/swagger | Swagger UI |
http://localhost:3010/ | Next.js app |
http://localhost:4200/ | Angular app |
Schema management
SqlOS owns its own database schema. On host startup, SqlOS runs embedded SQL scripts to create or update tables. Your app's EF Core migrations do not manage SqlOS tables. If you apply EF migrations before the host runs, call SqlOSBootstrapper.InitializeAsync() once beforehand (see the example API for a pattern when consumer tables reference SqlOS).
Next steps
- AuthServer Overview -- identity, sessions, and auth flows
- FGA Overview -- hierarchical authorization and query filtering
- SDK Reference -- all services and methods