GithubHelp home page GithubHelp logo

Comments (9)

xelantro avatar xelantro commented on June 10, 2024 1

Btw: so just that you are aware and to link it: #83
request.remote_addr was removed and changed to request.get_remote_address
So if my second statement is incorrect and you do need to append it another time, pls swap it

from matrix-registration.

xelantro avatar xelantro commented on June 10, 2024

Sry for not responding earlier - didn't see it.
Is this testet / merge ready?
If you think it should work, please open a pull request so we can sort it out!

from matrix-registration.

timmc avatar timmc commented on June 10, 2024

Depends if you think the change is acceptable -- it would switch from storing a single IP to a list of IPs, which may or may not be something people want. (If that approach is acceptable, I'm happy to submit a PR.)

from matrix-registration.

xelantro avatar xelantro commented on June 10, 2024

First of all, I think it a good change. As long as it stays a single string so we dont have to alter the database structure.
Regarding your code (correct me if im wrong, because im not that fluent with flask and shit)

  • the code in the readme is the one for the nginx reverse proxy so $remote_addr should be the clients address? (as long as its the only layer of proxy -> cloudflare, matrix-docker-ansible project), but many ppl use systems with multipls layers of reverse proxys so it'd be still good
  • the nginx website claims that the $proxy_add_x_forwarded_for appends the current $remote_addr to the incoming X-Forwarded-For header, so using the header in your phython should be enough and you shouldn't need to append request.remote_addr again
  • have you testet that it still works with the old nginx config (backwards comp) and without a reverse proxy?

from matrix-registration.

timmc avatar timmc commented on June 10, 2024

OK, I can work it up as a PR, maybe even with unit tests. :-) I'm not particularly familiar with Flask either.

I can also try testing it manually with different configurations.

from matrix-registration.

xelantro avatar xelantro commented on June 10, 2024

What I just noticed reading this again:
Could it have been that we've been ratelimiting the request from the proxy itself (if present) so for all users (maybe @SapuSeven knows), and whether integrating the header change in the limiter would be possible

from matrix-registration.

xelantro avatar xelantro commented on June 10, 2024

@timmc can you open the pr as draft now so we can move the discussion there? (Just your current code is fine then we can also suggest changes directly within githubs code thing)

from matrix-registration.

SapuSeven avatar SapuSeven commented on June 10, 2024

What I just noticed reading this again: Could it have been that we've been ratelimiting the request from the proxy itself (if present) so for all users (maybe @SapuSeven knows), and whether integrating the header change in the limiter would be possible

I have to say that I don't really know how exactly rate limiting works, I just looked at the code changes of the remote repository and noticed that get_ipaddr seems to have been replaced with get_remote_address.
Sorry for not testing this properly.

from matrix-registration.

timmc avatar timmc commented on June 10, 2024

Alternatively, solve both issues by adding a config setting like CLIENT_IP_HEADER = [X-Forwarded-For | X-Real-IP | etc.] that instructs the app that there's a trusted proxy in front -- if not set, use request.remote_addr, and if set, use request.headers.getlist(config.CLIENT_IP_HEADER)[-1].

from matrix-registration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.