Skip to content

Conversation

@justinc1
Copy link
Contributor

@justinc1 justinc1 commented Sep 11, 2025

The PR uses refresh_token to obtain a new access token when access token for AAP expires. The clusters.yaml file needs to be contain in addition to access_token also refresh_token, client_id and client_secret.

The PR will store OAuth2 client_secret and refresh_token to DB (in addition to existing access_token). All three are encrypted.

The API endpoint for token refresh changes from AAP 2.5 to 2.6. AAP version detection uses ping endpoint to detect version. The ping endpoint does not require authentication.

A helper command getclusters is added. It is a debugging aid, it dumps token to screen in plaintext.

To test this:

  • in clusters.yml set access_token to invalid value

  • run python manage.py setclusters <path to yaml file>

  • run python manage.py run_dispatcher

  • run python manage.py syncdata --since 2025-09-10 --until 2025-09-11

  • now run_dispatcher shows:

    ERROR 2025-09-11 11:26:51,367 connector 238275 123340344852608 GET request failed with status 401
    ...
    INFO 2025-09-11 11:26:51,720 connector 238275 123340344852608 Token refresh POST request succeeded with status 200
    
  • run podman exec -it automation-dashboard-web /venv/bin/python ./manage.py getclusters --decrypt, it will show you your new access and refresh token.

I did test this with AAP 2.4 and with AAP 2.6.

Documentation update is needed.

@justinc1 justinc1 requested a review from kcagran September 11, 2025 11:54
@github-actions
Copy link

github-actions bot commented Sep 11, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
4833 3646 75% 0% 🟢

New Files

File Coverage Status
src/backend/apps/clusters/management/commands/getclusters.py 0% 🟢
src/backend/apps/clusters/migrations/0016_alter_cluster_aap_version.py 0% 🟢
TOTAL 0% 🟢

Modified Files

File Coverage Status
src/backend/apps/clusters/connector.py 74% 🟢
src/backend/apps/clusters/encryption.py 94% 🟢
src/backend/apps/clusters/management/commands/setclusters.py 0% 🟢
src/backend/apps/clusters/models.py 87% 🟢
src/backend/apps/clusters/schemas.py 100% 🟢
src/backend/tests/unit/test_connector.py 100% 🟢
TOTAL 76% 🟢

updated for commit: a349e4b by action🐍

@justinc1 justinc1 self-assigned this Sep 11, 2025
@justinc1 justinc1 force-pushed the refresh-token branch 5 times, most recently from afad504 to 1c7b10d Compare October 23, 2025 14:28
@justinc1 justinc1 marked this pull request as ready for review October 23, 2025 14:32
@AlexSCorey
Copy link
Member

@justinc1 Do we have an issue tracking the need to update the docs?

@justinc1
Copy link
Contributor Author

justinc1 commented Oct 28, 2025

@justinc1 justinc1 changed the title Refresh access_token AAP-55571 Refresh access_token Oct 28, 2025
Requires client_id and client_secret.

Signed-off-by: Justin Cinkelj <[email protected]>

# Conflicts:
#	clusters.example.yaml
#	src/backend/apps/clusters/models.py
It allows checking token values.

Signed-off-by: Justin Cinkelj <[email protected]>
Signed-off-by: Justin Cinkelj <[email protected]>
The value depends on encryption key.

Signed-off-by: Justin Cinkelj <[email protected]>
@ShaiahWren
Copy link
Contributor

@justinc1 could you rebase this branch on top of main? Thank you! :)

@SherinV
Copy link
Contributor

SherinV commented Nov 7, 2025

cursor review

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.

5 participants