Skip to content

Chore: stop using our API internally - #1683

Merged
nhoening merged 14 commits into
mainfrom
chore/stop-using-API-internally
Sep 8, 2025
Merged

nhoening merged 14 commits into
mainfrom
chore/stop-using-API-internally

Conversation

@nhoening

@nhoening nhoening commented Aug 29, 2025 •

Copy link
Copy Markdown
Member

Description

Stop calling the API from Python (UI views). It was confusing and can cause ghost bugs (see issue).

  • Stop using it in account views
  • Stop using it in asset views
  • Stop using it in users views
  • Remove InternalApi class altogether
  • Added changelog item in documentation/changelog.rst

Look & Feel

The pages should still feel the same.

Only on the /users/ID endpoint, we are fixing an unnecessarily strong restriction: we are actually allowing other people than just admins to view it. This enables consultants to actually load user pages.

How to test

Click around, run the tests.

Think: do we do the authorization well / as good as before?

Further Improvements

...

Related Items

Closes #1682

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening nhoening added this to the 0.28.0 milestone Aug 29, 2025
@nhoening nhoening added the UI label Aug 29, 2025
@read-the-docs-community

read-the-docs-community Bot commented Aug 29, 2025 •

Copy link
Copy Markdown

@Flix6x

Flix6x commented Aug 30, 2025

Copy link
Copy Markdown
Member

If you want to ensure the same auth mechanism as before, shouldn't the InternalAPI be replaced with ajax calls rather than having the UI views bypass the API?

@nhoening

Copy link
Copy Markdown
Member Author

I guess we can get there one day if we want. But the way there is still long. We already did a lot of work, but need to focus.

This can be done rather fast, and it is needed now as new potential community members are blocked.

Also, we have still one auth layer, everything is done via check_access()

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
… before edit test

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
… page for a user, one new service utility now shared by API and UI views, removed mocks from tests

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…ures/flexmeasures into chore/stop-using-API-internally
@nhoening
nhoening requested review from Muhammad-Moiz626 and joshuaunity and removed request for joshuaunity September 4, 2025 22:00

@Muhammad-Moiz626 Muhammad-Moiz626 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall the UI does not seem to be breaking for me as I went through the pages by clicking around and creating/editing/deleting sensors as well.

Comment thread .vscode/spellright.dict Resolved
@nhoening

nhoening commented Sep 7, 2025 •

Copy link
Copy Markdown
Member Author

Overall the UI does not seem to be breaking for me as I went through the pages by clicking around and creating/editing/deleting sensors as well.

Thanks.
Have you checked that I kept the needed permissions at the same intended level as it was when we used the API?

@Muhammad-Moiz626 Muhammad-Moiz626 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall the code looks good to me with one small comment. Otherwise I'm okay with merging it.

Comment thread flexmeasures/ui/views/users/views.py Resolved
…h functions which use this already do their own check_access() call.

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

@Muhammad-Moiz626 Muhammad-Moiz626 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks.

@nhoening
nhoening merged commit 363375f into main Sep 8, 2025
@nhoening
nhoening deleted the chore/stop-using-API-internally branch September 8, 2025 15:43
@Flix6x Flix6x mentioned this pull request Sep 12, 2025
2 tasks done
Flix6x added a commit that referenced this pull request Nov 5, 2026
… passwords on a GET, and check access on UI pages

On 1.0.x, GET /assets/delete_with_data/<id> deleted any asset, with its data, for any logged-in user,
as it called the asset service without the permission check the API does (since #1683, in v0.28.0).
The asset page's delete button and the reset-password buttons now call the API instead,
and the UI routes that acted on a GET are gone, so a link on another site cannot trigger them either.
The sensor page, the user audit log page and the page listing an organisation's assets now check access,
and the account audit log page follows the audit log's own access rule, as on main.

See GHSA-vmgf-59hm-j9m7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop using InternalAPI

3 participants