Security<User> class
abstract
The security module.
##Usage
First, you have to implement Authenticator. For sake of description, we use a dummy implementation here called DummyAuthenticator:
final authenticator = new DummyAuthenticator()
..addUser("john", "123", ["user"])
..addUser("peter", "123", ["user", "admin"]);
Second, you can use SimpleAccessControl
or implement your own access control
(AccessControl):
final accessControl = new SimpleAccessControl({
"/admin/.*": ["admin"],
"/member/.*": ["user", "admin"]
});
Finally, instantiate Security with the authenticator and access control you want:
final security = new Security(authenticator, accessControl);
new StreamServer(uriMapping: {
"/s_login": security.login,
"/s_logout": security.logout
}, filterMapping: {
"/.*": security.filter
}).start();
Constructors
-
Security(Authenticator<
User> authenticator, AccessControl<User> accessControl, {Redirector? redirector, RememberMe<User> ? rememberMe, RememberUri? rememberUri, FutureOr onLogin(HttpConnect connect, User user, bool? rememberMe)?, FutureOr onLogout(HttpConnect connect, User user)?}) -
Constructor.
*
factory
Properties
- accessControl → AccessControl
-
The access control.
no setter
- authenticator → Authenticator
-
The authenticator.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- redirector → Redirector
-
The redirector.
no setter
- rememberMe → RememberMe?
-
The remember me.
no setter
- rememberUri → RememberUri
-
The remember URI.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
filter(
HttpConnect connect, Future chain(HttpConnect conn)) → Future - The filter used to configure Stream server's filter mapping.
-
login(
HttpConnect connect, {String? username, String? password, bool? rememberMe, bool redirect = true, bool handleAuthenticationException = true}) → Future - The handler used to configure Stream server's URI mapping for handling
-
logout(
HttpConnect connect, {bool redirect = true}) → Future - The handler used to configure Stream server's URI mapping for handling
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setLogin(
HttpConnect connect, User user, {bool? rememberMe, bool resetSession = true, bool onLogin = true}) → Future - Notifies Rikulo Security that the given user logged in.
-
switchBack(
HttpConnect conect, Map< String, dynamic> data) → void - Switches back.
-
switchLogin(
HttpConnect connect, User user, {bool onLogin = true, bool? resetSession}) → Future< Map< String, dynamic> > -
Switches to the given
user
. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited