Why Authentication
Abstraction of various authentication mechanism.
Interface
Auth is a server-side interface that identifies an user from some kind of identification. (e.g. access tokens)
interface Auth<User> {
function authenticate():Promise<Option<User>>;
}
Delegate is a client side interface that allows user to login/logout and generates authentication tokens
interface Delegate<Credentials, Profile> {
var status(default, null):Observable<Status<Profile>>;
function getToken():Promise<Option<String>>;
function signIn(credentials:Credentials):Promise<Profile>;
function signOut():Promise<Noise>;
}
enum Status<Profile> {
Initializing;
SignedOut;
SignedIn(profile:Profile);
Errored(e:Error);
}
Implementations
Auth
- CognitoAuth authenticates users using AWS Cognito ID token
- FirebaseAuth authenticates users using Firebase ID token
Delegate
- AmplifyDelegate an implementation for AWS Amplify
- DummyDelegate a dummy implementation that exposes the interface methods in a functional programming approach
Plugins
AuthSession.hxAn implementation fortink_web'sSessionwhich allows usingwhy.Authimplementations as authentication providers.DelegateClient.hxAn implementation fortink_http'sClientwhich allows usingwhy.Delegateimplementations as the provider to generate aAUTHORIZATIONHTTP header.