-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.md
56 lines (43 loc) · 1.86 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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)
```haxe
interface Auth<User> {
function authenticate():Promise<Option<User>>;
}
```
`Delegate` is a client side interface that allows user to login/logout and generates authentication tokens
```haxe
interface Delegate<SignUpInfo, Credentials, Profile, ProfilePatch> {
final status:Observable<Status<User<Profile, ProfilePatch>>>;
function signUp(info:SignUpInfo):Promise<Noise>;
function signIn(credentials:Credentials):Promise<Noise>;
function signOut():Promise<Noise>;
function forgetPassword(id:String):Promise<Noise>;
function resetPassword(id:String, code:String, password:String):Promise<Noise>;
function confirmSignUp(id:String, code:String):Promise<Noise>;
}
interface User<Profile, ProfilePatch> {
final profile:Observable<Profile>;
function getToken():Promise<String>;
function updateProfile(patch:ProfilePatch):Promise<Noise>;
function changePassword(oldPassword:String, newPassword:String):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.hx` An implementation for `tink_web`'s `Session` which allows using `why.Auth` implementations as authentication providers.
- `DelegateClient.hx` An implementation for `tink_http`'s `Client` which allows using `why.Delegate` implementations as the provider to generate a `AUTHORIZATION` HTTP header.