forked from OpenG2P/openg2p-program
-
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.
Merge pull request OpenG2P#190 from Abhishek-Wagh/17.0-develop
well-known Api implementation in fastapi
- Loading branch information
Showing
10 changed files
with
49 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# Part of OpenG2P. See LICENSE file for full copyright and licensing details. | ||
from . import models | ||
from . import controllers | ||
from . import services | ||
from . import models |
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 |
---|---|---|
@@ -1 +1 @@ | ||
from . import payments | ||
from . import well_known |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
import json | ||
from typing import Annotated | ||
|
||
from fastapi import APIRouter, Depends | ||
|
||
from odoo.api import Environment | ||
|
||
from odoo.addons.fastapi.dependencies import odoo_env | ||
|
||
# create a router | ||
api_router = APIRouter() | ||
|
||
|
||
@api_router.get("/jwks.json") | ||
def get_partners(env: Annotated[Environment, Depends(odoo_env)]): | ||
CryptoKeySet = env["g2p.crypto.key.set"].sudo() | ||
key_sets = CryptoKeySet.search([("status", "=", "active")]) | ||
jwks = [json.loads(key_set.jwk) for key_set in key_sets] | ||
return {"keys": jwks} |
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,9 @@ | ||
<odoo> | ||
<!-- --> | ||
<record id="fastapi_endpoint_data" model="fastapi.endpoint"> | ||
<field name="name">payment</field> | ||
<field name="app">payment</field> | ||
<field name="root_path">/apiv1payment</field> | ||
<!-- <field name="registry_sync" eval="obj()._add_after_commit_hook([obj().id]) and False"/> --> | ||
</record> | ||
</odoo> |
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,15 @@ | ||
from odoo import fields, models | ||
|
||
from ..controllers.well_known import api_router | ||
|
||
|
||
class WellknownComponent(models.Model): | ||
_inherit = "fastapi.endpoint" | ||
app: str = fields.Selection( | ||
selection_add=[("payment", "Payment")], ondelete={"payment": "cascade"} | ||
) | ||
|
||
def _get_fastapi_routers(self): | ||
if self.app == "payment": | ||
return [api_router] | ||
return super()._get_fastapi_routers() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.