-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
CustomHref
and update react-spa example (#154)
* feat: react-spa use login_challenge * chore: cleanup
- Loading branch information
Showing
6 changed files
with
204 additions
and
19 deletions.
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 |
---|---|---|
|
@@ -17,7 +17,7 @@ Ory Elements supports integrating with: | |
- Preact | ||
- ExpressJs (experimental) | ||
|
||
### Get Started | ||
## Get Started | ||
|
||
```shell | ||
git clone --depth 1 [email protected]:ory/elements.git | ||
|
@@ -38,8 +38,83 @@ ory tunnel http://localhost:3000 --project <project-slug> --dev | |
The tunnel will now _mirror_ the Ory APIs under `http://localhost:4000` which we | ||
have explicity told our React app to use through the `VITE_ORY_SDK_URL` export. | ||
|
||
Now you can see Ory Elements in action by opening http://localhost:3000 in your | ||
browser! | ||
Now you can see Ory Elements in action by opening <http://localhost:3000> in | ||
your browser! | ||
|
||
### Ory OAuth flows | ||
|
||
Ory Network supports OAuth single sign on (SSO) flows. This is applicable to use | ||
cases where you have multiple first-party applications sharing the same user | ||
pool, e.g. sign in on app A and app B with the same credentials. | ||
|
||
Another use case is sharing user data with third party providers. In this case | ||
you are the provider and allow third party apps to sign in your users without | ||
needing access to their credentials. For example "sign in with Google", you are | ||
Google in this scenario. | ||
|
||
<https://www.ory.sh/docs/hydra/guides/custom-ui-oauth2> | ||
|
||
You can try it out locally using the following steps: | ||
|
||
1. Create an Ory Network project | ||
|
||
```shell | ||
ory create project --name "TestOAuth" | ||
``` | ||
|
||
2. Create an OAuth Client | ||
|
||
```shell | ||
ory create oauth2-client \ | ||
--project ORY_NETWORK_PROJECT_SLUG_OR_ID \ | ||
--name YOUR_CLIENT_NAME \ | ||
--grant-type authorization_code,refresh_token \ | ||
--response-type code,id_token \ | ||
--scope openid,offline \ | ||
--redirect-uri http://127.0.0.1:5555/callback | ||
``` | ||
|
||
3. Run the Ory CLI tunnel | ||
|
||
```shell | ||
ory tunnel http://localhost:3000 --dev --project <slug> | ||
``` | ||
|
||
4. Run the React application | ||
|
||
```shell | ||
export VITE_ORY_SDK_URL=http://localhost:4000 | ||
npm run dev | ||
``` | ||
|
||
5. Perform an OAuth flow | ||
|
||
This is using a test OAuth client, this would be another application / service | ||
or Ory Network project. | ||
|
||
```shell | ||
ory perform authorization-code \ | ||
--client-id ORY_CLIENT_ID \ | ||
--client-secret ORY_CLIENT_SECRET \ | ||
--project ORY_PROJECT_ID \ | ||
--port 5555 \ | ||
--scope openid,offline | ||
``` | ||
|
||
**Please take note to initiate the OAuth flow through the Ory tunnel on | ||
<http://localhost:4000> instead of your project slug oryapis URL.** | ||
|
||
For example: | ||
|
||
```diff | ||
- https://<project-slug>.projects.oryapis.com/oauth2/auth | ||
+ http://localhost:4000/oauth2/auth | ||
?audience=&client_id=77e447a8-f0b9-42dc-8d75-676a8ebf5e2e&max_age=0&nonce=mwlotcnpyfytjfwmcxsklnnm&prompt=&redirect_uri=http%3A%2F%2F127.0.0.1%3A5555%2Fcallback&response_type=code&scope=openid+offline&state=hcmykhxolygmattztdednkrs | ||
``` | ||
|
||
The reason for this is so that cookies can be set correctly on localhost. When | ||
deploying to production you will use your own domain attached to your Ory | ||
Network project. | ||
|
||
### Using and Modifying the Example | ||
|
||
|
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
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
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