Skip to content

Api bump last login#640

Open
simonLeary42 wants to merge 14 commits intomainfrom
api-bump-last-login
Open

Api bump last login#640
simonLeary42 wants to merge 14 commits intomainfrom
api-bump-last-login

Conversation

@simonLeary42
Copy link
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://127.0.0.1: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://127.0.0.1:8000/lan/api/bump-last-login.php?uid=user1_org1_test'
$ curl 'http://127.0.0.1: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. I didn't want to use 127.0.0.1, since that address could conceivably be used in production. Instead, I set ServerName and UseCanonicalName and switched the code over from HTTP_HOST to SERVER_NAME.

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

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 from 8105221 to 7213015 Compare March 6, 2026 17:04
@simonLeary42 simonLeary42 force-pushed the api-bump-last-login branch 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
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