Hi,
I’m quite new with Ruby On Rails. I have working Rails 3 environment with Apache / Passenger and Devise authentication.
Everything
is working fine but I have one question. I have some GIS (maps)
webservices and those services are implemented with PHP -mapscript. I
have to use PHP in those GIS services because there isn’t such GIS
features in Ruby.
I don’t know a ton about MapServer but it claims to have ruby support: An Introduction to MapServer — MapServer 8.0.1 documentation
I did notice, however, that their MapScript documentation only has language-specific sections for PHP and Python. That said, it looks like some people have used the ruby bindings for mapscript (at least on Mac): http://osgeo-org.1803224.n2.nabble.com/Ruby-Mapscript-on-Windows-td2243552.html
Also, it would appear development on the mapscript ruby bindings is at least being maintained: #3749 (Ruby MapScript Exceptions) – MapServer (bug closed 6 weeks ago).
Anyhow, that said, the lack of documentation (other than this language-neutral mapscript reference: SWIG MapScript API Reference — MapServer 7.6.4 documentation) does make it look like it might be dicey/glitchy to figure it out, but it might be worth experimenting with if it means you can have a more homogeneous environment.
Is it possible to control access to those PHP services with Rails
and Devise. The question is how can I route requests to PHP scripts via
Rails, control access to PHP scripts with Devise and prevent direct
access to those PHP scripts.
Now, is your PHP MapScript code a web application designed to be used directly by end-users? Or does it implement an actual “web service” Web service - Wikipedia designed to provide an API for other software to use?
If it is the former and you want to integrate your rails/devise-based authentication/authorization, then this is messy as you’d have to either:
- Proxy all “php requests” through a rails or (preferably) a rack app (devise uses the rack-based warden gem for authentication; you could work on top of that). This is a bad idea IMO
- Implement your warden/devise-compatible auth layer in PHP (this is more doable; I’ve had to integrate the sessions/auth layers of PHP apps with rails apps before).
If, however, it is the latter case (PHP implements a web service) then:
- If you keep access to the web service locked down (private access only) you can implement a web service client in ruby and use this in your front-end rails application (that already uses devise for auth).
- Or, if the PHP web service is publicly available and you need it locked down (in a manner compatible w/your existing rails auth system) then you’re back to the first two options already mentioned above.
Well, I don’t know if any of this was helpful or not or what your exact situation is. Others might care to contribute more/better ideas?
Either way, hope you find a solution.