-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate with Neon Users Service (#33)
# Description Update `client_manager` to use `mq_connector` for authentication via `neon-users-service` Update tokens to include more data, maintaining backwards-compat and adding `TokenConfig` compat. Update tokens for Klat token compat Update permissions handling to respect user configuration values Update auth request to include token_name for User database integration Add UserProfile.from_user_config for database compat. Update MQ connector to integrate with users service # Issues <!-- If this is related to or closes an issue/other PR, please note them here --> # Other Notes This includes breaking changes to JWT handling. Existing tokens do not follow [RFC7519](https://datatracker.ietf.org/doc/html/rfc7519#section-4.1); these changes update token contents to use Registered and Public Claim names where available. This includes a change to permissions handling by using roles defined in [neon-data-models](https://github.com/NeonGeckoCom/neon-data-models). The affected code has not been included in a stable release and behavior is unchanged when interacting with the HTTP endpoints. --------- Co-authored-by: Mike <mike@graywind.org>
- Loading branch information
1 parent
1cc78f6
commit d387765
Showing
21 changed files
with
596 additions
and
516 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
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
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,48 @@ | ||
# NEON AI (TM) SOFTWARE, Software Development Kit & Application Development System | ||
# All trademark and other rights reserved by their respective owners | ||
# Copyright 2008-2024 Neongecko.com Inc. | ||
# BSD-3 | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from this | ||
# software without specific prior written permission. | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
from fastapi import APIRouter, Depends | ||
from neon_hana.app.dependencies import jwt_bearer, mq_connector | ||
from neon_hana.schema.user_requests import GetUserRequest, UpdateUserRequest | ||
from neon_data_models.models.user import User | ||
|
||
user_route = APIRouter(tags=["user"], dependencies=[Depends(jwt_bearer)]) | ||
|
||
|
||
@user_route.post("/get") | ||
async def get_user(request: GetUserRequest, | ||
token: str = Depends(jwt_bearer)) -> User: | ||
hana_token = jwt_bearer.client_manager.get_token_data(token) | ||
return mq_connector.read_user(access_token=hana_token, | ||
auth_user=hana_token.sub, | ||
**dict(request)) | ||
|
||
|
||
@user_route.post("/update") | ||
async def update_user(request: UpdateUserRequest, | ||
token: str = Depends(jwt_bearer)) -> User: | ||
return mq_connector.update_user(access_token=token, | ||
**dict(request)) |
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
Oops, something went wrong.