Skip to content

Commit 5eca377

Browse files
committed
Merge branch 'ga' of github.com:Azure/static-web-apps-cli into ga
2 parents a0258b4 + d003665 commit 5eca377

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/www/docs/cli/local-auth.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
sidebar_position: 9
3+
title: Local Authentication
4+
---
5+
6+
The CLI allows to mock and read authentication and authorization credentials.
7+
8+
### Mocking credentials
9+
10+
When requesting the Static Web Apps login endpoints (`http://localhost:4280/.auth/login/<PROVIDER_NAME>`), you have access to a local authentication UI. This interface is served locally from the emulator and allows you to set fake user information for the current user from the provider supplied.
11+
12+
### Reading credentials
13+
14+
The front-end application can request the `http://localhost:4280/.auth/me` endpoint and a `clientPrincipal` containing the fake information will be returned by the authentication API.
15+
16+
Here is an example:
17+
18+
```json
19+
{
20+
"clientPrincipal": {
21+
"identityProvider": "twitter",
22+
"userId": "<USER-UUID>",
23+
"userDetails": "<USER_NAME>",
24+
"userRoles": ["anonymous", "authenticated"],
25+
"claims": [
26+
{
27+
"typ": "name",
28+
"val": "Azure Static Web Apps"
29+
}
30+
]
31+
}
32+
}
33+
```
34+
35+
The API functions can access user information using the `x-ms-client-principal` header.
36+
37+
See [Accessing user information](https://docs.microsoft.com/azure/static-web-apps/user-information) documentation for more details.

0 commit comments

Comments
 (0)