Skip to content

Conversation

jevinjojo
Copy link

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Description of Changes

  • Accept calling_station_id as an optional field in the request payload
  • Exclude the current device's session from the Simultaneous-Use count.
  • reject duplicate logins from the same device

@nemesifier nemesifier changed the title Add Calling-Station-Id support to authorize API and enhance Simultaneous-Use logic [change] Add Calling-Station-Id to authorize API to fix Simultaneous-Use Sep 29, 2025
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

It's "called_station_id", not "calling_station_id". I double checked the issue, the title was correct, but the description was incorrect.

After thinking about it again, I believe we should use both called/calling-station-id, I updated the issue description

We need a test for this, here's the scenario:

  • user has an open radius accounting
  • it tries to re-authenticate from the same client to the same NAS (same calling-station-id and called-station-id)
  • authorize succeeds

@jevinjojo
Copy link
Author

It's "called_station_id", not "calling_station_id". I double checked the issue, the title was correct, but the description was incorrect.

After thinking about it again, I believe we should use both called/calling-station-id, I updated the issue description

We need a test for this, here's the scenario:

  • user has an open radius accounting
  • it tries to re-authenticate from the same client to the same NAS (same calling-station-id and called-station-id)
  • authorize succeeds

@nemesifier I have updated the changes by accepting called_station_id, about the tests, when same device and same NAS reauth is allowed, it returns 200 Accept as expected and when Simultaneous-Use = 1 with 3 cases:

  • when a second device trying to connect while the first session is still active, expect to be 401 Reject
  • the device is already active, reauth from the same MAC and NAS is allowed. expect to be 200 Accept
  • once the session is closed, a new device is allowed to connect - 200 Accept

I wasn’t getting the 401 earlier, hadn’t linked the user to the org in the admin panel. can you test it and confirm if everything’s working as expected?

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

@jevinjojo tests and QA checks are failing, the developer docs of OpenWISP RADIUS explain how to run tests and QA checks.

Please read about our Coding Style Conventions, it explains how to fix formatting issues easily.

@jevinjojo
Copy link
Author

@nemesifier there was a flake8 warning in the test file. can we re-run the workflow.

@nemesifier
Copy link
Member

@jevinjojo the CI build will fail due to conventions for commit messages not being followed, it's not a big deal, but my understanding is that you'd like to contribute more to @openwisp, so I recommend following all the contributing best practices explained in our guidelines.

@nemesifier nemesifier changed the title [change] Add Calling-Station-Id to authorize API to fix Simultaneous-Use [feature] Add Calling-Station-Id to authorize API to fix Simultaneous-Use Oct 3, 2025
@nemesifier nemesifier changed the title [feature] Add Calling-Station-Id to authorize API to fix Simultaneous-Use [feature] Added Called/Calling-Station-Id to authorize API to fix Simultaneous-Use Oct 3, 2025
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

It looks good @jevinjojo but there's a few failing tests though so not ready yet ❌, see my comments below for some adjustments.

)

open_sessions = open_sessions.count()

Copy link
Member

Choose a reason for hiding this comment

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

Please remove all these blank lines because they provide no value.

payload["called_station_id"] = called_station_id
if calling_station_id is not None:
payload["calling_station_id"] = calling_station_id

Copy link
Member

Choose a reason for hiding this comment

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

Please remove this blank line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

[feature] Authorize view: allow receive called-station-id & calling-station-id, update Simultaneous-Use accordingly
2 participants