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

Api authentication with tokens #97

Merged
merged 23 commits into from
Dec 11, 2024
Merged

Api authentication with tokens #97

merged 23 commits into from
Dec 11, 2024

Conversation

PizieDust
Copy link
Collaborator

@PizieDust PizieDust commented Dec 8, 2024

closes #38

This PR introduces many changes, including a refactoring of how we check for csrf tokens.
In this PR:

  • We can now have both session authentication and api token authentication (both stateful and stateless)
  • Routes which change state are all converted to POST requests so that we can do the appropriate verifications.

The following endpoints can be accessed via the API

  • /api/volume/delete
  • /api/volume/create
  • /api/volume/download
  • /api/volume/upload
  • /api/unikernel/destroy
  • /api/unikernel/restart
  • /api/unikernel/create

@PizieDust PizieDust requested a review from hannesm December 8, 2024 14:43
@PizieDust PizieDust self-assigned this Dec 8, 2024
middleware.ml Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
unikernel.ml Show resolved Hide resolved
unikernel.ml Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
@hannesm
Copy link
Contributor

hannesm commented Dec 9, 2024

One question I have is: which endpoints should be accessible with an API token? All of them? As many as possible? Or is there a plan / strategy which endpoints?

I.e. does a "change password" endpoint make sense to be available with a token? The underlying question is as well what permission does a token have / should a user when creating a token assign permissions to it? These are open design questions.

@PizieDust
Copy link
Collaborator Author

One question I have is: which endpoints should be accessible with an API token? All of them? As many as possible? Or is there a plan / strategy which endpoints?

I.e. does a "change password" endpoint make sense to be available with a token? The underlying question is as well what permission does a token have / should a user when creating a token assign permissions to it? These are open design questions.

I think the endpoints that should be accessible with the token should be endpoints that do anything with albatross (creating a unikernel, volumes, destroying them etc) and maybe requesting new tokens.

For other activities, I think these should only be done via the dashboard

@PizieDust PizieDust requested a review from hannesm December 9, 2024 13:50
@PizieDust
Copy link
Collaborator Author

One question I have is: which endpoints should be accessible with an API token? All of them? As many as possible? Or is there a plan / strategy which endpoints?

I.e. does a "change password" endpoint make sense to be available with a token? The underlying question is as well what permission does a token have / should a user when creating a token assign permissions to it? These are open design questions.

We can add permissions to the tokens, I think that's a great idea, I can have another PR with that

@hannesm
Copy link
Contributor

hannesm commented Dec 10, 2024

I think the endpoints that should be accessible with the token should be endpoints that do anything with albatross (creating a unikernel, volumes, destroying them etc) and maybe requesting new tokens.

I completely agree, and would appreciate if we add - in this PR - a flag for authenticate ~token_is_ok:bool. Please let us not dive into the potential permission implementations.

I would not add requesting new tokens to the set of endpoints that can be done with a token.

To be more explicit, I'd guess the following endpoints are fine with a token:

  • /api/volume/delete
  • /api/volume/create
  • /api/volume/download
  • /api/volume/upload
  • /api/unikernel/destroy
  • /api/unikernel/restart
  • /api/unikernel/create

Would you agree? Is there something missing?

@PizieDust
Copy link
Collaborator Author

I think the endpoints that should be accessible with the token should be endpoints that do anything with albatross (creating a unikernel, volumes, destroying them etc) and maybe requesting new tokens.

I completely agree, and would appreciate if we add - in this PR - a flag for authenticate ~token_is_ok:bool. Please let us not dive into the potential permission implementations.

I would not add requesting new tokens to the set of endpoints that can be done with a token.

To be more explicit, I'd guess the following endpoints are fine with a token:

  • /api/volume/delete
  • /api/volume/create
  • /api/volume/download
  • /api/volume/upload
  • /api/unikernel/destroy
  • /api/unikernel/restart
  • /api/unikernel/create

Would you agree? Is there something missing?

This sounds great. I definitely agree

unikernel.ml Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
unikernel.ml Outdated Show resolved Hide resolved
PizieDust and others added 7 commits December 11, 2024 17:30
Co-authored-by: Hannes Mehnert <[email protected]>
Co-authored-by: Hannes Mehnert <[email protected]>
Co-authored-by: Hannes Mehnert <[email protected]>
Co-authored-by: Hannes Mehnert <[email protected]>
Co-authored-by: Hannes Mehnert <[email protected]>
@hannesm hannesm merged commit f16ceb8 into main Dec 11, 2024
2 checks passed
@hannesm hannesm deleted the api_auth branch December 11, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

REST API
3 participants