Skip to content

Remove Data Analytics Framework token authentication via GET/POST params. #2028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: xdmod11.0.1-access
Choose a base branch
from

Conversation

aaronweeden
Copy link
Contributor

@aaronweeden aaronweeden commented Apr 9, 2025

Description

This PR removes the ability to authenticate to the Data Analytics Framework REST API via API token in GET or POST parameters and makes it so the token must be provided via Authorization header. The GET/POST param functionality was in place for CentOS 7 to work around the Authorization header being eaten by Apache, and it is no longer needed.

These changes mean the current method of counting Data Analytics Framework requests for our reporting KPIs will no longer work (they involved reading the logs with ident = 'rest.logger.db' or ident = 'controller.log' and searching for the Bearer parameter). To correct this, this PR adds logging with a new ident = 'daf'.

This PR also updates the error messages and documentation to use consistent lowercasing of "token" and to move the duplicate error message strings into variables.

This PR also refactors some duplicated code into functions.

There is also a PR for https://github.com/ubccr/xdmod-xsede/pull/570.

Motivation and Context

Code cleanup and better practice not to have the API token in the request parameters.

Tests performed

This PR updates the token auth integration tests.

In a Docker container with the changes from this PR, I also made requests via the version of xdmod-data from ubccr/xdmod-data#68 and confirmed the logs appeared as expected, e.g.,:

+-------+---------------------+-------+----------+-----------------------------------------------------------------------------------------------------------+
| id    | logtime             | ident | priority | message                                                                                                   |
+-------+---------------------+-------+----------+-----------------------------------------------------------------------------------------------------------+
| 14122 | 2025-04-09 19:00:20 | daf   |        6 | {"message":"User 3 requested /controllers/metric_explorer.php with API token using xdmod-data Python v1.1.0.dev09"} |
| 14123 | 2025-04-09 19:00:21 | daf   |        6 | {"message":"User 3 requested /controllers/user_interface.php with API token using xdmod-data Python v1.1.0.dev09"}  |
| 14125 | 2025-04-09 19:00:21 | daf   |        6 | {"message":"User 3 requested /v1/warehouse/export/realms with API token using xdmod-data Python v1.1.0.dev09"}      |
| 14127 | 2025-04-09 19:00:22 | daf   |        6 | {"message":"User 3 requested /v1/warehouse/raw-data with API token using xdmod-data Python v1.1.0.dev09"}           |
+-------+---------------------+-------+----------+-----------------------------------------------------------------------------------------------------------+

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

@aaronweeden aaronweeden added maintenance / code quality Improvements and code cleanup. Not a new feature or enhancement to existing functionality. Category: Data Analytics Framework php Pull requests that update Php code labels Apr 9, 2025
@jpwhite4
Copy link
Member

Is this going to cause breakage / incompatibility between newer XDMoD and older python code?

@aaronweeden
Copy link
Contributor Author

Is this going to cause breakage / incompatibility between newer XDMoD and older python code?

No, every release of xdmod-data so far has put the token in both the header and the request params.

@aaronweeden aaronweeden marked this pull request as ready for review April 10, 2025 19:29
@aaronweeden aaronweeden changed the title Remove token authentication via GET/POST params. Remove Data Analytics Framework token authentication via GET/POST params. Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Data Analytics Framework maintenance / code quality Improvements and code cleanup. Not a new feature or enhancement to existing functionality. php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants