Skip to content

Authentication

The AlertHawk.Authentication service handles user identity and access for the AlertHawk platform: user sign-in (e.g. Microsoft Account), JWT and Azure AD token issuance/validation, and integration with other AlertHawk services.

All API routes are prefixed with /auth (e.g. /auth/api/User/GetAll).


Environment Variables

These variables are used when running the Authentication service (e.g. via Helm chart under auth.env). Configuration can be set in appsettings.json or via environment variables (double underscore __ in Helm for nested keys).

General

VariableDescriptionExample / Notes
ASPNETCORE_ENVIRONMENTRuntime environmentDevelopment, Production
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT.NET globalizationfalse recommended
basePathBase path for Swagger (dev)Optional, e.g. /auth

Database

VariableDescription
ConnectionStrings__SqlConnectionStringSQL Server connection string for user and auth data

Azure AD (Microsoft Identity)

VariableDescription
AzureAd__ClientIdAzure AD application (client) ID
AzureAd__TenantIdAzure AD tenant ID
AzureAd__ClientSecretAzure AD client secret
AzureAd__InstanceAzure AD instance URL (e.g. https://login.microsoftonline.com/)
AzureAd__CallbackPathOIDC callback path

Downstream API (Microsoft Graph)

VariableDescription
DownstreamApi__BaseUrlMicrosoft Graph base URL
DownstreamApi__ScopesScopes to request

JWT (token generation and validation)

VariableDescription
Jwt__KeySecret key used to sign/validate JWT tokens
Jwt__IssuersComma-separated list of valid issuers
Jwt__AudiencesComma-separated list of valid audiences

Mobile / API key

VariableDescription
MOBILE_API_KEYAPI key required for mobile Azure auth (POST /auth/api/Auth/azure)

SMTP (password reset / email)

VariableDescription
smtpHostSMTP server host
smtpPortSMTP port (e.g. 587)
smtpUsernameSMTP username
smtpPasswordSMTP password
smtpFromFrom address for outgoing email
enableSslUse SSL for SMTP

Swagger UI (development)

VariableDescription
SwaggerUICredentials__usernameBasic auth username for Swagger UI
SwaggerUICredentials__passwordBasic auth password for Swagger UI

Caching

VariableDescription
CacheSettings__CacheProviderCache implementation

Sentry

VariableDescription
Sentry__EnabledEnable Sentry error reporting
Sentry__DsnSentry DSN URL
Sentry__EnvironmentEnvironment name sent to Sentry

Logging

VariableDescription
Logging__LogLevel__DefaultDefault log level
Logging__LogLevel__Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapterIdentity logger level

Feature flags / behavior

VariableDescriptionDefault
ENABLED_LOGIN_AUTHEnable username/password login and related endpointstrue; set to false to disable login, create, reset password, update password
DEMO_MODEWhen true, new users from Azure mobile auth get a default monitor group (e.g. group 24)false
BLOCKED_DOMAINSComma-separated email domains; users whose UPN/email ends with @<domain> get 403Optional

API Controllers

All controllers live under the base path /auth/api. Authentication uses JWT Bearer or Azure AD; most endpoints require authorization unless marked otherwise.

Auth — POST /auth/api/Auth/*

MethodRouteAuthDescription
POST/auth/api/Auth/azureNoneGet JWT for mobile app; body: { "email", "apiKey" }; apiKey must match MOBILE_API_KEY. Creates user if not exists.
POST/auth/api/Auth/refreshTokenBearerRefresh JWT using current token.
POST/auth/api/Auth/loginNoneUsername/password login; returns JWT. Disabled when ENABLED_LOGIN_AUTH=false.

User — POST|GET|PUT|DELETE /auth/api/User/*

MethodRouteAuthDescription
POST/auth/api/User/createNoneCreate user (email/password). Disabled when ENABLED_LOGIN_AUTH=false.
DELETE/auth/api/User/delete/{userId}AdminDelete user by ID.
DELETE/auth/api/User/deleteBearerDelete current user (by token).
PUT/auth/api/User/updateAdminUpdate user.
POST/auth/api/User/resetPassword/{email}NoneSend password reset email. Disabled when ENABLED_LOGIN_AUTH=false.
POST/auth/api/User/updatePasswordBearerChange password (current + new). Disabled when ENABLED_LOGIN_AUTH=false.
GET/auth/api/User/GetAllAdminGet all users.
GET/auth/api/User/GetAllByGroupId/{groupId}BearerGet users by group ID.
GET/auth/api/User/GetById/{userId}BearerGet user by ID.
GET/auth/api/User/GetByEmail/{userEmail}BearerGet user by email.
GET/auth/api/User/GetByUserName/{userName}BearerGet user by username.
GET/auth/api/User/{email}BearerGet user by email; creates from Azure AD if not exists.
GET/auth/api/User/GetUserCountBearerGet total user count.
GET/auth/api/User/GetUserDetailsByTokenBearerGet current user from token.
POST/auth/api/User/UpdateUserDeviceTokenBearerUpdate device token for push. Body: { "deviceToken" }.
GET/auth/api/User/GetUserDeviceTokenListBearerGet device tokens for current user.
GET/auth/api/User/GetUserDeviceTokenListByUserId/{userId}BearerGet device tokens by user ID.
GET/auth/api/User/GetUserDeviceTokenListByGroupId/{groupId}NoneGet device tokens by group ID.

UserAction — POST|GET /auth/api/UserAction/*

MethodRouteAuthDescription
POST/auth/api/UserAction/createBearerCreate user action (body: action payload); userId set from token.
GET/auth/api/UserActionBearerGet list of user actions.

UserClusters — POST|GET /auth/api/UserClusters/*

MethodRouteAuthDescription
POST/auth/api/UserClustersAdminAdd a cluster to a user.
POST/auth/api/UserClusters/CreateOrUpdateAdminAdd or update multiple clusters; body: { "userId", "clusters": [] }. Empty list removes all.
GET/auth/api/UserClusters/GetAllByUserId/{userId}BearerGet clusters by user ID (own user or admin).

UsersMonitorGroup — POST|GET|DELETE /auth/api/UsersMonitorGroup/*

MethodRouteAuthDescription
POST/auth/api/UsersMonitorGroup/AssignUserToGroupBearerAssign current user to a monitor group.
POST/auth/api/UsersMonitorGroup/createAdminAssign users to groups (list).
GET/auth/api/UsersMonitorGroup/GetAllBearerGet all monitor group IDs for current user.
GET/auth/api/UsersMonitorGroup/GetAllByUserId/{userId}AdminGet monitor groups by user ID.
DELETE/auth/api/UsersMonitorGroup/{groupMonitorId}AdminDelete all user-group relationships for a group.

Version — GET /auth/api/Version

MethodRouteAuthDescription
GET/auth/api/VersionNoneReturn API version string.

Helm chart reference

In the AlertHawk Helm chart, Authentication is configured under the auth section. Example from values.yaml:

yaml
auth:
  replicas: 1
  env:
    ASPNETCORE_ENVIRONMENT: Development
    ConnectionStrings__SqlConnectionString: your-connection-string
    Sentry__Enabled: false
    Sentry__Dsn: sentry-dsn-url
    Sentry__Environment: Local
    SwaggerUICredentials__username: admin
    SwaggerUICredentials__password: admin
    CacheSettings__CacheProvider: MemoryCache
    AzureAd__ClientId: clientid
    AzureAd__TenantId: tenantid
    AzureAd__ClientSecret: secret
    AzureAd__Instance: instance
    AzureAd__CallbackPath: /signin-oidc
    DownstreamApi__BaseUrl: https://graph.microsoft.com/beta
    DownstreamApi__Scopes: User.Read
    smtpHost: smtp-host
    smtpPort: smtp-port
    smtpUsername: smtp-user
    smtpPassword: smtp-pass
    smtpFrom: smtp-from
    enableSsl: true
    Jwt__Key: jwt-key
    Jwt__Issuers: issuers
    Jwt__Audiences: audiences
    Logging__LogLevel__Default: Warning
    Logging__LogLevel__Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter: Critical
    DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: false
    MOBILE_API_KEY: your_auth_api_key

Adjust values (especially secrets and connection strings) for your environment.

AlertHawk - Self-hosted monitoring solution.