Skip to content

Commit

Permalink
fix(iam): adding token-auth score endpoint (#684)
Browse files Browse the repository at this point in the history
* fix(iam): adding token-auth score endpoint

* monitoring config
  • Loading branch information
lucianHymer committed Sep 27, 2024
1 parent 2e40648 commit dcd896c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
16 changes: 16 additions & 0 deletions api/ceramic_cache/api/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from registry.models import Score
from stake.api import handle_get_gtc_stake
from stake.schema import GetSchemaResponse
from trusta_labs.api import CgrantsApiKey

from ..exceptions import (
InternalServerException,
Expand All @@ -71,6 +72,8 @@

router = Router()

secret_key = CgrantsApiKey()


def get_address_from_did(did: str):
return did.split(":")[-1]
Expand Down Expand Up @@ -522,6 +525,19 @@ def calc_score(
return get_detailed_score_response_for_address(address, payload.alternate_scorer_id)


@router.get(
"/score/{int:scorer_id}/{str:address}",
response=DetailedScoreResponse,
auth=secret_key,
)
def calc_score_community(
request,
scorer_id: int,
address: str,
) -> DetailedScoreResponse:
return get_detailed_score_response_for_address(address, scorer_id)


class FailedVerificationException(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = "Unable to authorize request"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def get_config(base_url: str) -> dict:
},
"payload": [],
},
("GET", "/ceramic-cache/score/{scorer_id}/{address}"): {
"skip": True, # Skipping because uptime robot api rejects creating multiple monitors on same endpoint
},
("POST", "/ceramic-cache/score/{address}"): {
# TODO: do we still use this POST API ???
"skip": True, # Skipping because uptime robot api rejects creating multiple monitors on same endpoint
Expand Down
4 changes: 2 additions & 2 deletions infra/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1673,9 +1673,9 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"

"infra-libs@https://github.com/passportxyz/infra-libs.git#2845-fleek-aws":
"infra-libs@passportxyz/infra-libs#semver:^1.1.0":
version "1.0.0"
resolved "https://github.com/passportxyz/infra-libs.git#c824f123e02a1fdb1f31faf6e09524c8617a2605"
resolved "https://codeload.github.com/passportxyz/infra-libs/tar.gz/1de32e835e9ebb47bb35db71e3ca66d49915f1ed"
dependencies:
"@1password/op-js" "^0.1.13"
"@pulumi/aws" "^6.45.0"
Expand Down

0 comments on commit dcd896c

Please sign in to comment.