-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'introduce-vip-models-pricing-4-part' of github.com:matu…
…sdrobuliak66/osparc-simcore into introduce-vip-models-pricing-4-part
- Loading branch information
Showing
40 changed files
with
1,381 additions
and
836 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from typing import Annotated | ||
|
||
from fastapi import APIRouter, Depends, status | ||
from models_library.api_schemas_webserver.auth import ( | ||
ApiKeyCreateRequest, | ||
ApiKeyCreateResponse, | ||
ApiKeyGet, | ||
) | ||
from models_library.generics import Envelope | ||
from models_library.rest_error import EnvelopedError | ||
from simcore_service_webserver._meta import API_VTAG | ||
from simcore_service_webserver.api_keys._exceptions_handlers import _TO_HTTP_ERROR_MAP | ||
from simcore_service_webserver.api_keys._rest import ApiKeysPathParams | ||
|
||
router = APIRouter( | ||
prefix=f"/{API_VTAG}", | ||
tags=["auth"], | ||
responses={ | ||
i.status_code: {"model": EnvelopedError} for i in _TO_HTTP_ERROR_MAP.values() | ||
}, | ||
) | ||
|
||
|
||
@router.post( | ||
"/auth/api-keys", | ||
operation_id="create_api_key", | ||
status_code=status.HTTP_201_CREATED, | ||
response_model=Envelope[ApiKeyCreateResponse], | ||
) | ||
async def create_api_key(_body: ApiKeyCreateRequest): | ||
"""creates API keys to access public API""" | ||
|
||
|
||
@router.get( | ||
"/auth/api-keys", | ||
operation_id="list_api_keys", | ||
response_model=Envelope[list[ApiKeyGet]], | ||
status_code=status.HTTP_200_OK, | ||
) | ||
async def list_api_keys(): | ||
"""lists API keys by this user""" | ||
|
||
|
||
@router.get( | ||
"/auth/api-keys/{api_key_id}", | ||
operation_id="get_api_key", | ||
response_model=Envelope[ApiKeyGet], | ||
status_code=status.HTTP_200_OK, | ||
) | ||
async def get_api_key(_path: Annotated[ApiKeysPathParams, Depends()]): | ||
"""returns the API Key with the given ID""" | ||
|
||
|
||
@router.delete( | ||
"/auth/api-keys/{api_key_id}", | ||
operation_id="delete_api_key", | ||
status_code=status.HTTP_204_NO_CONTENT, | ||
) | ||
async def delete_api_key(_path: Annotated[ApiKeysPathParams, Depends()]): | ||
"""deletes the API key with the given ID""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
# | ||
# core --- | ||
"_auth", | ||
"_auth_api_keys", | ||
"_groups", | ||
"_tags", | ||
"_tags_groups", # after _tags | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
35 changes: 35 additions & 0 deletions
35
packages/models-library/src/models_library/rpc/webserver/auth/api_keys.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import datetime as dt | ||
from typing import Annotated | ||
|
||
from models_library.basic_types import IDStr | ||
from pydantic import BaseModel, ConfigDict, Field | ||
|
||
|
||
class ApiKeyCreate(BaseModel): | ||
display_name: Annotated[str, Field(..., min_length=3)] | ||
expiration: dt.timedelta | None = None | ||
|
||
model_config = ConfigDict( | ||
from_attributes=True, | ||
) | ||
|
||
|
||
class ApiKeyGet(BaseModel): | ||
id: IDStr | ||
display_name: Annotated[str, Field(..., min_length=3)] | ||
api_key: str | None = None | ||
api_secret: str | None = None | ||
|
||
model_config = ConfigDict( | ||
from_attributes=True, | ||
json_schema_extra={ | ||
"examples": [ | ||
{ | ||
"id": "42", | ||
"display_name": "test-api-forever", | ||
"api_key": "key", | ||
"api_secret": "secret", | ||
}, | ||
] | ||
}, | ||
) |
Empty file.
Empty file.
Oops, something went wrong.