Skip to content
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

User Impersonation in SaaS with Ember.js and Ruby on Rails #81

Merged

Conversation

BradLeftley
Copy link
Contributor

No description provided.


## [User Impersonation in SaaS with Ember.js and Ruby on Rails 🐹](https://codeandtechno.com/posts/user-impersonation-ember-simple-auth-doorkeeper/)

When developing applications it is important to be able to log in as one of your users and see exactly what they see. This can help debugging issues and aid your support team in assisting users.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might suggest that user impersonation is important for SaaS products: "When developing SaaS (software as a service) applications, it is important [...]".


When developing applications it is important to be able to log in as one of your users and see exactly what they see. This can help debugging issues and aid your support team in assisting users.

[@matixmatix](https://github.com/matixmatix) has created a awesome tutorial on how this can be done using Ember.js ([Ember Simple Auth](https://ember-simple-auth.com/) with Ruby on Rails (with [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) gem FOR 0Auth2).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"a awesome" -> "an awesome"
"gem FOR 0Auth2" -> "gem for OAuth2"


[@matixmatix](https://github.com/matixmatix) has created a awesome tutorial on how this can be done using Ember.js ([Ember Simple Auth](https://ember-simple-auth.com/) with Ruby on Rails (with [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) gem FOR 0Auth2).

Achieving this is fairly simple process. Once the client is exchanging username and password for an access token we then call this 0Auth 2.0 Password grant flow. Then to impersonate a user we then create a new token by bypassing the part where the password is used. Then by asking DoorKeeper to issue a new token for the provided user directly. Now we have a token we then create a new authenticator by extending the existing 0Auth2 authorizer, so we can pass the tokenData directly to our Ember app.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explaining OAuth2 isn't easy (there's always that diagram that confuses me), so good job summarizing the important steps!

For clarity, I might suggest the following:

"Achieving this is a fairly simple process. Normally, a client exchanges their username and password for an access token. To impersonate that user, we would need to create the token without the user's password. We can ask DoorKeeper to issue a new token for the provided user directly. Lastly, we update our existing OAuth2 authorizer so that we can pass the token (instead of password) to log in as that user."


Achieving this is fairly simple process. Once the client is exchanging username and password for an access token we then call this 0Auth 2.0 Password grant flow. Then to impersonate a user we then create a new token by bypassing the part where the password is used. Then by asking DoorKeeper to issue a new token for the provided user directly. Now we have a token we then create a new authenticator by extending the existing 0Auth2 authorizer, so we can pass the tokenData directly to our Ember app.

Read [@matixmatix](https://github.com/matixmatix) full [tutorial](https://codeandtechno.com/posts/user-impersonation-ember-simple-auth-doorkeeper/) to get started!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put an apostrophe after the name? "matixmatix's"


When developing SaaS (software as a service) applications, it is important to be able to log in as one of your users and see exactly what they see. This can help debugging issues and aid your support team in assisting users.

[@matixmatix](https://github.com/matixmatix) has created an awesome tutorial on how this can be done using Ember.js ([Ember Simple Auth](https://ember-simple-auth.com/) with Ruby on Rails (with [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) gem for 0Auth2).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BradLeftley One more correction: "0Auth2" to "OAuth2" (you used the number 0). Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted :)

Copy link
Member

@amyrlam amyrlam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks Brad for the writeup! And @ijlee2 for the review!

I'm wondering why the Netlify preview doesn't show up, maybe because it's from a fork?

@amyrlam amyrlam added the embertimes PR for an Ember Times issue label Apr 17, 2019
@amyrlam amyrlam merged commit 55e92ff into ember-learn:blog/embertimes-94 Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embertimes PR for an Ember Times issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants