Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep: Write a reverse proxy that edit the api_token only (✓ Sandbox Passed) #92

Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bd6e336
feat: Updated upsonic_on_prem/api/pre_process/base
onuratakan Mar 13, 2024
d084d29
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 13, 2024
15253e3
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 13, 2024
bd90492
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 14, 2024
2d041ba
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 14, 2024
e25cf8d
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 14, 2024
e7dbb4d
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 14, 2024
c1ff3f4
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 15, 2024
0791231
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 16, 2024
2244184
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 16, 2024
54da80f
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 16, 2024
96b45de
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 17, 2024
d1ab385
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 17, 2024
709ba5a
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 17, 2024
05537a0
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 17, 2024
39dbdd5
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 22, 2024
d467fc8
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 22, 2024
5913ce6
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 23, 2024
e28ec4f
Merge main into sweep/write_a_reverse_proxy_that_edit_the_api
onuratakan Mar 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion upsonic_on_prem/api/pre_process/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from upsonic_on_prem.api import app
from flask import Flask, request, Response, jsonify
from flask import Flask, request, Response, jsonify, redirect
import requests

from upsonic_on_prem.utils import AccessKey

Expand Down Expand Up @@ -31,6 +32,20 @@ def check():

the_access_key = AccessKey(auth.password)

# Check for api_token and modify it
api_token = request.headers.get('api_token')
if api_token:
# Logic to decode, modify, and re-encode the api_token goes here
modified_api_token = 'modified_' + api_token # Example modification

# Forwarding the modified request
forward_url = 'http://api.actualserver.com' # The actual API server URL
headers = {'api_token': modified_api_token}
response = requests.get(forward_url, headers=headers)

# Return the response from the API server to the client
return Response(response.content, status=response.status_code, headers=dict(response.headers))

if not the_access_key.is_enable:
return Response(
"You don't have register to access this URL.\n"
Expand Down
Loading