This project demonstrates the integration of a Flutter application with Keycloak for authentication and identity management.
- OAuth2/OpenID Connect authentication with Keycloak
- Login with PKCE (Proof Key for Code Exchange)
- JWT token management
- User information display
- Logout with token revocation
- Flutter SDK
- Docker and Docker Compose
- Git
Keycloak is configured via Docker Compose. Before starting, adjust the IP in the docker-compose.yml
file:
KC_HOSTNAME: 192.168.50.3 # Change to your machine's IP
To start Keycloak:
docker-compose up -d
After starting, access the admin console:
- URL: http://YOUR_IP:8080
- Username: admin
- Password: admin
Note: The
mobile
client is already configured through therealm-export.json
file, which is automatically imported during Keycloak initialization.
In the lib/auth_service.dart
file, verify that the IP is correct:
final String keycloakUrl = 'http://192.168.50.3:8080'; # Change to the same IP configured in docker-compose
final String realm = 'master'; # Using the master realm
- Clone the repository and checkout the correct branch:
git clone [REPOSITORY_URL]
git checkout [BRANCH_NAME]
- Install dependencies:
flutter pub get
- Run the application:
flutter run
- The app uses PKCE for secure authentication
- Tokens are securely stored using
flutter_secure_storage
- Communication with Keycloak is done via HTTPS (recommended for production)
- Keycloak database is configured as
dev-mem
(in-memory) - Data will be lost when restarting the Keycloak container
- For production, consider using a persistent database (PostgreSQL)
- The configured IP must be accessible by both the app and browser
- This project uses Keycloak's
master
realm - The
mobile
client is automatically imported from therealm-export.json
file
Feel free to open issues or submit pull requests with improvements.
This project is licensed under the MIT License.