add: adding blank files refactor contracts.dart to auth.dart
This commit is contained in:
parent
c900303ee8
commit
cf208dc7c1
136 changed files with 298 additions and 8 deletions
21
packages/contracts/lib/auth.dart
Normal file
21
packages/contracts/lib/auth.dart
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/// Support for doing something awesome.
|
||||||
|
///
|
||||||
|
/// More dartdocs go here.
|
||||||
|
library;
|
||||||
|
|
||||||
|
// Auth Contracts
|
||||||
|
export 'src/auth/access/authorizable.dart';
|
||||||
|
export 'src/auth/access/gate.dart';
|
||||||
|
export 'src/auth/middleware/authenticates_request.dart';
|
||||||
|
export 'src/auth/authenticatable.dart';
|
||||||
|
export 'src/auth/can_reset_password.dart';
|
||||||
|
export 'src/auth/factory.dart';
|
||||||
|
export 'src/auth/guard.dart';
|
||||||
|
export 'src/auth/must_verify_email.dart';
|
||||||
|
export 'src/auth/password_broker_factory.dart';
|
||||||
|
export 'src/auth/password_broker.dart';
|
||||||
|
export 'src/auth/stateful_guard.dart';
|
||||||
|
export 'src/auth/supports_basic_auth.dart';
|
||||||
|
export 'src/auth/user_provider.dart';
|
||||||
|
|
||||||
|
// TODO: Export any libraries intended for clients of this package.
|
|
@ -1,8 +0,0 @@
|
||||||
/// Support for doing something awesome.
|
|
||||||
///
|
|
||||||
/// More dartdocs go here.
|
|
||||||
library;
|
|
||||||
|
|
||||||
// export 'src/fabric_contracts_base.dart';
|
|
||||||
|
|
||||||
// TODO: Export any libraries intended for clients of this package.
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
abstract class Authenticatable {
|
||||||
|
/// Get the name of the unique identifier for the user.
|
||||||
|
///
|
||||||
|
/// @return string
|
||||||
|
String getAuthIdentifierName();
|
||||||
|
|
||||||
|
/// Get the unique identifier for the user.
|
||||||
|
///
|
||||||
|
/// @return dynamic
|
||||||
|
dynamic getAuthIdentifier();
|
||||||
|
|
||||||
|
/// Get the name of the password attribute for the user.
|
||||||
|
///
|
||||||
|
/// @return string
|
||||||
|
String getAuthPasswordName();
|
||||||
|
|
||||||
|
/// Get the password for the user.
|
||||||
|
///
|
||||||
|
/// @return string
|
||||||
|
String getAuthPassword();
|
||||||
|
|
||||||
|
/// Get the token value for the "remember me" session.
|
||||||
|
///
|
||||||
|
/// @return string
|
||||||
|
String getRememberToken();
|
||||||
|
|
||||||
|
/// Set the token value for the "remember me" session.
|
||||||
|
///
|
||||||
|
/// @param string value
|
||||||
|
/// @return void
|
||||||
|
void setRememberToken(String value);
|
||||||
|
|
||||||
|
/// Get the column name for the "remember me" token.
|
||||||
|
///
|
||||||
|
/// @return string
|
||||||
|
String getRememberTokenName();
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
abstract class CanResetPassword {
|
||||||
|
/// Get the e-mail address where password reset links are sent.
|
||||||
|
///
|
||||||
|
/// @return string
|
||||||
|
String getEmailForPasswordReset();
|
||||||
|
|
||||||
|
/// Send the password reset notification.
|
||||||
|
///
|
||||||
|
/// @param string token
|
||||||
|
/// @return void
|
||||||
|
void sendPasswordResetNotification(String token);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
//import 'package:your_project_path/contracts/auth/guard.dart';
|
||||||
|
//import 'package:your_project_path/contracts/auth/stateful_guard.dart';
|
||||||
|
import 'package:fabric_contracts/auth.dart';
|
||||||
|
|
||||||
|
abstract class Factory {
|
||||||
|
/// Get a guard instance by name.
|
||||||
|
///
|
||||||
|
/// @param [name] The name of the guard instance to retrieve.
|
||||||
|
/// @return An instance of [Guard] or [StatefulGuard].
|
||||||
|
Guard guard(String? name);
|
||||||
|
|
||||||
|
/// Set the default guard the factory should serve.
|
||||||
|
///
|
||||||
|
/// @param [name] The name of the default guard.
|
||||||
|
void shouldUse(String name);
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
import 'authenticatable.dart';
|
||||||
|
abstract class Guard {
|
||||||
|
/// Determine if the current user is authenticated.
|
||||||
|
///
|
||||||
|
/// @return bool
|
||||||
|
bool check();
|
||||||
|
|
||||||
|
/// Determine if the current user is a guest.
|
||||||
|
///
|
||||||
|
/// @return bool
|
||||||
|
bool guest();
|
||||||
|
|
||||||
|
/// Get the currently authenticated user.
|
||||||
|
///
|
||||||
|
/// @return Authenticatable|null
|
||||||
|
Authenticatable? user();
|
||||||
|
|
||||||
|
/// Get the ID for the currently authenticated user.
|
||||||
|
///
|
||||||
|
/// @return int|string|null
|
||||||
|
dynamic id();
|
||||||
|
|
||||||
|
/// Validate a user's credentials.
|
||||||
|
///
|
||||||
|
/// @param Map<String, dynamic> credentials
|
||||||
|
/// @return bool
|
||||||
|
bool validate(Map<String, dynamic> credentials);
|
||||||
|
|
||||||
|
/// Determine if the guard has a user instance.
|
||||||
|
///
|
||||||
|
/// @return bool
|
||||||
|
bool hasUser();
|
||||||
|
|
||||||
|
/// Set the current user.
|
||||||
|
///
|
||||||
|
/// @param Authenticatable user
|
||||||
|
/// @return Guard
|
||||||
|
Guard setUser(Authenticatable user);
|
||||||
|
}
|
||||||
|
|
||||||
|
//abstract class Authenticatable {
|
||||||
|
// String getIdentifier();
|
||||||
|
//}
|
|
@ -0,0 +1,21 @@
|
||||||
|
abstract class MustVerifyEmail {
|
||||||
|
/// Determine if the user has verified their email address.
|
||||||
|
///
|
||||||
|
/// @return bool
|
||||||
|
bool hasVerifiedEmail();
|
||||||
|
|
||||||
|
/// Mark the given user's email as verified.
|
||||||
|
///
|
||||||
|
/// @return bool
|
||||||
|
bool markEmailAsVerified();
|
||||||
|
|
||||||
|
/// Send the email verification notification.
|
||||||
|
///
|
||||||
|
/// @return void
|
||||||
|
void sendEmailVerificationNotification();
|
||||||
|
|
||||||
|
/// Get the email address that should be used for verification.
|
||||||
|
///
|
||||||
|
/// @return string
|
||||||
|
String getEmailForVerification();
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
typedef Closure = FutureOr<dynamic> Function();
|
||||||
|
|
||||||
|
abstract class PasswordBroker {
|
||||||
|
/// Constant representing a successfully sent reminder.
|
||||||
|
static const String RESET_LINK_SENT = 'passwords.sent';
|
||||||
|
|
||||||
|
/// Constant representing a successfully reset password.
|
||||||
|
static const String PASSWORD_RESET = 'passwords.reset';
|
||||||
|
|
||||||
|
/// Constant representing the user not found response.
|
||||||
|
static const String INVALID_USER = 'passwords.user';
|
||||||
|
|
||||||
|
/// Constant representing an invalid token.
|
||||||
|
static const String INVALID_TOKEN = 'passwords.token';
|
||||||
|
|
||||||
|
/// Constant representing a throttled reset attempt.
|
||||||
|
static const String RESET_THROTTLED = 'passwords.throttled';
|
||||||
|
|
||||||
|
/// Send a password reset link to a user.
|
||||||
|
///
|
||||||
|
/// @param Map<String, dynamic> credentials
|
||||||
|
/// @param Closure? callback
|
||||||
|
/// @return Future<String>
|
||||||
|
Future<String> sendResetLink(Map<String, dynamic> credentials, [Closure? callback]);
|
||||||
|
|
||||||
|
/// Reset the password for the given token.
|
||||||
|
///
|
||||||
|
/// @param Map<String, dynamic> credentials
|
||||||
|
/// @param Closure callback
|
||||||
|
/// @return Future<dynamic>
|
||||||
|
Future<dynamic> reset(Map<String, dynamic> credentials, Closure callback);
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
import 'password_broker.dart';
|
||||||
|
|
||||||
|
abstract class PasswordBrokerFactory {
|
||||||
|
/// Get a password broker instance by name.
|
||||||
|
///
|
||||||
|
/// @param String? name
|
||||||
|
/// @return PasswordBroker
|
||||||
|
PasswordBroker broker([String? name]);
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
import 'authenticatable.dart';
|
||||||
|
import 'guard.dart';
|
||||||
|
|
||||||
|
abstract class StatefulGuard extends Guard {
|
||||||
|
/// Attempt to authenticate a user using the given credentials.
|
||||||
|
///
|
||||||
|
/// [credentials] are the user's credentials.
|
||||||
|
/// [remember] indicates if the user should be remembered.
|
||||||
|
/// Returns true if authentication was successful.
|
||||||
|
Future<bool> attempt(Map<String, dynamic> credentials, {bool remember = false});
|
||||||
|
|
||||||
|
/// Log a user into the application without sessions or cookies.
|
||||||
|
///
|
||||||
|
/// [credentials] are the user's credentials.
|
||||||
|
/// Returns true if authentication was successful.
|
||||||
|
Future<bool> once(Map<String, dynamic> credentials);
|
||||||
|
|
||||||
|
/// Log a user into the application.
|
||||||
|
///
|
||||||
|
/// [user] is the user to log in.
|
||||||
|
/// [remember] indicates if the user should be remembered.
|
||||||
|
void login(Authenticatable user, {bool remember = false});
|
||||||
|
|
||||||
|
/// Log the given user ID into the application.
|
||||||
|
///
|
||||||
|
/// [id] is the ID of the user.
|
||||||
|
/// [remember] indicates if the user should be remembered.
|
||||||
|
/// Returns the authenticated user or false if authentication failed.
|
||||||
|
Future<Authenticatable?> loginUsingId(dynamic id, {bool remember = false});
|
||||||
|
|
||||||
|
/// Log the given user ID into the application without sessions or cookies.
|
||||||
|
///
|
||||||
|
/// [id] is the ID of the user.
|
||||||
|
/// Returns the authenticated user or false if authentication failed.
|
||||||
|
Future<Authenticatable?> onceUsingId(dynamic id);
|
||||||
|
|
||||||
|
/// Determine if the user was authenticated via "remember me" cookie.
|
||||||
|
///
|
||||||
|
/// Returns true if authenticated via "remember me" cookie.
|
||||||
|
bool viaRemember();
|
||||||
|
|
||||||
|
/// Log the user out of the application.
|
||||||
|
void logout();
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
import 'package:symfony/http_foundation.dart';
|
||||||
|
|
||||||
|
abstract class SupportsBasicAuth {
|
||||||
|
/// Attempt to authenticate using HTTP Basic Auth.
|
||||||
|
///
|
||||||
|
/// @param String field
|
||||||
|
/// @param Map<String, dynamic> extraConditions
|
||||||
|
/// @return Response|null
|
||||||
|
Response? basic({String field = 'email', Map<String, dynamic> extraConditions = const {}});
|
||||||
|
|
||||||
|
/// Perform a stateless HTTP Basic login attempt.
|
||||||
|
///
|
||||||
|
/// @param String field
|
||||||
|
/// @param Map<String, dynamic> extraConditions
|
||||||
|
/// @return Response|null
|
||||||
|
Response? onceBasic({String field = 'email', Map<String, dynamic> extraConditions = const {}});
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
import 'authenticatable.dart';
|
||||||
|
|
||||||
|
abstract class UserProvider {
|
||||||
|
/// Retrieve a user by their unique identifier.
|
||||||
|
///
|
||||||
|
/// @param dynamic identifier
|
||||||
|
/// @return Authenticatable|null
|
||||||
|
Future<Authenticatable?> retrieveById(dynamic identifier);
|
||||||
|
|
||||||
|
/// Retrieve a user by their unique identifier and "remember me" token.
|
||||||
|
///
|
||||||
|
/// @param dynamic identifier
|
||||||
|
/// @param String token
|
||||||
|
/// @return Authenticatable|null
|
||||||
|
Future<Authenticatable?> retrieveByToken(dynamic identifier, String token);
|
||||||
|
|
||||||
|
/// Update the "remember me" token for the given user in storage.
|
||||||
|
///
|
||||||
|
/// @param Authenticatable user
|
||||||
|
/// @param String token
|
||||||
|
/// @return void
|
||||||
|
Future<void> updateRememberToken(Authenticatable user, String token);
|
||||||
|
|
||||||
|
/// Retrieve a user by the given credentials.
|
||||||
|
///
|
||||||
|
/// @param Map<String, dynamic> credentials
|
||||||
|
/// @return Authenticatable|null
|
||||||
|
Future<Authenticatable?> retrieveByCredentials(Map<String, dynamic> credentials);
|
||||||
|
|
||||||
|
/// Validate a user against the given credentials.
|
||||||
|
///
|
||||||
|
/// @param Authenticatable user
|
||||||
|
/// @param Map<String, dynamic> credentials
|
||||||
|
/// @return bool
|
||||||
|
Future<bool> validateCredentials(Authenticatable user, Map<String, dynamic> credentials);
|
||||||
|
|
||||||
|
/// Rehash the user's password if required and supported.
|
||||||
|
///
|
||||||
|
/// @param Authenticatable user
|
||||||
|
/// @param Map<String, dynamic> credentials
|
||||||
|
/// @param bool force
|
||||||
|
/// @return void
|
||||||
|
Future<void> rehashPasswordIfRequired(Authenticatable user, Map<String, dynamic> credentials, {bool force = false});
|
||||||
|
}
|
0
packages/contracts/lib/src/broadcasting/broadcaster.dart
Normal file
0
packages/contracts/lib/src/broadcasting/broadcaster.dart
Normal file
0
packages/contracts/lib/src/broadcasting/factory.dart
Normal file
0
packages/contracts/lib/src/broadcasting/factory.dart
Normal file
0
packages/contracts/lib/src/bus/dispatcher.dart
Normal file
0
packages/contracts/lib/src/bus/dispatcher.dart
Normal file
0
packages/contracts/lib/src/bus/queueing_dispatcher.dart
Normal file
0
packages/contracts/lib/src/bus/queueing_dispatcher.dart
Normal file
0
packages/contracts/lib/src/cache/factory.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/factory.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/lock.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/lock.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/lock_provider.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/lock_provider.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/lock_timeout_exception.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/lock_timeout_exception.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/repository.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/repository.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/store.dart
vendored
Normal file
0
packages/contracts/lib/src/cache/store.dart
vendored
Normal file
0
packages/contracts/lib/src/config/repository.dart
Normal file
0
packages/contracts/lib/src/config/repository.dart
Normal file
0
packages/contracts/lib/src/console/application.dart
Normal file
0
packages/contracts/lib/src/console/application.dart
Normal file
0
packages/contracts/lib/src/console/isolatable.dart
Normal file
0
packages/contracts/lib/src/console/isolatable.dart
Normal file
0
packages/contracts/lib/src/console/kernel.dart
Normal file
0
packages/contracts/lib/src/console/kernel.dart
Normal file
0
packages/contracts/lib/src/container/container.dart
Normal file
0
packages/contracts/lib/src/container/container.dart
Normal file
0
packages/contracts/lib/src/cookie/factory.dart
Normal file
0
packages/contracts/lib/src/cookie/factory.dart
Normal file
0
packages/contracts/lib/src/cookie/queueing_factory.dart
Normal file
0
packages/contracts/lib/src/cookie/queueing_factory.dart
Normal file
0
packages/contracts/lib/src/database/query/builder.dart
Normal file
0
packages/contracts/lib/src/database/query/builder.dart
Normal file
0
packages/contracts/lib/src/debug/exception_handler.dart
Normal file
0
packages/contracts/lib/src/debug/exception_handler.dart
Normal file
0
packages/contracts/lib/src/encryption/encrypter.dart
Normal file
0
packages/contracts/lib/src/encryption/encrypter.dart
Normal file
0
packages/contracts/lib/src/events/dispatcher.dart
Normal file
0
packages/contracts/lib/src/events/dispatcher.dart
Normal file
0
packages/contracts/lib/src/filesystem/cloud.dart
Normal file
0
packages/contracts/lib/src/filesystem/cloud.dart
Normal file
0
packages/contracts/lib/src/filesystem/factory.dart
Normal file
0
packages/contracts/lib/src/filesystem/factory.dart
Normal file
0
packages/contracts/lib/src/filesystem/filesystem.dart
Normal file
0
packages/contracts/lib/src/filesystem/filesystem.dart
Normal file
0
packages/contracts/lib/src/foundation/application.dart
Normal file
0
packages/contracts/lib/src/foundation/application.dart
Normal file
0
packages/contracts/lib/src/foundation/caches_routes.dart
Normal file
0
packages/contracts/lib/src/foundation/caches_routes.dart
Normal file
0
packages/contracts/lib/src/hashing/hasher.dart
Normal file
0
packages/contracts/lib/src/hashing/hasher.dart
Normal file
0
packages/contracts/lib/src/http/kernel.dart
Normal file
0
packages/contracts/lib/src/http/kernel.dart
Normal file
0
packages/contracts/lib/src/mail/attachable.dart
Normal file
0
packages/contracts/lib/src/mail/attachable.dart
Normal file
0
packages/contracts/lib/src/mail/factory.dart
Normal file
0
packages/contracts/lib/src/mail/factory.dart
Normal file
0
packages/contracts/lib/src/mail/mail_queue.dart
Normal file
0
packages/contracts/lib/src/mail/mail_queue.dart
Normal file
0
packages/contracts/lib/src/mail/mailable.dart
Normal file
0
packages/contracts/lib/src/mail/mailable.dart
Normal file
0
packages/contracts/lib/src/mail/mailer.dart
Normal file
0
packages/contracts/lib/src/mail/mailer.dart
Normal file
0
packages/contracts/lib/src/notifications/dispatcher.dart
Normal file
0
packages/contracts/lib/src/notifications/dispatcher.dart
Normal file
0
packages/contracts/lib/src/notifications/factory.dart
Normal file
0
packages/contracts/lib/src/notifications/factory.dart
Normal file
0
packages/contracts/lib/src/pagination/paginator.dart
Normal file
0
packages/contracts/lib/src/pagination/paginator.dart
Normal file
0
packages/contracts/lib/src/pipeline/hub.dart
Normal file
0
packages/contracts/lib/src/pipeline/hub.dart
Normal file
0
packages/contracts/lib/src/pipeline/pipeline.dart
Normal file
0
packages/contracts/lib/src/pipeline/pipeline.dart
Normal file
0
packages/contracts/lib/src/process/invoked_process.dart
Normal file
0
packages/contracts/lib/src/process/invoked_process.dart
Normal file
0
packages/contracts/lib/src/process/process_result.dart
Normal file
0
packages/contracts/lib/src/process/process_result.dart
Normal file
0
packages/contracts/lib/src/queue/clearable_queue.dart
Normal file
0
packages/contracts/lib/src/queue/clearable_queue.dart
Normal file
0
packages/contracts/lib/src/queue/entity_resolver.dart
Normal file
0
packages/contracts/lib/src/queue/entity_resolver.dart
Normal file
0
packages/contracts/lib/src/queue/factory.dart
Normal file
0
packages/contracts/lib/src/queue/factory.dart
Normal file
0
packages/contracts/lib/src/queue/job.dart
Normal file
0
packages/contracts/lib/src/queue/job.dart
Normal file
0
packages/contracts/lib/src/queue/monitor.dart
Normal file
0
packages/contracts/lib/src/queue/monitor.dart
Normal file
0
packages/contracts/lib/src/queue/queue.dart
Normal file
0
packages/contracts/lib/src/queue/queue.dart
Normal file
0
packages/contracts/lib/src/queue/queueable_entity.dart
Normal file
0
packages/contracts/lib/src/queue/queueable_entity.dart
Normal file
0
packages/contracts/lib/src/queue/should_be_unique.dart
Normal file
0
packages/contracts/lib/src/queue/should_be_unique.dart
Normal file
0
packages/contracts/lib/src/queue/should_queue.dart
Normal file
0
packages/contracts/lib/src/queue/should_queue.dart
Normal file
0
packages/contracts/lib/src/redis/connection.dart
Normal file
0
packages/contracts/lib/src/redis/connection.dart
Normal file
0
packages/contracts/lib/src/redis/connector.dart
Normal file
0
packages/contracts/lib/src/redis/connector.dart
Normal file
0
packages/contracts/lib/src/redis/factory.dart
Normal file
0
packages/contracts/lib/src/redis/factory.dart
Normal file
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue