Skip to content
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

Mpsk devices #749

Merged
merged 50 commits into from
Oct 3, 2024
Merged

Mpsk devices #749

merged 50 commits into from
Oct 3, 2024

Conversation

agmes4
Copy link
Member

@agmes4 agmes4 commented Sep 17, 2024

Added

  • added MPSK Clients for a user
  • added model representing MPSK Clients
  • added frontend integration for mpsk adding revoming and editing
  • added api endpoints for mpsk

Resolves #744

@agmes4 agmes4 requested a review from lukasjuhrich September 17, 2024 15:37
@agmes4 agmes4 linked an issue Sep 17, 2024 that may be closed by this pull request
Copy link
Collaborator

@lukasjuhrich lukasjuhrich left a comment

Choose a reason for hiding this comment

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

Overall, these are some high-quality changes! I've found a few details here and there, and some things you could not have known about.

pycroft/model/mpsk_client.py Outdated Show resolved Hide resolved
pycroft/lib/mpsk_client.py Outdated Show resolved Hide resolved
pycroft/model/mpsk_client.py Outdated Show resolved Hide resolved
tests/model/test_mpsk.py Outdated Show resolved Hide resolved
tests/model/test_mpsk.py Outdated Show resolved Hide resolved
web/api/v0/__init__.py Outdated Show resolved Hide resolved
web/api/v0/__init__.py Outdated Show resolved Hide resolved
web/blueprints/mpskclient/__init__.py Outdated Show resolved Hide resolved
web/blueprints/mpskclient/__init__.py Outdated Show resolved Hide resolved
web/blueprints/mpskclient/__init__.py Outdated Show resolved Hide resolved
@ibot3
Copy link
Member

ibot3 commented Sep 19, 2024

Please add a certain limit for the number of MPSK devices per user. (e.g. 50)

@agmes4
Copy link
Member Author

agmes4 commented Sep 19, 2024

I will set it to 10 dont think this should be exceeded by anyone

@ibot3
Copy link
Member

ibot3 commented Sep 19, 2024

If you choose a limit this low, there may be situations where it is not enough for a user with many devices.
Maybe add this limitation only on the API side, so that there is no limit for our admins.

@lukasjuhrich
Copy link
Collaborator

Maybe add this limitation only on the API side, so that there is no limit for our admins.

Generally in favor, but is there any technical limit we should care about? or do the controllers allow arbitrarily many devices?
This should not matter since MPSK is an edge-case anyway, but I would be curious what the theoretical limit would be; every subnet is finite, anyway.

@ibot3
Copy link
Member

ibot3 commented Sep 19, 2024

Generally in favor, but is there any technical limit we should care about? or do the controllers allow arbitrarily many devices? This should not matter since MPSK is an edge-case anyway, but I would be curious what the theoretical limit would be; every subnet is finite, anyway.

Besides the subnet size, there shouldn't be a limit AFAIK.
I suggested the devices limit mainly to avoid that someone creates lots of devices (maybe hundreds, thousands) with a bad intention.

@agmes4
Copy link
Member Author

agmes4 commented Sep 19, 2024

but we dont preserve a IP for them so yeah when he has that many devices we have a problem but when he adds so much devices. Or am I missing something?

@agmes4
Copy link
Member Author

agmes4 commented Sep 19, 2024

Anyway I added now the limit of 10 devices we could set it down.

pycroft/lib/mpsk_client.py Outdated Show resolved Hide resolved
@mabezi
Copy link
Contributor

mabezi commented Sep 20, 2024

Looks pretty good to me.

Do we want to add a note in Pycroft if the user has a legacy wifi password? That could simplify debugging, but in the end it affects only very few users.

@lukasjuhrich lukasjuhrich force-pushed the MPSK_devices branch 2 times, most recently from d81dede to 9dca68e Compare September 28, 2024 09:52
@lukasjuhrich
Copy link
Collaborator

@agmes4 I've rebased on top of develop and squashed the !fixup commits (you can do this yourself with rebase -i --autosquash), as you would have done anyway. Just be aware that when pulling, you'll have to rebase on top of the new origin/MPSK_devices.

@lukasjuhrich
Copy link
Collaborator

I'm setting up the API tests. In the meantime, I found a few things to fix.
Most importantly, we're missing an API endpoint to list all of the MPSK devices ;)

@lukasjuhrich
Copy link
Collaborator

The API tests have been prepped; @agmes4 continues work and adds an endpoint for the devices.

An important feature has been suggested by @mabezi: when a user has no wifi password or a legacy password, instead of the mpsk table we should add a warning alert "user has no wifi password or a legacy password, and needs a new cleartext password to use MPSK clients".

This is only relevant for edge cases like active members or other folk with registered_at≤2020.

@lukasjuhrich
Copy link
Collaborator

Ah, also, please add lib.mpsk_client to the list of modules with strictest type checking in pyproject.toml (that is, next to lib.user

@mabezi mabezi added feature 🔨 web/ui Things relating to Flask routes and Jinja templates 🔨 db-schema Things that touch the DB schema and probably require a migration. 🔨 api labels Oct 1, 2024
agmes4 added 3 commits October 2, 2024 16:35
added a new Subsection for MPSK Clients for the creating of them

#744
added the database model for storing
added the needed functions
as well as the relation to the user and back

Signed-off-by: Alex <[email protected]>
#744
changed the name

Signed-off-by: Alex <[email protected]>
agmes4 and others added 25 commits October 2, 2024 16:35
changed the creat mpsks so that it now validates for the length of added clients

Signed-off-by: Alex <[email protected]>
#744
the api is now able to add more clients

Signed-off-by: Alex <[email protected]>
#744
Co-authored-by: Lukas Juhrich <[email protected]>
Signed-off-by: Alex <[email protected]>

#744
added the db session now as parameter
removed kargs for determining api calls
moved check for number of mpsks clients to api

Signed-off-by: Alex <[email protected]>
#744
added the type hint for Session
fixed api wrong type
Since the amount check moved from lib to API, this is not raised anymore.
This uses the data attached by the webargs handler, which is
responsible for throwing 422 unprocessable entity.

See https://webargs.readthedocs.io/en/latest/framework_support.html#error-handling

Also, note that pallets/flask#593 is now
closed, making the workaround superfluous.
This fixes a subtle parameter swap in the API call.
In that case, it returns `None` just as if the password weren't set
added same mac test, invalid password, exceeds the max clients
added delete mpsk; test not found, unauthed, successful delete

Signed-off-by: Alex <[email protected]>
#744
refactored code
renamed some error codes for better readability

Signed-off-by: Alex <[email protected]>
#744
added get mpsks clients tests

Signed-off-by: Alex <[email protected]>
#744
added api route for getting all the mpsks clients of a user

Signed-off-by: Alex <[email protected]>
#744
added test for changing the mpsk clients

Signed-off-by: Alex <[email protected]>
#744
changed the error codes for changing mpsk client so they match the ones in adding

Signed-off-by: Alex <[email protected]>
#744
added karg parameter

Signed-off-by: Alex <[email protected]>
#744
imported the pycroft.lib.mpsk_client to strict typechecking
The tablet icon was hard to idenfity.
@lukasjuhrich
Copy link
Collaborator

tests (& migration) went through locally, and ruff cannot handle a PR of this size, so merging in spite of CI.

@lukasjuhrich lukasjuhrich merged commit 5948cfe into develop Oct 3, 2024
5 of 6 checks passed
@lukasjuhrich lukasjuhrich deleted the MPSK_devices branch October 3, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🔨 api 🔨 db-schema Things that touch the DB schema and probably require a migration. 🔨 web/ui Things relating to Flask routes and Jinja templates
Projects
Development

Successfully merging this pull request may close these issues.

Add support for MPSK
4 participants