Skip to content

Commit 5172e91

Browse files
authored
feat: flutter SDK updates (#54)
1 parent 5ae53c6 commit 5172e91

15 files changed

+321
-250
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,21 @@ iOS, Android
3232
- bump the http dependency to the latest version
3333
- bump the flutter_web_auth dependency to the latest version
3434
- bump the flutter_secure_storage dependency to the latest version
35+
36+
## 1.2.0
37+
38+
### Dependencies update
39+
40+
- bump http package dependency to 1.2.0
41+
- bump flutter_secure_storage package dependency to 9.0.0
42+
- bump flutter_lints package dependency to 3.0.x
43+
44+
### Features
45+
46+
- Update `LogtoConfig` to support new organization feature, including new organization scopes and fetching organization token
47+
- Add `LogtoClient.getOrganizationToken` method to support organization token retrieval
48+
49+
### Refactor
50+
51+
- Export all the necessary classes and interfaces from `logto_core` to `logto_client` package
52+
- Update the example app to demonstrate the new organization feature

README.md

Lines changed: 8 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -12,163 +12,17 @@
1212

1313
Logto's flutter SDK for native apps.
1414

15-
## Installation
15+
[pub.dev](https://pub.dev/packages/logto_dart_sdk)
1616

17-
```sh
18-
flutter pub get logto_dart_sdk
19-
```
17+
## Packages
2018

21-
## Products
19+
- logto_core: Core SDK is used for generation dart project with basic API and util method provided.
20+
- logto_client: Client SDK for flutter native apps. Built based on logto_core with user sign-in interaction flow integrated
2221

23-
| Name | Description |
24-
| ------------ | ----------------------------------------------------------------------------------------------------------- |
25-
| logto_core | Core SDK is used for generation dart project with basic API and util method provided. |
26-
| logto_client | Client SDK for flutter native apps. Built based on logto_core with user sign-in interaction flow integrated |
22+
## Platforms
2723

28-
## Logto Client
24+
iOS, Android
2925

30-
### Configurations
26+
## Integration Guide
3127

32-
#### flutter_secure_storage
33-
34-
We use [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage) to implement the cross-platform persistent auth_token secure storage.
35-
36-
- Keychain is used for iOS
37-
- AES encryption is used for Android.
38-
39-
Configure Android version:
40-
41-
In [project]/android/app/build.gradle set minSdkVersion to >= 18.
42-
43-
```gradle
44-
android {
45-
...
46-
47-
defaultConfig {
48-
...
49-
minSdkVersion 18
50-
...
51-
}
52-
}
53-
54-
```
55-
56-
> Note By default Android backups data on Google Drive. It can cause exception java.security.InvalidKeyException:Failed to unwrap key. You need to:
57-
>
58-
> - disable autobackup,
59-
> - exclude sharedprefs FlutterSecureStorage used by the plugin
60-
61-
1. To disable autobackup, go to your app manifest file and set the boolean value android:allowBackup.
62-
63-
```xml
64-
<manifest ... >
65-
...
66-
<application
67-
android:allowBackup="false"
68-
android:fullBackupContent="false">
69-
...
70-
>
71-
...
72-
</application>
73-
</manifest>
74-
```
75-
76-
2. Exclude sharedprefs FlutterSecureStorage.
77-
78-
If you need to enable the android:fullBackupContent for your app. Set up a backup rule to [exclude](https://developer.android.com/guide/topics/data/autobackup#IncludingFiles) the prefs used by the plugin.
79-
80-
```xml
81-
<application ...
82-
android:fullBackupContent="@xml/backup_rules">
83-
</application>
84-
```
85-
86-
```xml
87-
<?xml version="1.0" encoding="utf-8"?>
88-
<full-backup-content>
89-
<exclude domain="sharedpref" path="FlutterSecureStorage"/>
90-
</full-backup-content>
91-
```
92-
93-
Please check [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage#configure-android-version) for more details.
94-
95-
#### flutter_web_auth
96-
97-
[flutter_web_auth](https://pub.dev/packages/flutter_appauth) is used behind Logto's flutter SDK. We rely on its webview-based interaction interface to open Logto's authorization pages.
98-
99-
> In the background, this plugin uses ASWebAuthenticationSession on iOS 12+ and macOS 10.15+, SFAuthenticationSession on iOS 11, Chrome Custom Tabs on Android and opens a new window on Web. You can build it with iOS 8+, but it is currently only supported by iOS 11 or higher.
100-
101-
Android
102-
103-
In order to capture the callback url from Logto's sign-in web page, you will need to register your sign-in redirectUri to the `AndroidManifest.xml`.
104-
105-
```xml
106-
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" android:exported="true">
107-
<intent-filter android:label="flutter_web_auth">
108-
<action android:name="android.intent.action.VIEW"/>
109-
<category android:name="android.intent.category.DEFAULT"/>
110-
<category android:name="android.intent.category.BROWSABLE"/>
111-
<data android:scheme="io.logto"/>
112-
</intent-filter>
113-
</activity>
114-
```
115-
116-
By doing so, your app will automatically capture the callbaclUri after a successful sign-in and redirect the user back to the app.
117-
118-
### Basic Usage
119-
120-
```dart
121-
import 'package:logto_dart_sdk/logto_dart_sdk.dart';
122-
123-
// ...
124-
late LogtoClient logtoClient;
125-
126-
void _init() async {
127-
logtoClient = LogtoClient(
128-
config: config, // LogtoConfig
129-
httpClient: http.Client(), // Optional http client
130-
);
131-
}
132-
133-
void signIn() async {
134-
await logtoClient.signIn(redirectUri);
135-
}
136-
137-
void signOut() async {
138-
await logtoClient.signOut();
139-
}
140-
141-
```
142-
143-
### Class LogtoConfig
144-
145-
#### Properties
146-
147-
| name | type | description |
148-
| --------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
149-
| appId | String | Your appId generate from Logto's admin console |
150-
| appSecret | String? | App Secret generated along with the appId. Optional for native apps. |
151-
| endpoint | String | Your logto server endpoint. e.g. https://logto.dev |
152-
| scopes | List&#60;String&#62;? | List all the permission scopes your app will request for. You may define and find it through Logto's admin console. |
153-
| resources | List&#60;String&#62;? | List all the [resource indicators](https://docs.logto.io/docs/references/resources/) you app may request for access. You may define and find it through Logto's admin console. |
154-
155-
### Class LogtoClient
156-
157-
#### Properties
158-
159-
| name | type | description |
160-
| --------------- | --------------------------------------- | ----------------------------------------------- |
161-
| config | final LogtoConfig | Logto Config used to init Logto Client |
162-
| idToken | read-only Future&#60;String?&#62; | idToken returned after success authentication |
163-
| isAuthenticated | read-only Future&#60;bool&#62; | Is Authenticated status |
164-
| idTokenClaims | read-only Future&#60;OpenIdClaims?&#62; | Decoded idToken claims including basic userinfo |
165-
| loading | read-only bool | Global API loading status |
166-
167-
#### Methods
168-
169-
| name | type | description |
170-
| -------------- | --------------------------------------------------- | ------------------------------------------------------------------- |
171-
| getAccessToken | ({String? resource}) -> Future&#60;AccessToken&#62; | Request for an api resource specific access token for authorization |
172-
| signIn | (String? redirectUri) -> Future&#60;void&#62; | Init user sign-in flow |
173-
| signOut | () -> Future&#60;void&#62; | Sign-out |
174-
| getUserInfo | () => Future&#60;UserInfo&#62; | Get user info |
28+
[Flutter SDK tutorial](https://docs.logto.io/sdk/flutter/)

analysis_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ include: package:flutter_lints/flutter.yaml
22

33
# Additional information about this file can be found at
44
# https://dart.dev/guides/language/analysis-options
5+
6+
linter:
7+
rules:
8+
slash_for_doc_comments: false

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>11.0</string>
24+
<string>12.0</string>
2525
</dict>
2626
</plist>

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '11.0'
2+
# platform :ios, '12.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
344344
GCC_WARN_UNUSED_FUNCTION = YES;
345345
GCC_WARN_UNUSED_VARIABLE = YES;
346-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
346+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
347347
MTL_ENABLE_DEBUG_INFO = NO;
348348
SDKROOT = iphoneos;
349349
SUPPORTED_PLATFORMS = iphoneos;
@@ -421,7 +421,7 @@
421421
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
422422
GCC_WARN_UNUSED_FUNCTION = YES;
423423
GCC_WARN_UNUSED_VARIABLE = YES;
424-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
424+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
425425
MTL_ENABLE_DEBUG_INFO = YES;
426426
ONLY_ACTIVE_ARCH = YES;
427427
SDKROOT = iphoneos;
@@ -470,7 +470,7 @@
470470
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
471471
GCC_WARN_UNUSED_FUNCTION = YES;
472472
GCC_WARN_UNUSED_VARIABLE = YES;
473-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
473+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
474474
MTL_ENABLE_DEBUG_INFO = NO;
475475
SDKROOT = iphoneos;
476476
SUPPORTED_PLATFORMS = iphoneos;

0 commit comments

Comments
 (0)