diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ade9eb8ae..11ab57f2c 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -30,9 +30,9 @@ jobs: with: php-version: "8.1" tools: composer - - uses: subosito/flutter-action@v2.8.0 + - uses: subosito/flutter-action@v2.10.0 with: - flutter-version: "3.7.12" + flutter-version: "3.10.6" channel: "stable" - uses: actions/setup-python@v4 with: diff --git a/code-examples/protect-page-login/flutter_web_redirect/env b/code-examples/protect-page-login/flutter_web_redirect/env index 05000abc4..709adc1f6 100644 --- a/code-examples/protect-page-login/flutter_web_redirect/env +++ b/code-examples/protect-page-login/flutter_web_redirect/env @@ -1 +1 @@ -ORY_BASE_URL=http://localhost:3005 +ORY_BASE_URL=http://localhost:3005 \ No newline at end of file diff --git a/code-examples/protect-page-login/flutter_web_redirect/lib/main.dart b/code-examples/protect-page-login/flutter_web_redirect/lib/main.dart index 41e7a6397..02e75d611 100644 --- a/code-examples/protect-page-login/flutter_web_redirect/lib/main.dart +++ b/code-examples/protect-page-login/flutter_web_redirect/lib/main.dart @@ -1,9 +1,8 @@ // Copyright © 2022 Ory Corp // SPDX-License-Identifier: Apache-2.0 -import 'dart:html'; -import 'package:dio/adapter_browser.dart'; -import 'package:dio/browser_imp.dart'; +import 'package:universal_html/html.dart'; +import 'package:dio/browser.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -18,8 +17,8 @@ Future main() async { // create the dio client for http requests final options = BaseOptions( baseUrl: baseUrl, - connectTimeout: 10000, - receiveTimeout: 5000, + connectTimeout: const Duration(seconds: 10000), + receiveTimeout: const Duration(seconds: 5000), headers: { "Accept": "application/json", }, @@ -53,7 +52,8 @@ class MyApp extends StatelessWidget { final Dio dio; final AuthService auth; - const MyApp({Key? key, required this.dio, required this.auth}) : super(key: key); + const MyApp({Key? key, required this.dio, required this.auth}) + : super(key: key); // This widget is the root of your application. @override @@ -69,7 +69,8 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key, required this.title, required this.auth}) : super(key: key); + const MyHomePage({Key? key, required this.title, required this.auth}) + : super(key: key); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect @@ -89,7 +90,6 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - @override Widget build(BuildContext context) { // The Flutter framework has been optimized to make rerunning build methods @@ -122,7 +122,8 @@ class _MyHomePageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Session Information:${widget.auth.identity.toString()}'), - TextButton(onPressed: widget.auth.logout, child: const Text('Logout')), + TextButton( + onPressed: widget.auth.logout, child: const Text('Logout')), ], ), ), diff --git a/code-examples/protect-page-login/flutter_web_redirect/lib/services/auth.dart b/code-examples/protect-page-login/flutter_web_redirect/lib/services/auth.dart index fd963ea6f..36a00be84 100644 --- a/code-examples/protect-page-login/flutter_web_redirect/lib/services/auth.dart +++ b/code-examples/protect-page-login/flutter_web_redirect/lib/services/auth.dart @@ -1,6 +1,6 @@ // Copyright © 2022 Ory Corp // SPDX-License-Identifier: Apache-2.0 -import 'dart:html'; +import 'package:universal_html/html.dart'; import 'package:dio/dio.dart'; import 'package:ory_client/ory_client.dart'; @@ -9,18 +9,16 @@ class AuthService { final FrontendApi _ory; Session? _identity; - AuthService(Dio dio) : - _ory = OryClient(dio: dio).getFrontendApi(); + AuthService(Dio dio) : _ory = OryClient(dio: dio).getFrontendApi(); Future isAuthenticated() async { - return _ory.toSession().then((resp) { + return _ory.toSession().then((resp) { if (resp.statusCode == 200) { _identity = resp.data; return true; } return false; - }) - .catchError((error) { + }).catchError((error) { return false; }); } diff --git a/code-examples/protect-page-login/flutter_web_redirect/pubspec.lock b/code-examples/protect-page-login/flutter_web_redirect/pubspec.lock index e223e8d34..795360abc 100644 --- a/code-examples/protect-page-login/flutter_web_redirect/pubspec.lock +++ b/code-examples/protect-page-login/flutter_web_redirect/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -29,18 +29,26 @@ packages: dependency: transitive description: name: built_value - sha256: "2f17434bd5d52a26762043d6b43bb53b3acd029b4d9071a329f46d67ef297e6d" + sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166" url: "https://pub.dev" source: hosted - version: "8.5.0" + version: "8.6.1" characters: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" + source: hosted + version: "1.3.1" clock: dependency: transitive description: @@ -53,26 +61,34 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" + csslib: + dependency: transitive + description: + name: csslib + sha256: "831883fb353c8bdc1d71979e5b342c7d88acfbc643113c14ae51e2442ea0f20f" + url: "https://pub.dev" + source: hosted + version: "0.17.3" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - sha256: caac504f942f41dfadcf45229ce8c47065b93919a12739f20d6173a883c5ec73 + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.0.5" dio: dependency: "direct main" description: name: dio - sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8" + sha256: ce75a1b40947fea0a0e16ce73337122a86762e38b982e1ccb909daa3b9bc4197 url: "https://pub.dev" source: hosted - version: "4.0.6" + version: "5.3.2" fake_async: dependency: transitive description: @@ -98,23 +114,31 @@ packages: dependency: "direct main" description: name: flutter_dotenv - sha256: d9283d92059a22e9834bc0a31336658ffba77089fb6f3cc36751f1fc7c6661a3 + sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77" url: "https://pub.dev" source: hosted - version: "5.0.2" + version: "5.1.0" flutter_lints: dependency: "direct dev" description: name: flutter_lints - sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + html: + dependency: transitive + description: + name: html + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" + url: "https://pub.dev" + source: hosted + version: "0.15.4" http_parser: dependency: transitive description: @@ -127,26 +151,26 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" lints: dependency: transitive description: name: lints - sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.1" matcher: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -159,10 +183,10 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" one_of: dependency: transitive description: @@ -183,18 +207,18 @@ packages: dependency: "direct main" description: name: ory_client - sha256: d7273618796319c9782548d5f4b2f632b66ea1175f25216177420184e12a0cc8 + sha256: "6cee3dc3ff90527e9b7e9897546201842660a2f5cef90828d75973d114bcac7a" url: "https://pub.dev" source: hosted - version: "1.1.27" + version: "1.1.41" path: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" quiver: dependency: transitive description: @@ -252,18 +276,34 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" typed_data: dependency: transitive description: name: typed_data - sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" + universal_html: + dependency: "direct main" + description: + name: universal_html + sha256: a5cc5a84188e5d3e58f3ed77fe3dd4575dc1f68aa7c89e51b5b4105b9aab3b9d + url: "https://pub.dev" + source: hosted + version: "2.2.3" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" vector_math: dependency: transitive description: @@ -273,4 +313,4 @@ packages: source: hosted version: "2.1.4" sdks: - dart: ">=2.19.0 <3.0.0" + dart: ">=3.0.6 <4.0.0" diff --git a/code-examples/protect-page-login/flutter_web_redirect/pubspec.yaml b/code-examples/protect-page-login/flutter_web_redirect/pubspec.yaml index d51104091..6de2bb50d 100644 --- a/code-examples/protect-page-login/flutter_web_redirect/pubspec.yaml +++ b/code-examples/protect-page-login/flutter_web_redirect/pubspec.yaml @@ -6,19 +6,20 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: ">=2.15.1 <3.0.0" + sdk: ">=3.0.6 <4.0.0" dependencies: flutter: sdk: flutter - cupertino_icons: 1.0.2 - dio: 4.0.6 - flutter_dotenv: 5.0.2 - ory_client: 1.1.27 + cupertino_icons: ^1.0.5 + dio: ^5.3.2 + flutter_dotenv: ^5.1.0 + ory_client: ^1.1.41 + universal_html: ^2.2.3 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: 2.0.1 + flutter_lints: ^2.0.2 flutter: uses-material-design: true diff --git a/docs/getting-started/integrate-auth/20_flutter-web-redirect.mdx b/docs/getting-started/integrate-auth/20_flutter-web-redirect.mdx index 6a51d2396..d39fd0dfa 100644 --- a/docs/getting-started/integrate-auth/20_flutter-web-redirect.mdx +++ b/docs/getting-started/integrate-auth/20_flutter-web-redirect.mdx @@ -56,7 +56,7 @@ Next, create an Authentication service in the `lib/services` directory. This ser session information. ```shell-session -touch lib/services/auth.dart +mkdir lib/services && touch lib/services/auth.dart ``` ```mdx-code-block title="lib/services/auth.dart" @@ -68,7 +68,7 @@ import auth from '!!raw-loader!../../../code-examples/protect-page-login/flutter ## Add environment variables Create a `.env` file in the root of the project to hold the `ORY_BASE_URL` variable. The value of the variable is the Ory proxy -URL, for example `http://localhost:3005/.ory`. +URL, for example `http://localhost:3005`. ```shell-session touch .env @@ -117,13 +117,13 @@ import SdkEnvVar from '@site/src/components/SdkEnvVar' ``` -3. Run the Ory proxy to mirror the Ory API endpoints on your application's domain (`localhost`): +3. Run the Ory tunnel to expose Ory API under the same top-level domain as your application (`localhost`): ```shell-session -ory proxy --port 3005 http://localhost:4005 +ory tunnel --port 3005 http://localhost:4005 ``` -4. Open [http://localhost:3005](http://localhost:3005) to access the application. As the initial call is made by an +4. Open [http://localhost:4005](http://localhost:4005) to access the application. As the initial call is made by an unauthenticated user, the session check doesn't detect a valid session and redirects to the login page of the defined Ory project.

From there, you can create a new account or sign in using an existing identity. When you sign in, the session becomes valid and the application shows the `Home` page with the session data.