Before you start
- Create a workspace at https://auth.ziqme.com/signup. It starts on the Free plan; no card is needed.
- Open https://app.ziqme.com/auth-admin, choose "Register application", and add your redirect URI. A browser or mobile app is a public application (no secret). A server is confidential and gets a client secret, shown once.
- Note the client ID (it starts with app_). It is safe to ship in a browser: it is not a secret.
Protect an API
JwtBearer needs nothing specific to Auth: it reads the discovery document and the signing keys by itself.
builder.Services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = "https://auth.ziqme.com";
options.Audience = "app_your_client_id";
options.MapInboundClaims = false;
options.TokenValidationParameters.RoleClaimType = "roles";
options.TokenValidationParameters.ValidTypes = ["at+jwt"];
});
app.MapGet("/orders", [Authorize(Roles = "manager")] () => Results.Ok());The SmartDesk.Auth.Sdk package wraps the same settings in AddAuthSdkBearer and adds the webhook signature check. It is not on NuGet yet; for early access, contact Ziqme support at https://ziqme.com/contact. The Microsoft.AspNetCore.Authentication.JwtBearer setup above needs no Ziqme package.
builder.Services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddAuthSdkBearer(options =>
{
options.Issuer = "https://auth.ziqme.com";
options.ClientId = "app_your_client_id";
});Sign people in to a server-rendered app
Register a confidential application and use the OpenID Connect handler with the code flow and PKCE.
builder.Services
.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(options =>
{
options.Authority = "https://auth.ziqme.com";
options.ClientId = "app_your_client_id";
options.ClientSecret = builder.Configuration["Auth:ClientSecret"];
options.ResponseType = "code";
options.UsePkce = true;
options.Scope.Add("roles");
options.MapInboundClaims = false;
options.TokenValidationParameters.RoleClaimType = "roles";
});Keep the client secret in your secret store. It is shown once when the application is registered and again only when you rotate it.