diff --git a/wien_talks/wien_talks_client/lib/src/protocol/client.dart b/wien_talks/wien_talks_client/lib/src/protocol/client.dart index de9b4df..99e1b50 100644 --- a/wien_talks/wien_talks_client/lib/src/protocol/client.dart +++ b/wien_talks/wien_talks_client/lib/src/protocol/client.dart @@ -12,7 +12,8 @@ import 'package:serverpod_client/serverpod_client.dart' as _i1; import 'dart:async' as _i2; import 'package:wien_talks_client/src/protocol/greeting.dart' as _i3; -import 'protocol.dart' as _i4; +import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i4; +import 'protocol.dart' as _i5; /// This is an example endpoint that returns a greeting message through /// its [hello] method. @@ -32,19 +33,12 @@ class EndpointGreeting extends _i1.EndpointRef { ); } -/// {@category Endpoint} -class EndpointRecipe extends _i1.EndpointRef { - EndpointRecipe(_i1.EndpointCaller caller) : super(caller); +class Modules { + Modules(Client client) { + auth = _i4.Caller(client); + } - @override - String get name => 'recipe'; - - _i2.Future postQuote(String quote) => - caller.callServerEndpoint( - 'recipe', - 'postQuote', - {'quote': quote}, - ); + late final _i4.Caller auth; } class Client extends _i1.ServerpodClientShared { @@ -63,7 +57,7 @@ class Client extends _i1.ServerpodClientShared { bool? disconnectStreamsOnLostInternetConnection, }) : super( host, - _i4.Protocol(), + _i5.Protocol(), securityContext: securityContext, authenticationKeyManager: authenticationKeyManager, streamingConnectionTimeout: streamingConnectionTimeout, @@ -74,19 +68,17 @@ class Client extends _i1.ServerpodClientShared { disconnectStreamsOnLostInternetConnection, ) { greeting = EndpointGreeting(this); - recipe = EndpointRecipe(this); + modules = Modules(this); } late final EndpointGreeting greeting; - late final EndpointRecipe recipe; + late final Modules modules; @override - Map get endpointRefLookup => { - 'greeting': greeting, - 'recipe': recipe, - }; + Map get endpointRefLookup => {'greeting': greeting}; @override - Map get moduleLookup => {}; + Map get moduleLookup => + {'auth': modules.auth}; } diff --git a/wien_talks/wien_talks_client/lib/src/protocol/protocol.dart b/wien_talks/wien_talks_client/lib/src/protocol/protocol.dart index 5719c72..88a112d 100644 --- a/wien_talks/wien_talks_client/lib/src/protocol/protocol.dart +++ b/wien_talks/wien_talks_client/lib/src/protocol/protocol.dart @@ -13,6 +13,7 @@ import 'package:serverpod_client/serverpod_client.dart' as _i1; import 'greeting.dart' as _i2; import 'quotes/create_quote.dart' as _i3; import 'quotes/quote.dart' as _i4; +import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i5; export 'greeting.dart'; export 'quotes/create_quote.dart'; export 'quotes/quote.dart'; @@ -59,6 +60,9 @@ class Protocol extends _i1.SerializationManager { ? (data as List).map((e) => deserialize(e)).toList() : null) as T; } + try { + return _i5.Protocol().deserialize(data, t); + } on _i1.DeserializationTypeNotFoundException catch (_) {} return super.deserialize(data, t); } @@ -75,6 +79,10 @@ class Protocol extends _i1.SerializationManager { if (data is _i4.Quote) { return 'Quote'; } + className = _i5.Protocol().getClassNameForObject(data); + if (className != null) { + return 'serverpod_auth.$className'; + } return null; } @@ -93,6 +101,10 @@ class Protocol extends _i1.SerializationManager { if (dataClassName == 'Quote') { return deserialize<_i4.Quote>(data['data']); } + if (dataClassName.startsWith('serverpod_auth.')) { + data['className'] = dataClassName.substring(15); + return _i5.Protocol().deserializeByClassName(data); + } return super.deserializeByClassName(data); } } diff --git a/wien_talks/wien_talks_server/lib/server.dart b/wien_talks/wien_talks_server/lib/server.dart index f69fa35..ed0e06c 100644 --- a/wien_talks/wien_talks_server/lib/server.dart +++ b/wien_talks/wien_talks_server/lib/server.dart @@ -1,10 +1,10 @@ -import 'package:wien_talks_server/src/birthday_reminder.dart'; import 'package:serverpod/serverpod.dart'; - +import 'package:serverpod_auth_server/serverpod_auth_server.dart' as auth; +import 'package:wien_talks_server/src/birthday_reminder.dart'; import 'package:wien_talks_server/src/web/routes/root.dart'; -import 'src/generated/protocol.dart'; import 'src/generated/endpoints.dart'; +import 'src/generated/protocol.dart'; // This is the starting point of your Serverpod server. In most cases, you will // only need to make additions to this file if you add future calls, are @@ -12,7 +12,12 @@ import 'src/generated/endpoints.dart'; void run(List args) async { // Initialize Serverpod and connect it with your generated code. - final pod = Serverpod(args, Protocol(), Endpoints()); + final pod = Serverpod( + args, + Protocol(), + Endpoints(), + authenticationHandler: auth.authenticationHandler, + ); // Setup a default page at the web root. pod.webServer.addRoute(RouteRoot(), '/'); diff --git a/wien_talks/wien_talks_server/lib/src/generated/protocol.yaml b/wien_talks/wien_talks_server/lib/src/generated/protocol.yaml index 2f46503..9a4113d 100644 --- a/wien_talks/wien_talks_server/lib/src/generated/protocol.yaml +++ b/wien_talks/wien_talks_server/lib/src/generated/protocol.yaml @@ -1,4 +1,2 @@ greeting: - hello: -recipe: - - postQuote: diff --git a/wien_talks/wien_talks_server/pubspec.lock b/wien_talks/wien_talks_server/pubspec.lock index 3112221..8cadb10 100644 --- a/wien_talks/wien_talks_server/pubspec.lock +++ b/wien_talks/wien_talks_server/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _discoveryapis_commons: + dependency: transitive + description: + name: _discoveryapis_commons + sha256: "113c4100b90a5b70a983541782431b82168b3cae166ab130649c36eb3559d498" + url: "https://pub.dev" + source: hosted + version: "1.0.7" _fe_analyzer_shared: dependency: transitive description: @@ -17,6 +25,14 @@ packages: url: "https://pub.dev" source: hosted version: "8.1.1" + archive: + dependency: transitive + description: + name: archive + sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd" + url: "https://pub.dev" + source: hosted + version: "4.0.7" args: dependency: transitive description: @@ -25,6 +41,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.7.0" + asn1lib: + dependency: transitive + description: + name: asn1lib + sha256: "9a8f69025044eb466b9b60ef3bc3ac99b4dc6c158ae9c56d25eeccf5bc56d024" + url: "https://pub.dev" + source: hosted + version: "1.6.5" async: dependency: transitive description: @@ -65,6 +89,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.0" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" collection: dependency: transitive description: @@ -97,6 +129,30 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.6" + crypto_keys: + dependency: transitive + description: + name: crypto_keys + sha256: acc19abf34623d990a0e8aec69463d74a824c31f137128f42e2810befc509ad0 + url: "https://pub.dev" + source: hosted + version: "0.3.0+1" + email_validator: + dependency: transitive + description: + name: email_validator + sha256: b19aa5d92fdd76fbc65112060c94d45ba855105a28bb6e462de7ff03b12fa1fb + url: "https://pub.dev" + source: hosted + version: "3.0.0" + ffi: + dependency: transitive + description: + name: ffi + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + url: "https://pub.dev" + source: hosted + version: "2.1.4" file: dependency: transitive description: @@ -137,6 +193,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.3" + google_identity_services_web: + dependency: transitive + description: + name: google_identity_services_web + sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454" + url: "https://pub.dev" + source: hosted + version: "0.3.3+1" + googleapis: + dependency: transitive + description: + name: googleapis + sha256: "5c9e0f25be1dec13d8d2158263141104c51b5ba83487537c17a2330581e505ee" + url: "https://pub.dev" + source: hosted + version: "14.0.0" + googleapis_auth: + dependency: transitive + description: + name: googleapis_auth + sha256: b81fe352cc4a330b3710d2b7ad258d9bcef6f909bb759b306bf42973a7d046db + url: "https://pub.dev" + source: hosted + version: "2.0.0" http: dependency: transitive description: @@ -161,6 +241,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.2" + image: + dependency: transitive + description: + name: image + sha256: "4e973fcf4caae1a4be2fa0a13157aa38a8f9cb049db6529aa00b4d71abc4d928" + url: "https://pub.dev" + source: hosted + version: "4.5.4" io: dependency: transitive description: @@ -169,6 +257,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + jose: + dependency: transitive + description: + name: jose + sha256: "7955ec5d131960104e81fbf151abacb9d835c16c9e793ed394b2809f28b2198d" + url: "https://pub.dev" + source: hosted + version: "0.3.4" js: dependency: transitive description: @@ -233,6 +329,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + openid_client: + dependency: transitive + description: + name: openid_client + sha256: "1d39a829dc770947bf8ec8684a3456743ef0205a777371efe16773a44163eb6a" + url: "https://pub.dev" + source: hosted + version: "0.4.9" package_config: dependency: transitive description: @@ -249,6 +353,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "1a97266a94f7350d30ae522c0af07890c70b8e62c71e8e3920d1db4d23c057d1" + url: "https://pub.dev" + source: hosted + version: "7.0.1" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe" + url: "https://pub.dev" + source: hosted + version: "3.9.1" pool: dependency: transitive description: @@ -257,6 +377,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + posix: + dependency: transitive + description: + name: posix + sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61" + url: "https://pub.dev" + source: hosted + version: "6.0.3" postgres: dependency: transitive description: @@ -273,6 +401,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: ea0b925899e64ecdfbf9c7becb60d5b50e706ade44a85b2363be2a22d88117d2 + url: "https://pub.dev" + source: hosted + version: "3.2.2" redis: dependency: transitive description: @@ -313,6 +449,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.9.1" + serverpod_auth_server: + dependency: "direct main" + description: + name: serverpod_auth_server + sha256: ad393f09b5ed82b624c9d299b61d945fb07729a0a704faa67795588200168369 + url: "https://pub.dev" + source: hosted + version: "2.9.1" serverpod_lints: dependency: transitive description: @@ -561,6 +705,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + x509: + dependency: transitive + description: + name: x509 + sha256: cbd1a63846884afd273cda247b0365284c8d85a365ca98e110413f93d105b935 + url: "https://pub.dev" + source: hosted + version: "0.2.4+3" + xml: + dependency: transitive + description: + name: xml + sha256: "3202a47961c1a0af6097c9f8c1b492d705248ba309e6f7a72410422c05046851" + url: "https://pub.dev" + source: hosted + version: "6.6.0" yaml: dependency: transitive description: diff --git a/wien_talks/wien_talks_server/pubspec.yaml b/wien_talks/wien_talks_server/pubspec.yaml index bebc275..9df0369 100644 --- a/wien_talks/wien_talks_server/pubspec.yaml +++ b/wien_talks/wien_talks_server/pubspec.yaml @@ -8,6 +8,7 @@ environment: dependencies: serverpod: 2.9.1 + serverpod_auth_server: ^2.9.1 dev_dependencies: lints: '>=3.0.0 <7.0.0' diff --git a/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart b/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart index 02dbd91..d9ec37d 100644 --- a/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart +++ b/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart @@ -102,8 +102,6 @@ void withServerpod( class TestEndpoints { late final _GreetingEndpoint greeting; - - late final _RecipeEndpoint recipe; } class _InternalTestEndpoints extends TestEndpoints @@ -117,10 +115,6 @@ class _InternalTestEndpoints extends TestEndpoints endpoints, serializationManager, ); - recipe = _RecipeEndpoint( - endpoints, - serializationManager, - ); } } @@ -163,43 +157,3 @@ class _GreetingEndpoint { }); } } - -class _RecipeEndpoint { - _RecipeEndpoint( - this._endpointDispatch, - this._serializationManager, - ); - - final _i2.EndpointDispatch _endpointDispatch; - - final _i2.SerializationManager _serializationManager; - - _i3.Future postQuote( - _i1.TestSessionBuilder sessionBuilder, - String quote, - ) async { - return _i1.callAwaitableFunctionAndHandleExceptions(() async { - var _localUniqueSession = - (sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild( - endpoint: 'recipe', - method: 'postQuote', - ); - try { - var _localCallContext = await _endpointDispatch.getMethodCallContext( - createSessionCallback: (_) => _localUniqueSession, - endpointPath: 'recipe', - methodName: 'postQuote', - parameters: _i1.testObjectToJson({'quote': quote}), - serializationManager: _serializationManager, - ); - var _localReturnValue = await (_localCallContext.method.call( - _localUniqueSession, - _localCallContext.arguments, - ) as _i3.Future); - return _localReturnValue; - } finally { - await _localUniqueSession.close(); - } - }); - } -}