-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: CustomHref
and update react-spa example
#154
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kmherrmann This might be what you wanted a couple months ago 😅
The reason why you got cookie problems when testing out the OAuth flows were that the link generated by the SDK was always on the project slug URL and never localhost. This means you set OAuth cookies on the oryapis.com domain instead of localhost.