-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from go-bazzinga/9-add-login-page
adding app flow documentation
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Anonymous Identity | ||
|
||
```mermaid | ||
--- | ||
title: Generated anonymous identity & session identity for new user | ||
--- | ||
sequenceDiagram | ||
actor client as Client Device | ||
participant ssr as SSR Backend | ||
participant auth as Auth Service | ||
participant canister as Canister | ||
participant kv as Cloudflare KV Store | ||
client->>ssr: Visits website 1st time | ||
ssr->>client: Loads Auth page in iframe | ||
client->>auth: Loads anonymous identity page | ||
Note over auth: Creates Private KeyPair <br/> & Session KeyPair for a user <br/> using random seed | ||
Note over auth: Session KeyPair is <br/> valid for 30 minutes | ||
auth->>kv: Store User's private & session KeyPair | ||
Note over kv: {pubkey: User's Pubkey, <br/> private_key: User's Private Key, <br/> session_identity: Session KeyPair } | ||
Note over auth: Generates DelegatedIdentity <br/> signed by Private KeyPair | ||
auth-->>client: Returns Delegated Identity with signed cookie with refresh token | ||
Note over client: Builds Secp256k1Identity <br/> & DelegatedIdentity | ||
Note over client: Client builds Secp256k1KeyIdentity <br/> & DelegationIdentity <br/> & keeps ready for <br/> future canister calls | ||
client->>canister: When needed calls canister using DelegatedIdentity directly for fetching resources | ||
canister-->>client: Provides resources | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# OAuth2 Login | ||
|
||
## Example provider - Google | ||
|
||
```mermaid | ||
--- | ||
title: OAuth2 Login when user wants to claim tokens | ||
--- | ||
sequenceDiagram | ||
actor client as Client Device | ||
participant ssr as SSR Backend | ||
participant auth as Auth Service | ||
participant ext_auth as External OAuth Service | ||
participant canister as Canister | ||
participant kv as Cloudflare KV Store | ||
Note over client: client passes signed<br /> cookie everytime<br/> with refresh token to auth | ||
client->>auth: Client clicks on claim<br /> tokens button is redirected<br /> to auth login page | ||
auth-->>client: Returns Login Page with oAuth providers<br /> sets pkce_verifire & csrf_token in cookie | ||
client->>ext_auth: Chooses provider & redirects<br /> Client logs-in on provider's page | ||
ext_auth-->client: Provides request token & csrf_token in return | ||
client-->>auth: passes request Token & provided csrf token. | ||
auth->>ext_auth: Verifies token with pkce_verifire & csrf_token | ||
ext_auth-->>auth: returns with access token | ||
auth->>ext_auth: Requests user's id | ||
ext_auth-->>auth: User id returned | ||
auth->>kv: Stores user id associated with user's keypair | ||
auth-->>client: Returns updated refresh token<br /> and new delegated session<br /> for user's keypair | ||
client-->>client: From auth page<br /> Sends post_message with new<br /> delegated session id to ssr page | ||
Note over client: Client continues using app & can claim tokens | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters