Skip to content

Commit

Permalink
sample: Make apps use the same keystore dev-1950
Browse files Browse the repository at this point in the history
  • Loading branch information
roxk committed Sep 3, 2024
1 parent 4ea7881 commit 88c15be
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 14 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Prerequisute

### Flutter Sample App

- flutter 3.10.0

### Xamarin Sample App

- .NET 5+
- Xamarin Workload in Visual Studio

## Note On Credential

This sample app isn't meant to be relased or used so no attempt is made to secure the keystore.
2 changes: 1 addition & 1 deletion XamarinFormSample/Sample.Shared/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MainViewModel : INotifyPropertyChanged
public delegate void ErrorRaisedHandler(object sender, Exception e);
private AuthgearSdk authgear;
private readonly IAuthgearFactory authgearFactory;
public readonly string RedirectUri = "com.authgear.exampleapp.xamarin://host/path";
public readonly string RedirectUri = "com.authgear.migrate.tool.xamarin.flutter.sample://host/path";
public string ClientId { get; set; } =
Preferences.Get("authgear.clientID", Config.AuthgearClientId);
public string AuthgearEndpoint { get; set; } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace XamarinFormSample.Droid
{
[Activity(Label = "Authgear SDK XamarinFormSample", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
[Activity(Label = "Authgear Migrate Tool XamarinToFlutter Xamarin", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.authgear.exampleapp.xamarin" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.authgear.migrate.tool.xamarin.flutter.sample" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
<application android:label="Authgear Xamarin" android:theme="@style/MainTheme" android:usesCleartextTraffic="true"></application>
<application android:label="Authgear Migrate Tool XamarinToFlutter Xamarin" android:theme="@style/MainTheme" android:usesCleartextTraffic="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<queries>
<intent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace XamarinFormSample.Droid
[Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTop, Exported = true)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable },
DataScheme = "com.authgear.exampleapp.xamarin")]
DataScheme = "com.authgear.migrate.tool.xamarin.flutter.sample")]
public class WebAuthenticationCallbackActivity : Xamarin.Essentials.WebAuthenticatorCallbackActivity
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
<MandroidI18n />
<AndroidKeyStore>true</AndroidKeyStore>
<AndroidSigningKeyStore>D:\work\authgear-tool-migrate-xamarin-flutter\keystore-main.jks</AndroidSigningKeyStore>
<AndroidSigningStorePass>Abcd1234!</AndroidSigningStorePass>
<AndroidSigningKeyAlias>main</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>Abcd1234!</AndroidSigningKeyPass>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -47,6 +52,11 @@
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidKeyStore>true</AndroidKeyStore>
<AndroidSigningKeyStore>D:\work\authgear-tool-migrate-xamarin-flutter\keystore-main.jks</AndroidSigningKeyStore>
<AndroidSigningStorePass>Abcd1234!</AndroidSigningStorePass>
<AndroidSigningKeyAlias>main</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>Abcd1234!</AndroidSigningKeyPass>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<SelectedDevice>Google Pixel 7a</SelectedDevice>
<SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
<ActiveDebugProfile>Google Pixel 7a %28Android 14.0 - API 34%29</ActiveDebugProfile>
<DefaultDevice>Windows Subsystem for Android</DefaultDevice>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion XamarinFormSample/XamarinFormSample.iOS/Entitlements.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>keychain-access-groups</key>
<array>
<string>com.authgear.exampleapp.xamarin</string>
<string>com.authgear.migrate.tool.xamarin.flutter.sample</string>
</array>
</dict>
</plist>
4 changes: 2 additions & 2 deletions XamarinFormSample/XamarinFormSample.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.authgear.exampleapp.xamarin://host/path</string>
<string>com.authgear.migrate.tool.xamarin.flutter.sample://host/path</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.authgear.exampleapp.xamarin</string>
<string>com.authgear.migrate.tool.xamarin.flutter.sample</string>
</array>
</dict>
</array>
Expand Down
19 changes: 14 additions & 5 deletions flutter-example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.authgear.exampleapp.flutter"
applicationId "com.authgear.migrate.tool.xamarin.flutter.sample"
// minSdkVersion flutter.minSdkVersion
// 21 is required to use androidx.security
minSdkVersion 21
Expand All @@ -53,11 +53,20 @@ android {
}

signingConfigs {
def file = rootProject.file("keystore-main.properties")
def props = new Properties()
props.load(new FileInputStream(file))
debug {
storeFile new File(file.parent, props['storeFile'])
keyAlias props['keyAlias']
storePassword props['storePassword']
keyPassword props['keyPassword']
}
release {
storeFile file("keystore.jks")
storePassword project.ext.has("STORE_PASSWORD") ? project.ext["STORE_PASSWORD"] : ""
keyAlias project.ext.has("KEY_ALIAS") ? project.ext["KEY_ALIAS"] : ""
keyPassword project.ext.has("KEY_PASSWORD") ? project.ext["KEY_PASSWORD"] : ""
storeFile new File(file.parent, props['storeFile'])
keyAlias props['keyAlias']
storePassword props['storePassword']
keyPassword props['keyPassword']
}
}

Expand Down
2 changes: 1 addition & 1 deletion flutter-example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:allowBackup="true"
android:fullBackupContent="@xml/full_backup_content"
android:dataExtractionRules="@xml/data_extraction_rules"
android:label="Authgear Flutter"
android:label="Authgear Migrate Tool XamarinToFlutter Flutter"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
Expand Down
4 changes: 4 additions & 0 deletions flutter-example/android/keystore-main.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
storeFile=../../keystore-main.jks
keyAlias=main
storePassword=Abcd1234!
keyPassword=Abcd1234!
Binary file added keystore-main.jks
Binary file not shown.

0 comments on commit 88c15be

Please sign in to comment.