Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔖 v0..4.0 #16

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0
* Add package screenshots.
* Rename domain variable into frontendUrl to avoid confusion.

## 0.3.3
* Automate publishing workflow.

Expand Down
2 changes: 1 addition & 1 deletion example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LoginScreen extends StatelessWidget {
final config = KeycloakConfig(
bundleIdentifier: '<bundle_identifier>',
clientId: '<client_id>',
domain: '<domain>',
frontendUrl: '<frontend_url>',
realm: '<realm>');

// Check if user has successfully logged in.
Expand Down
26 changes: 11 additions & 15 deletions lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ class KeycloakConfig {
static final KeycloakConfig instance = KeycloakConfig._();

/// Initializes the configuration settings such as
/// [bundleIdentifier], [clientId], [domain], and [realm]. These settings
/// [bundleIdentifier], [clientId], [frontendUrl], and [realm]. These settings
/// are essential for interacting with the Keycloak server during the
/// authentication process.
factory KeycloakConfig(
{required String bundleIdentifier,
required String clientId,
required String domain,
required String frontendUrl,
required String realm}) =>
instance
..bundleIdentifier = bundleIdentifier
..clientId = clientId
..domain = domain
..frontendUrl = frontendUrl
..realm = realm;

String? _bundleIdentifier;

String? _clientId;

String? _domain;
String? _frontendUrl;

String? _realm;

Expand All @@ -34,40 +34,36 @@ class KeycloakConfig {
/// The alphanumeric ID string that is used in OIDC requests and in the Keycloak database to identify the client.
String get clientId => _clientId ?? '';

/// The client domain name, host or IP address.
String get domain => _domain ?? '';
/// The fixed base URL for frontend requests.
String get frontendUrl => _frontendUrl ?? '';

/// The realm name.
String get realm => _realm ?? '';

/// The base URI for the authorization server.
String get issuer => '$domain/realms/$realm';
String get issuer => '$frontendUrl/realms/$realm';

/// The callback URI after the user has been successfully authorized and granted an access token.
String get redirectUri => '$_bundleIdentifier://login-callback';

/// The application unique identifier.
set bundleIdentifier(String? value) {
if (value == null) return;
_bundleIdentifier = value;
_secureStorage.write(key: _bundleIdentifierKey, value: value);
}

/// The alphanumeric ID string that is used in OIDC requests and in the Keycloak database to identify the client.
set clientId(String? value) {
if (value == null) return;
_clientId = value;
_secureStorage.write(key: _clientIdKey, value: value);
}

/// The client domain name, host or IP address.
set domain(String? value) {
set frontendUrl(String? value) {
if (value == null) return;
_domain = value;
_secureStorage.write(key: _domainKey, value: value);
_frontendUrl = value;
_secureStorage.write(key: _frontendUrlKey, value: value);
}

/// The realm name.
set realm(String? value) {
if (value == null) return;
_realm = value;
Expand All @@ -78,7 +74,7 @@ class KeycloakConfig {
Future<void> initialize() async {
bundleIdentifier = await _secureStorage.read(key: _bundleIdentifierKey);
clientId = await _secureStorage.read(key: _clientIdKey);
domain = await _secureStorage.read(key: _domainKey);
frontendUrl = await _secureStorage.read(key: _frontendUrlKey);
realm = await _secureStorage.read(key: _realmKey);
}
}
2 changes: 1 addition & 1 deletion lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const _secureStorage = FlutterSecureStorage();

const _bundleIdentifierKey = 'keycloak-bundle-identifier';
const _clientIdKey = 'keycloak-client-id';
const _domainKey = 'keycloak-domain';
const _frontendUrlKey = 'keycloak-frontendUrl';
const _realmKey = 'keycloak-realm';
const _refreshTokenKey = 'keycloak-refresh-token';
3 changes: 2 additions & 1 deletion lib/src/wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class KeycloakWrapper {
final request = EndSessionRequest(
idTokenHint: idToken,
issuer: KeycloakConfig.instance.issuer,
postLogoutRedirectUrl: KeycloakConfig.instance.redirectUri);
postLogoutRedirectUrl: KeycloakConfig.instance.redirectUri,
allowInsecureConnections: true);

await _appAuth.endSession(request);
await _secureStorage.deleteAll();
Expand Down
6 changes: 4 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: keycloak_wrapper
description: Keycloak Single Sign-On (SSO) authentication package for Flutter framework.
version: 0.3.3
version: 0.4.0
repository: https://github.com/fa-fifi/keycloak-wrapper
issue_tracker: https://github.com/fa-fifi/keycloak-wrapper/issues
topics: [authentication, keycloak, oauth2, openidconnect]
screenshots:
- description: 'Login screen with the default Keycloak theme.'
path: screenshots/login-screen.png

environment:
sdk: '>=3.1.2 <4.0.0'
Expand Down
Binary file added screenshots/login-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.