-
Notifications
You must be signed in to change notification settings - Fork 83
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
Use OAuth flows for login, reg, logout, change password #171
Conversation
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
@aldeed Started testing and I'm having some success and some issues:
|
@mikemurray For the first user, use this Reaction Identity branch: reactioncommerce/reaction#6002 (comment) I had forgotten to PR the change I made there. Not sure about existing customer account issue. When you sign in it should bring back to admin, and then admin should kick you back to the login form and it should stop there. I'll retest. |
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
@mikemurray This should all be working now. You will need to test with this API branch and this Identity branch |
Technically this works great so far, normal users don't get dashboard access, login as owner works. What is just weird is the redirect url I get: http://localhost:4080/?state= Something else that may be improved: Each time i close the Tab and enter again while still authenticated, the page does a redirect to hydra, therefore increasing the time until the admin is usable. |
Also it seems like the storefront hydra client and admin hydra client registrations conflict. |
@janus-reith The The ?state= URL should appear only briefly if everything is working correctly, and then you should be back on whatever page you originally landed on logged out. That, too, is entirely a You're correct that this is different from storefront in that it's being done as an SPA. Although there is currently a Meteor backend, we expect that this project will likely evolve into SPA after Meteor is removed. There is no need for SSR as there is on the storefront side. That said, I think For a good summary of the different OAuth types, see https://www.ory.sh/oauth2-for-mobile-app-spa-browser/. What we are doing here is described in the "What To Do Instead" section. I'm not sure what you mean about the client ID conflicts. The |
@aldeed Thanks, I read exactly this article some months ago when trying to get a better grasp of how oauth2 works. Also, I somehow can't reproduce the cases where I was redirected to only "?state=", it now works for both initial signups and those redirects happening after visiting again - Will keep an eye on that and report back if it happens again. But one minor issue I can still reproduce:
While probably not that common, these cases occur. |
@janus-reith For that issue, are you logging in as the same user in both? Is it an admin or customer user for each? |
@aldeed Same admin user. |
Here is a quick example that fixes this:
I used With this in place, I can have Login Flows open both for backend and frontend, and when completing the backend flow after the frontend flow the backend will redirect again and log me in The same needs to be done for the frontend on the |
@janus-reith Thanks. I'm wondering if this might be a Hydra bug that you are working around. It does seem like an easy workaround that doesn't hurt (at least on the admin side), but I don't fully understand why a user's login flow for one client would interrupt their login flow for another client. All challenges and tokens should be per-client. |
@janus-reith Since this last issue is an edge case that needs more investigation and thought, and the rest of this works, I moved your comments to a new issue here: #178 Post any further discussion there. |
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.
@aldeed Issues I'm seeing now
Admin
- After creating the first user, I'm redirected to the admin, but to the main area. I don't see the create shop form. If I refresh, then the form shows up.
- Signing in as an
admin
doesn't show the default page: This SS is what I see for both cases.
- Signing-out doesn't work if I attempt to sign out from the
Accounts
page. The URL for that page is/accounts
so that might be the problem. If the refresh wheel on the same page, I'm redirected back to the blank homepage, and If I sign out there, then it works. Even though the address bar showshttp://localhost:4080/accounts
- Reset password works, doesn't redirect on success. Not sure if it's supposed to, but this could be a ticket in the
reaction-identity
project if it should.
The first 2 issues are probably the router/react component not getting the route change notification. Maybe there's a replace
instead of a push
, or missing withRouter
decorators / useRouter
hooks.
The last one is probably due to the fact what we had a lot of pathname.startWith("/accounts")
to handle special cases. Maybe renaming the page to /manage-accounts
would fix it.
Customer
- If I register as a customer all seems to work, but I get a flash of the admin and then signed out. While no information is shown, it's would be a cleaner flow if that didn't happen. This isn't terribly critical for this release and could be another ticket.
Otherwise, things seem to works while working around these minor flow hiccups.
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
@mikemurray I added a workaround for the routing issue we discussed and simplified The workaround is a bit icky, but it works every time for me, in every browser. Everything else I tried didn't work. One result of my changes is that I'm no longer kicking "customer" users back to the login form. If you log in as a customer user, you'll see some of the UI, but no data and lots of errors. That seems fine to me for now, but in a future PR I want to implement some kind of I don't see any issues with logout on |
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.
👍
Resolves #81
Impact: breaking
Type: feature
Changes
Authorization
header with the Hydra access token instead of using the custommeteor-login-token
header.If the above is confusing to you, essentially nothing about the user experience has changed except that you'll notice that you're over on the Reaction Identity URL whenever you are logging in, registering, or changing your password.
Breaking changes
Reaction Admin UI no longer works if you don't also have Hydra and Reaction Identity services configured and running on the Docker network. This involves some new environment variables that are required (but are set correctly automatically for local development if you run
bin/setup
).Testing
Be sure to run
bin/setup
after pulling, and make sure you have the latest commit on thereaction-hydra
3.0.0 branch and the latest commit on thereaction-identity
trunk branch both running.Specifically, make sure your
reaction-hydra
.env
file has the two new variables set:Then verify all registration, login, and logout flows you can think of. Test the "Change Password" link on the profile page (click Profile in user menu).
If you log in as a non-admin user, you should be immediately logged out. If you're not logged in when you visit the Reaction Admin URL, it should kick you out to the login page.