Skip to content

Conversation

@thedev132
Copy link
Member

Summary of the problem

Currently in security page we don't show where that token was created and in context of Mobile app we would like to see where we logged in (or where token was refreshed)

Describe your changes

I added an IP address field to the API Token model then doorkeeper will update the token object after a successful response with the remote IP. Added some model functions to get lat and long for security page map

@thedev132 thedev132 requested review from a team as code owners November 17, 2025 04:07
@thedev132 thedev132 requested a review from Copilot November 17, 2025 04:51
Copilot finished reviewing on behalf of thedev132 November 17, 2025 04:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds IP address tracking to API access tokens to help users see where their OAuth tokens were created or refreshed, particularly useful for mobile app authentication. The implementation captures the IP address during token creation, stores it in the database, and displays it with geolocation information on the security page.

Key Changes:

  • Added ip_address (inet) column to api_tokens table with an index
  • Configured Doorkeeper to capture and store IP addresses during token operations
  • Added geocoding methods to ApiToken model for displaying location on a map

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
db/migrate/20251117030308_add_ip_address_to_api_tokens.rb Migration adding ip_address column and index to api_tokens table
db/schema.rb Schema update reflecting the new ip_address field and index
config/initializers/doorkeeper.rb Configured custom token attributes and hook to capture IP address on successful authentication
app/models/api_token.rb Added geocoding methods (geocode_result, latitude, longitude) to retrieve location from IP
app/views/users/_oauth_authorization.erb Updated OAuth authorization view to display map and IP address for tokens

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

thedev132 and others added 4 commits November 16, 2025 20:57
@thedev132 thedev132 marked this pull request as draft November 17, 2025 05:56
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.

2 participants