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

can we add this automatically I have to run a script to make changes, else I get 127.0.0.1 #273

Open
6abc opened this issue Feb 10, 2024 · 0 comments

Comments

@6abc
Copy link

6abc commented Feb 10, 2024

Find the path to auth_signals.py

AUTH_SIGNALS_PATH=$(find . -type f -name auth_signals.py)

Check if the file was found

if [ -z "$AUTH_SIGNALS_PATH" ]; then
echo "Error: auth_signals.py not found."
exit 1
fi

Use sed to replace the lines in auth_signals.py

sed -i "s/'remote_ip': request.META[REMOTE_ADDR_HEADER]/'remote_ip': request.META.get('HTTP_X_FORWARDED_FOR', request.META['REMOTE_ADDR']).split(',')[0],/" "$AUTH_SIGNALS_PATH"

Find the path to request_signals.py

REQUEST_SIGNALS_PATH=$(find . -type f -name request_signals.py)

Check if the file was found

if [ -z "$REQUEST_SIGNALS_PATH" ]; then
echo "Error: request_signals.py not found."
exit 1
fi

Use sed to replace the lines in request_signals.py

sed -i "s/remote_ip = environ.get(REMOTE_ADDR_HEADER, None)/remote_ip = environ.get('HTTP_X_FORWARDED_FOR', environ.get(REMOTE_ADDR_HEADER, '0.0.0.0')).split(',')[0]/" "$REQUEST_SIGNALS_PATH"
sed -i "s/remote_ip = list(scope.get('client', ('0.0.0.0', 0)))[0]/remote_ip = headers.get(b'x-forwarded-for', b'0.0.0.0').decode("utf-8").split(',')[0]/" "$REQUEST_SIGNALS_PATH"

image

@6abc 6abc changed the title can we add this automatically I have run a script to make changes can we add this automatically I have to run a script to make changes, else I get 127.0.0.1 Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant