
7o6hi (7o6hi) asked a question.
Integration of Okta SSO in Rails App: Authentication Flow
User Initiation:
The authentication process begins when a user initiates an Okta sign-in on Fieldwatch.
Redirect to Okta:
Fieldwatch redirects the user to Okta, initiating the authentication flow. This redirection includes parameters essential for the authentication process.
Okta Authentication:
On Okta's platform, the user undergoes authentication, which may involve providing credentials like username/email and password or employing advanced methods such as multi-factor authentication (MFA).
Successful Verification:
Upon successful verification, Okta generates an ID Token and potentially an Access Token. The ID Token contains user information and details about the authentication event.
Redirect Back to Fieldwatch:
Okta redirects the user back to Fieldwatch along with the ID Token.
Fieldwatch Verification:
Upon receiving the user back from Okta, Fieldwatch performs various verification and authorization steps.
One critical step involves checking the local database to ascertain whether the authenticated user already exists locally. In pseudo-code:
* Assuming auth.info.email contains the user's email from the ID Token
user = User.find_by(email: auth.info.email)
if user.present?
* User exists in the local database, proceed with authentication
* ...
else
* User does not exist locally, handle accordingly (e.g., prompt user to register)
* ...
Testing in Sandbox Environment:
The desired functionality has been tested in the sandbox environment. To transition to the production environment, please provide the technical steps.

I not find the code in this flow. okta should return code then use code to get id tokem or access token. mostly we only return access token, then query user info.
how can we integrate okta with rails application on production environment ?
Hi @7o6hi (7o6hi) , Thank you for reaching out to the Okta Community!
This question is more appropriate for our dedicated Okta Developer Forum.
My advice would be to reach out devforum.okta.com to take advantage of their expertise.
While we'll do our best to answer all of your questions here, this medium is more inclined towards Okta core products and features (non-developer work).
As far as I can see, there is no out of the box guide for type of implementation, however I found some reference posts/articles that may help you get started. I’ll post them bellow, but I still recommend reaching out to the Developer community for this.
https://developer.okta.com/blog/2020/09/25/easy-auth-ruby-on-rails-6-login
https://devforum.okta.com/t/okta-on-ruby-on-rails-application/22696
If my answer helped, remember to mark it as best to increase its visibility for other members of the Okta Community who might have the same questions as you.
Hope my answer helps!
--------------------------------
Earn Today: New Okta Community Badges Have Arrived