Skip to content

Conversation

@olivaresf
Copy link
Contributor

@olivaresf olivaresf commented Dec 4, 2025

Based on #1766, working my way to making a fully native experience possible:

  • Allow magic links to be sent via API request
  • Allow code to be submitted via API request
  • Authenticate web views given an access token
  • Clean up
  • Unit tests for each endpoint
  • Security audit for access token -> web view

@olivaresf olivaresf requested review from jayohms and monorkin December 4, 2025 23:11
@jyroscoped
Copy link

  • I would recommend extracting the rate_limit_exceeded_message string into a constant or locale file, as it's duplicated across both controllers and might need to be updated in multiple places.
  • The safe navigation operator usage in Sessions::SessionsController#create with identity&.send_magic_link could mask issues—consider whether silently failing to send a magic link when the identity doesn't exist is the intended behavior, or if you should handle this case more explicitly.
  • In respond_to_valid_code_from, creating an access token and rendering user data in the JSON response assumes the API client should receive sensitive information immediately after authentication. I would recommend documenting the security implications or reconsidering what data gets exposed in this endpoint.
  • The rate_limit_exceeded method is now duplicated between Sessions::MagicLinksController and SessionsController. I would recommend extracting this into a shared concern or module to reduce duplication.
  • In Sessions::SessionsController#create, the HTML format still calls serve_development_magic_link(magic_link) even when magic_link is nil (if identity doesn't exist). This could cause unexpected behavior—I would recommend adding a guard clause or handling the nil case explicitly.
  • The X-Magic-Link-Code header is being set in the JSON response only in development, which is fine for development workflows, but I would recommend documenting this behavior clearly to prevent accidental exposure in production.

1 similar comment
@jyroscoped
Copy link

  • I would recommend extracting the rate_limit_exceeded_message string into a constant or locale file, as it's duplicated across both controllers and might need to be updated in multiple places.
  • The safe navigation operator usage in Sessions::SessionsController#create with identity&.send_magic_link could mask issues—consider whether silently failing to send a magic link when the identity doesn't exist is the intended behavior, or if you should handle this case more explicitly.
  • In respond_to_valid_code_from, creating an access token and rendering user data in the JSON response assumes the API client should receive sensitive information immediately after authentication. I would recommend documenting the security implications or reconsidering what data gets exposed in this endpoint.
  • The rate_limit_exceeded method is now duplicated between Sessions::MagicLinksController and SessionsController. I would recommend extracting this into a shared concern or module to reduce duplication.
  • In Sessions::SessionsController#create, the HTML format still calls serve_development_magic_link(magic_link) even when magic_link is nil (if identity doesn't exist). This could cause unexpected behavior—I would recommend adding a guard clause or handling the nil case explicitly.
  • The X-Magic-Link-Code header is being set in the JSON response only in development, which is fine for development workflows, but I would recommend documenting this behavior clearly to prevent accidental exposure in production.

@olivaresf
Copy link
Contributor Author

Thanks for your feedback! This is a WIP and isn't ready yet 😄

@monorkin monorkin force-pushed the mobile/native-log-in branch 2 times, most recently from aaa225a to b74d8b0 Compare December 5, 2025 10:25
@monorkin monorkin force-pushed the mobile/native-log-in branch 3 times, most recently from 5dbbcaa to 4c62455 Compare December 5, 2025 10:59
@monorkin
Copy link
Contributor

monorkin commented Dec 5, 2025

@olivaresf seems like you don't have your email address added to Github so it doesn't show proper attribution on your commits.
(After rebasing, they look like I made them, but that should fix itself after you add your email address)

@monorkin
Copy link
Contributor

monorkin commented Dec 5, 2025

I pushed a few small changes and added comments to point them out.

@olivaresf olivaresf force-pushed the mobile/native-log-in branch from 9462b97 to af9c1b6 Compare December 5, 2025 21:24
@monorkin monorkin force-pushed the mobile/native-log-in branch from ad62957 to 558f9ca Compare December 9, 2025 14:14
@monorkin monorkin force-pushed the basic-api branch 2 times, most recently from 3f17434 to 79e77a3 Compare December 10, 2025 08:24
olivaresf and others added 8 commits December 10, 2025 09:31
The identity endpoint can be used to fetch that information
We had a call about this. In short, we could reuse access tokens but then the user would see access tokens for every mobile device they have without any indication as to what is going on. So, since this really is just logging in instead of an integration which seems to be the primary purpose of access tokens, we can just use our regular session cookie for authentication.
@monorkin monorkin force-pushed the mobile/native-log-in branch from 558f9ca to f35690b Compare December 10, 2025 08:38
Base automatically changed from basic-api to main December 10, 2025 14:44
@olivaresf olivaresf force-pushed the mobile/native-log-in branch from 1b15f41 to f35690b Compare December 10, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants