Require login to view, unless accessing from certain IP range

(Michael Marner) #1

I’m planning on moving a community organisation’s internal communications to Discourse from phpBB. One of the issues we have at the moment is that while the organisation has about 120 members, maybe 1/5 of members participate in the discussion. Part of the move to Discourse is to encourage participation, by making everything easier. The email digests will also help.

Anyway, what I would like to do is make the forum private, unless accessed from a certain IP range. That way I can make the forum visible without login on our internal network, set all our computers’ home pages to the forum, and encourage people to at least read. This, I hope, will further encourage participation. Outside the internal network the forum will require login in order to view posts.

Is this something I could accomplish through the SSO hooks? Alternatively, is there’s a is_allowed_to_view_posts function or some other more dodgey way I could hack this functionality?

(Sam Saffron) #2

If I got you right you are basically asking for

“requires login if not in this ip range” function, we don’t have this, sounds interesting for this kind of use case.

I am open to a PR that would add this feature if you want to work on it, you would need an extra check after the requires login check, it does not sound like a big change to me.

Just add an extra site setting for the range of ips that are immune to the requires login check.

(Michael Marner) #3

Yeah that’s the gist of it. It looks like checking the IP range is pretty easy in Rails, so it’s just incorporating the check. I might have a go at this in the next week or so.