You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Cloud users, We've made it easy to let you "Bring your own UI" to Logto. Cloud users can now upload a zip file containing the custom UI assets in Logto Console -> Sign-in experience -> Custom UI. (Check out the [Bring your UI](/docs/recipes/customize-sie/bring-your-ui) for more details.)
9
+
For Logto Cloud users, We've made it easy to let you "Bring your own UI" to Logto. Cloud users can now upload a zip file containing the custom UI assets in Logto Console -> Sign-in experience -> Custom UI. (Check out the [Bring your UI](/docs/recipes/customize-sie/bring-your-ui) page for more details.)
10
10
11
11
However, when developing such custom UI pages, users want to test and debug the code locally, before uploading to Logto Cloud. This CLI command helps you set up a local proxy and connect the following 3 entities together:
12
12
your Logto cloud auth endpoint, your application, and your custom sign-in UI.
13
13
14
-
Assuming your Cloud tenant ID is `foobar`, and you have a custom sign-in page running on dev server at `http://localhost:4000`.
14
+
## Why do I need this?
15
+
16
+
By default, when you click the "sign-in" button in your application, you will be navigated to the sign-in page configured at Logto endpoint. A successful sign-in flow can be illustrated as follows:
17
+
18
+
```mermaid
19
+
sequenceDiagram
20
+
box Local machine
21
+
participant A as Your application
22
+
end
23
+
box Logto Cloud
24
+
participant B as Logto Cloud auth endpoint
25
+
participant C as Logto sign-in page
26
+
end
27
+
A ->> B: User initiates "sign-in" action and request auth
28
+
B -->> A: Return auth response and tell the client<br/>to redirect to the Logto sign-in page
29
+
A ->> C: Redirect to the Logto sign-in page
30
+
C ->> B: Submit the sign-in form and<br/>request experience API to authenticate
31
+
B -->> C: Respond the sign-in request and<br/>tell the client to redirect to your application
32
+
C -->> A: Redirect to your application
33
+
A --> A: Handle the sign-in callback and<br/>the user is now authenticated
34
+
```
35
+
36
+
But now since you are developing your own custom sign-in UI, you need a way to navigate to the custom sign-in UI pages running on your local machine instead.
37
+
This requires a local proxy to intercept the outgoing requests from your application and redirect them to your custom sign-in UI pages.
38
+
39
+
Additionally, you need to interact with Logto's experience API to authenticate users and manage sessions.
40
+
This proxy will also help forward these experience API requests to Logto Cloud in order to avoid CORS issues.
41
+
42
+
The sequence diagram below illustrates how a successful "sign-in" flow works with your custom UI and the proxy in place:
43
+
44
+
```mermaid
45
+
sequenceDiagram
46
+
box Local machine
47
+
participant A as Your application
48
+
participant B as Your custom sign-in UI
49
+
participant C as proxy
50
+
end
51
+
box Logto Cloud
52
+
participant D as Logto Cloud auth endpoint
53
+
participant E as Logto sign-in page
54
+
end
55
+
A ->> C: User initiates "sign-in" action and request auth
56
+
C ->> D: Forward auth request to Logto Cloud endpoint
57
+
D -->> C: Return auth response andtell the client<br/>to redirect to the Logto sign-in page
58
+
C ->> B: Intercept the redirect and<br/>redirect to your custom sign-in page
59
+
B ->> C: Submit the sign-in form and<br/>request experience API to authenticate
60
+
C ->> D: Forward the experience API requests to Logto Cloud
61
+
D -->> C: Authenticate sign-in request and<br/>tell the client to redirect to your application
62
+
C -->> A: Redirect to your application
63
+
A --> A: Handle the sign-in callback and<br/>the user is now authenticated
64
+
```
65
+
66
+
With the proxy in place, you can now develop and test your custom sign-in UI locally, without needing to upload the assets to Logto Cloud every time you make a change.
67
+
68
+
## Instructions
69
+
70
+
### Step 1: Execute the command
71
+
72
+
Assuming your Cloud tenant ID is `foobar`, and you have a custom sign-in page running on your local dev server at `http://localhost:4000`.
If all set up correctly, when you click the "sign-in" button in your application, you should be navigated to your custom sign-in page instead of Logto's built-in UI, along with valid session (cookies) that allows you to further interact with Logto experience API.
0 commit comments