-
-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[auth][photos] Support for passkey (#435)
<!-- Thanks for contributing! Provide a description of your changes below and a general summary in the title Please look at the following checklist to ensure that your PR can be accepted quickly: --> ## Description Passkey implementation (similar will be done in ente Photos) <!--- Describe your changes in detail --> ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [ ] 🖼️ New icon - [x] ✨ New feature (non-breaking change which adds functionality) - [ ] 🛠️ Bug fix (non-breaking change which fixes an issue) - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🧹 Code refactor - [ ] ✅ Build configuration change - [ ] 📝 Documentation - [ ] 🗑️ Chore
- Loading branch information
Showing
23 changed files
with
585 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:ente_auth/core/configuration.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
|
||
class FeatureFlagService { | ||
FeatureFlagService._privateConstructor(); | ||
static final FeatureFlagService instance = | ||
FeatureFlagService._privateConstructor(); | ||
|
||
static final _internalUserIDs = const String.fromEnvironment( | ||
"internal_user_ids", | ||
defaultValue: "1,2,3,4,191,125,1580559962388044,1580559962392434,10000025", | ||
).split(",").map((element) { | ||
return int.parse(element); | ||
}).toSet(); | ||
|
||
bool isInternalUserOrDebugBuild() { | ||
final String? email = Configuration.instance.getEmail(); | ||
final userID = Configuration.instance.getUserID(); | ||
return (email != null && email.endsWith("@ente.io")) || | ||
_internalUserIDs.contains(userID) || | ||
kDebugMode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:ente_auth/core/network.dart'; | ||
import 'package:ente_auth/utils/dialog_util.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:logging/logging.dart'; | ||
import 'package:url_launcher/url_launcher_string.dart'; | ||
|
||
class PasskeyService { | ||
PasskeyService._privateConstructor(); | ||
static final PasskeyService instance = PasskeyService._privateConstructor(); | ||
|
||
final _enteDio = Network.instance.enteDio; | ||
|
||
Future<String> getJwtToken() async { | ||
final response = await _enteDio.get( | ||
"/users/accounts-token", | ||
); | ||
return response.data!["accountsToken"] as String; | ||
} | ||
|
||
Future<void> openPasskeyPage(BuildContext context) async { | ||
try { | ||
final jwtToken = await getJwtToken(); | ||
final url = "https://accounts.ente.io/account-handoff?token=$jwtToken"; | ||
await launchUrlString( | ||
url, | ||
mode: LaunchMode.externalApplication, | ||
); | ||
} catch (e) { | ||
Logger('PasskeyService').severe("failed to open passkey page", e); | ||
showGenericErrorDialog(context: context).ignore(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.