Skip to content

Commit

Permalink
changing the auth token
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-dhanwant-yral committed Nov 11, 2024
1 parent 2bb94f7 commit a4f36aa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy-on-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ jobs:
- name: Set Fly secrets
run: |
flyctl secrets set --stage --app "prod-yral-nsfw-classification" "SERVICE_CRED=$(jq -n -c "${SERVICE_CRED}")"
flyctl secrets set --stage --app "prod-yral-nsfw-classification" "PUBLIC_KEY_TO_VERIFY_INCOMING_CALLS_FROM_FRONTEND_LEPTOS_SSR_SERVICE=${PUBLIC_KEY_TO_VERIFY_INCOMING_CALLS_FROM_FRONTEND_LEPTOS_SSR_SERVICE}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_IO_DEPLOY_TOKEN }}
SERVICE_CRED: ${{ secrets.GOOGLE_CLOUD_EVENTS_BQ_SERVICE_ACCOUNT_KEY_JSON }}
PUBLIC_KEY_TO_VERIFY_INCOMING_CALLS_FROM_FRONTEND_LEPTOS_SSR_SERVICE:
${{ env.PUBLIC_KEY_TO_VERIFY_INCOMING_CALLS_FROM_FRONTEND_LEPTOS_SSR_SERVICE }}

- name: Check fly status
run: |
Expand Down
25 changes: 20 additions & 5 deletions ping_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import nsfw_detector_pb2_grpc
import os
import jwt
import base64

token_fpath = "/Users/jaydhanwant/Documents/SS/nsfw_jwt_token.txt"
with open(token_fpath, 'r') as f:
_JWT_TOKEN = f.read()

# server_url = 'prod-yral-nsfw-classification.fly.dev:443'
server_url = 'yral-nsfw-classification.fly.dev:443'
server_url = 'prod-yral-nsfw-classification.fly.dev:443'
# server_url = 'yral-nsfw-classification.fly.dev:443'
# Load the private key from a path specified in an environment variable

def run():
Expand All @@ -20,11 +21,25 @@ def run():
# Test video ID (replace with an actual video ID for testing)
video_id = "00034f1c9c9148388bf6873776222535"

image_url = "https://img-cdn.pixlr.com/image-generator/history/65bb506dcb310754719cf81f/ede935de-1138-4f66-8ed7-44bd16efc709/medium.webp"
# Test image path for byte64
image_path = "/Users/jaydhanwant/Downloads/WhatsApp Image 2024-08-29 at 13.18.09.jpeg"

try:
print("Sending request to server")
print("Sending video ID request to server")
metadata = [('authorization', f'Bearer {_JWT_TOKEN}')]
response = stub.DetectNSFWVideoId(nsfw_detector_pb2.NSFWDetectorRequestVideoId(video_id=video_id), metadata=metadata)
print(response)
video_response = stub.DetectNSFWVideoId(nsfw_detector_pb2.NSFWDetectorRequestVideoId(video_id=video_id), metadata=metadata)
print(video_response)

# print("Sending image URL request to server")
# url_response = stub.DetectNSFWURL(nsfw_detector_pb2.NSFWDetectorRequestURL(url=image_url), metadata=metadata)
# print(url_response)

print("Sending image to byte64 request to server")
with open(image_path, "rb") as image_file:
image_byte64 = base64.b64encode(image_file.read()).decode('utf-8')
byte64_response = stub.DetectNSFWImg(nsfw_detector_pb2.NSFWDetectorRequestImg(image=image_byte64), metadata=metadata)
print(byte64_response)
except grpc.RpcError as e:
print(f"RPC failed: {e}")

Expand Down
7 changes: 4 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@

_AUTH_HEADER_KEY = "authorization"

_PUBLIC_KEY = consts.NSFW_JWT_PUB_KEY
_JWT_PAYLOAD = {
# _PUBLIC_KEY = consts.NSFW_JWT_PUB_KEY
_PUBLIC_KEY = os.environ.get("PUBLIC_KEY_TO_VERIFY_INCOMING_CALLS_FROM_FRONTEND_LEPTOS_SSR_SERVICE")
_JWT_PAYLOAD = {
"sub": "yral-nsfw-detector-server",
"company": "gobazzinga",
"company": "Yral",
}

# downloading model artifacts
Expand Down

0 comments on commit a4f36aa

Please sign in to comment.