bapp_auth library
Authentication package for BAPP framework platforms.
Provides Keycloak SSO authentication, automatic token management, and a pre-configured BappApiClient for making authenticated API requests.
Quick Start
import 'package:bapp_auth/bapp_auth.dart';
// Configure for your platform
final auth = BappAuth(
config: BappAuthConfig(
clientId: 'my-flutter-app',
host: 'https://my-company.bapp.ro/api',
app: 'my-app',
),
);
// Initialize (restores saved session or attempts SSO)
await auth.initialize();
// Login if needed
if (!auth.isAuthenticated) {
await auth.loginWithSSO();
}
// Use the authenticated API client
final me = await auth.apiClient.me();
final items = await auth.apiClient.list('myapp.item');
Classes
- AuthenticatedHttpClient
- An HTTP client wrapper that transparently injects bearer tokens and handles automatic token refresh.
- AuthState
- Represents the current authentication state.
- BappApiClient
- API client for the BAPP platform.
- BappAuth
- Main authentication manager for BAPP framework platforms.
- BappAuthConfig
- Configuration for BappAuth.
- DeviceAuthorizationResponse
- Response from the OAuth2 device authorization endpoint.
- KeycloakAuth
- Keycloak OAuth2 authentication client.
-
PagedList<
T> - A list of results with pagination metadata.
- PlatformConfig
- Platform-specific configuration helper for OAuth redirect URLs.
- TokenResponse
- Represents an OAuth2 token response from the authorization server.
Enums
- AuthStatus
- Authentication status.
Typedefs
- OnAuthRequiredFn = void Function()
- Callback invoked when token refresh fails and re-authentication is needed.
-
TokenRefreshFn
= Future<
TokenResponse?> Function() - Callback that performs a token refresh and returns the new token.