Skip to content

Commit

Permalink
Merge pull request #358 from verdigado/187-keycloak
Browse files Browse the repository at this point in the history
187: Fix keycloak for testing
  • Loading branch information
steffenkleinle authored Nov 28, 2024
2 parents a6da023 + ba41b56 commit 7451776
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ commands:
command: fvm dart run slang
name: Generate Translations
- run:
command: cp .env.example .env
name: Apply Example Environment
command: cp .env.prod .env
name: Apply Production Environment
prepare_workspace:
description: Attach the workspace at ~/attached_workspace and list its contents
steps:
Expand Down
5 changes: 2 additions & 3 deletions .circleci/src/commands/prepare_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ steps:
name: Generate Translations
command: fvm dart run slang
- run:
name: Apply Example Environment
# TODO Supply correct env
command: cp .env.example .env
name: Apply Production Environment
command: cp .env.prod .env
3 changes: 3 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OIDC_CLIENT_ID=gruene_app
OIDC_ISSUER=https://saml.gruene.de/realms/gruene-app-test
USE_LOGIN=true
5 changes: 0 additions & 5 deletions .env.example

This file was deleted.

3 changes: 3 additions & 0 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OIDC_CLIENT_ID=gruene_app
OIDC_ISSUER=https://saml.gruene.de/realms/gruene-app-test
USE_LOGIN=true
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ write good commit messages.
The application uses the following environment variables:

- `USE_LOGIN`: If set to `true`, the application will use the OIDC login. This variable is only a temporary solution to allow starting the app without IDP with secure connection. It will be removed later.
- `APP_ID`: The ID of the app.
- `OIDC_CALLBACK_PATH`: The path to the OIDC callback.
- `OIDC_CLIENT_ID`: The client ID of the OIDC client.
- `OIDC_ISSUER`: The issuer url of the identity provider.

You can copy the `.env.example` file to `.env` and fill in the values.
You can copy the `.env.dev` file to `.env` and fill in the values.
Please note that it's not possible to use the OIDC login if issuer url does not have a secure connection.

5 changes: 2 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

android {
namespace = "com.example.gruene_app"
namespace = "de.gruene.wkapp"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

Expand All @@ -20,8 +20,7 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.gruene_app"
applicationId = "de.gruene.wkapp"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion

Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.example.grueneapp" android:host="oauthredirect" />
<data android:scheme="de.gruene.wkapp" android:host="oauthredirect" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.gruene_app
package de.gruene.wkapp

import io.flutter.embedding.android.FlutterActivity

Expand Down
3 changes: 1 addition & 2 deletions android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

# TODO Fix application id
APPLICATION_ID = 'com.example.gruene_app'
APPLICATION_ID = 'de.gruene.wkapp'

CREDENTIALS_GIT_REPOSITORY_URL = ENV['CREDENTIALS_GIT_REPOSITORY_URL']
CREDENTIALS_DIRECTORY_PATH = ENV['CREDENTIALS_DIRECTORY_PATH']
Expand Down
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.grueneApp;
PRODUCT_BUNDLE_IDENTIFIER = de.gruene.wkapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand All @@ -384,7 +384,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.grueneApp.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = de.gruene.wkapp.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -401,7 +401,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.grueneApp.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = de.gruene.wkapp.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand All @@ -416,7 +416,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.grueneApp.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = de.gruene.wkapp.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand Down Expand Up @@ -547,7 +547,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.grueneApp;
PRODUCT_BUNDLE_IDENTIFIER = de.gruene.wkapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -569,7 +569,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.grueneApp;
PRODUCT_BUNDLE_IDENTIFIER = de.gruene.wkapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.example.grueneapp://oauthredirect</string>
<string>de.gruene.wkapp://oauthredirect</string>
</array>
</dict>
</array>
Expand Down
6 changes: 3 additions & 3 deletions lib/app/auth/repository/auth_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthRepository {
final AuthorizationTokenResponse result = await _appAuth.authorizeAndExchangeCode(
AuthorizationTokenRequest(
Config.oidcClientId,
'${Config.appId}://${Config.oidcCallbackPath}',
Config.oidcCallbackPath,
issuer: Config.oidcIssuer,
scopes: ['openid', 'profile', 'email'],
),
Expand All @@ -38,7 +38,7 @@ class AuthRepository {

Future<void> signOut() async {
final idToken = await _secureStorage.read(key: SecureStorageKeys.idToken);
final postLogoutRedirectUrl = '${Config.appId}://${Config.oidcCallbackPath}';
final postLogoutRedirectUrl = Config.oidcCallbackPath;
final endSessionUrl =
'${Config.oidcIssuer}/protocol/openid-connect/logout?id_token_hint=$idToken&post_logout_redirect_uri=$postLogoutRedirectUrl';

Expand Down Expand Up @@ -79,7 +79,7 @@ class AuthRepository {
final TokenResponse result = await _appAuth.token(
TokenRequest(
Config.oidcClientId,
'${Config.appId}://${Config.oidcCallbackPath}',
Config.oidcCallbackPath,
refreshToken: refreshToken,
issuer: Config.oidcIssuer,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/app/constants/config.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';

class Config {
static String get appId => dotenv.env['APP_ID'] ?? '';
static String get oidcCallbackPath => dotenv.env['OIDC_CALLBACK_PATH'] ?? '';
static String get appId => 'de.gruene.wkapp';
static String get oidcCallbackPath => '${Config.appId}://oauthredirect';
static String get oidcClientId => dotenv.env['OIDC_CLIENT_ID'] ?? '';
static String get oidcIssuer => dotenv.env['OIDC_ISSUER'] ?? '';
static bool get useLogin => dotenv.env['USE_LOGIN'] == 'true';
Expand Down

0 comments on commit 7451776

Please sign in to comment.