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

Resolved issue where user API keys needed admin role #589

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/src/components/pages/APIKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const SingleKey = ({ token, permissions, onDelete }: SingleKeyProps) => {
</Button>
<Button
onClick={() => setIsKeyVisible(!isKeyVisible)}
variant="default"
variant="outline"
>
{isKeyVisible ? "Hide" : "Show Key"}
</Button>
Expand Down Expand Up @@ -150,7 +150,7 @@ const APIKeys = () => {

return (
<RequireAuthentication>
<div className="container mx-auto max-w-4xl shadow-md rounded-lg bg-gray-1 text-gray-12 border bg-card text-card-foreground relative">
<div className="container mx-auto max-w-4xl shadow-md rounded-lg bg-gray-12 text-gray-2 border bg-card text-card-foreground relative">
<div className="p-6">
<h1 className="text-3xl font-extrabold mb-4">API Keys</h1>
{apiKeys === null ? (
Expand Down Expand Up @@ -191,7 +191,7 @@ const APIKeys = () => {
</label>
<Button
onClick={createKey}
variant="default"
variant="outline"
disabled={creatingKey}
>
Create {readonly ? "Read-only " : "Read-write "}Key
Expand Down
8 changes: 4 additions & 4 deletions store/app/routers/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from store.app.db import Crud
from store.app.model import APIKeyPermission, User
from store.app.security.user import get_session_user_with_admin_permission
from store.app.security.user import get_session_user

logger = logging.getLogger(__name__)

Expand All @@ -34,7 +34,7 @@ class NewKeyResponse(BaseModel):
@router.post("/new", response_model=NewKeyResponse)
async def new_key(
data: NewKeyRequest,
user: Annotated[User, Depends(get_session_user_with_admin_permission)],
user: Annotated[User, Depends(get_session_user)],
crud: Annotated[Crud, Depends(Crud.get)],
) -> NewKeyResponse:
api_key = await crud.add_api_key(
Expand All @@ -54,7 +54,7 @@ class ListKeysResponse(BaseModel):

@router.get("/list", response_model=ListKeysResponse)
async def list_keys(
user: Annotated[User, Depends(get_session_user_with_admin_permission)],
user: Annotated[User, Depends(get_session_user)],
crud: Annotated[Crud, Depends(Crud.get)],
) -> ListKeysResponse:
keys = await crud.list_api_keys(user.id)
Expand All @@ -72,7 +72,7 @@ async def list_keys(
@router.delete("/delete/{key}")
async def delete_key(
key: str,
user: Annotated[User, Depends(get_session_user_with_admin_permission)],
user: Annotated[User, Depends(get_session_user)],
crud: Annotated[Crud, Depends(Crud.get)],
) -> None:
await crud.delete_api_key(key)
Loading