Skip to content

Api bump last login#640

Merged
simonLeary42 merged 3 commits intomainfrom
api-bump-last-login
Mar 18, 2026
Merged

Api bump last login#640
simonLeary42 merged 3 commits intomainfrom
api-bump-last-login

Conversation

@simonLeary42
Copy link
Copy Markdown
Member

@simonLeary42 simonLeary42 commented Mar 5, 2026

adds an API endpoint where you can HTTP POST to bump the last login timestamp of a user. Requires an API key.

$ curl 'http://account-portal-docker-web:8000/lan/api/expiry.php?uid=user1_org1_test'; echo ""
{"uid":"user1_org1_test","idlelock_date":"1970/08/09","disable_date":"1971/02/05"}
$ curl -X POST -H 'Authorization: Bearer dev_environment_api_key' 'http://account-portal-docker-web:8000/lan/api/bump-last-login.php?uid=user1_org1_test'
$ curl 'http://account-portal-docker-web:8000/lan/api/expiry.php?uid=user1_org1_test'; echo ""
{"uid":"user1_org1_test","idlelock_date":"2026/10/12","disable_date":"2027/04/10"}

To demonstrate this, I needed to add an API key that runs in the docker dev environment. To do that, I needed another config override. To produce the above example, I used a DNS mapping in /etc/hosts to change the value of HTTP_HOST so that it would use this new override.

@simonLeary42 simonLeary42 requested a review from Copilot March 5, 2026 19:54
Copy link
Copy Markdown
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

Adds a new authenticated API endpoint to “bump” a user’s last-login timestamp and wires up test support/configuration for Bearer tokens.

Changes:

  • Introduced webroot/lan/api/bump-last-login.php endpoint guarded by a new UnityHTTPD::validateAPIKey() helper.
  • Extended PHPUnit HTTP helpers to send Authorization: Bearer ... headers.
  • Added functional coverage + config entries for API keys.

Reviewed changes

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

Show a summary per file
File Description
webroot/lan/api/bump-last-login.php New POST endpoint that validates API key and records a login event for a UID
resources/lib/UnityHTTPD.php Adds Bearer-token API key validation helper
test/phpunit-bootstrap.php Extends http helpers to inject Bearer token + renames http_get param
test/functional/BumpLastLoginApiTest.php Functional test for bump-last-login endpoint
deployment/overrides/phpunit/config/config.ini Adds [api]keys for PHPUnit environment
defaults/config.ini.default Documents [api]keys config option
CHANGELOG.md Notes new config option for API keys

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

@simonLeary42 simonLeary42 requested a review from bryank-cs March 5, 2026 19:58
@simonLeary42 simonLeary42 mentioned this pull request Mar 5, 2026
@simonLeary42 simonLeary42 force-pushed the api-bump-last-login branch from da9388f to d04c7a5 Compare March 5, 2026 20:27
@simonLeary42 simonLeary42 marked this pull request as draft March 5, 2026 20:30
@simonLeary42 simonLeary42 marked this pull request as draft March 5, 2026 20:30
@simonLeary42 simonLeary42 force-pushed the api-bump-last-login branch 2 times, most recently from 101d402 to 7663b22 Compare March 6, 2026 17:51
@simonLeary42 simonLeary42 requested a review from bryank-cs March 6, 2026 17:58
@simonLeary42 simonLeary42 marked this pull request as ready for review March 6, 2026 17:58
@simonLeary42 simonLeary42 marked this pull request as draft March 6, 2026 17:58
@simonLeary42 simonLeary42 marked this pull request as ready for review March 6, 2026 18:00
@simonLeary42 simonLeary42 marked this pull request as draft March 6, 2026 18:10
@simonLeary42 simonLeary42 force-pushed the api-bump-last-login branch from 42b7d00 to e62e286 Compare March 6, 2026 18:12
@simonLeary42 simonLeary42 marked this pull request as ready for review March 6, 2026 18:21
@simonLeary42
Copy link
Copy Markdown
Member Author

I tested out this theory that HTTP_HOST is insecure, and it's actually fine.

I added a mapping to my /etc/hosts so that the domain name phpstan maps to the production account portal, and then I tricked the discovery service into allowing my return path, and I got this:

image

@simonLeary42 simonLeary42 force-pushed the api-bump-last-login branch 3 times, most recently from 8ca6bd7 to 4e68abb Compare March 16, 2026 15:41
@simonLeary42 simonLeary42 merged commit be03031 into main Mar 18, 2026
3 checks passed
@simonLeary42 simonLeary42 deleted the api-bump-last-login branch March 18, 2026 13:20
@simonLeary42 simonLeary42 mentioned this pull request Mar 24, 2026
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.

3 participants