Deploying RubyCas Server with Trinidad

86 views
Skip to first unread message

Tina Tsui

unread,
Nov 1, 2012, 12:38:32 PM11/1/12
to rubycas...@googlegroups.com
Hi all,

First, I want to thank Matt Zukowski and all the contributors to this gem.  I have been using this in my development and test environments for past several months.  Everything is working great!

The only thing is in order for me to push it to production, I need it to use it with an Oracle database.  I want to do this using the Oracle JDBC driver so I want to deploy RubyCas Server with Trinidad.   I have had success with deploying my own Rails app using Trinidad.  I am actually very impress how well it worked -- I did not have to change a single line of code.  I also had success in creating a Rails app that connects to CAS Oracle database using Trinidad and Oracle JDBC driver.

I don't know enough about Sinatra to try to figure out how to run this under Trinidad.  So far this is what I changed:
added 
    s.add_dependency("activerecord-jdbc-adapter", "~> 1.2")
    s.add_dependency("jruby-openssl", "~> 0.7")
    s.add_dependency("trinidad", "~> 1.4")

------------------------------
ran bundle install for  jruby 1.6.7.2
added config/trinidad.yml that contains:

---
  address: localhost
  environment: development
  ssl:
    port: 8443
    keystore: /path/to/keystore.p12
    keystorePass: xx
    keystoreType: pkcs12

  jruby_min_runtimes: 1 # min number of runtimes
  jruby_max_runtimes: 1 # max number of runtimes

  web_apps:
   default:
    context_path: /authentication
    web_app_dir: /path/to/rubycas-server

--------------------
added the following to config.ru:
#\ -s trinidad

--------------------
I have CONFIG_FILE environment variable set to /path/to/rubycas-server/config.yml
I start trinidad with  trinidad command

and get the following output:

Initializing ProtocolHandler ["http-bio-8443"]
Initializing ProtocolHandler ["http-bio-3000"]
Starting Servlet Engine: Apache Tomcat/7.0.32
jruby 1.6.7.2 (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_33) [linux-amd64-java]
using a shared (threadsafe!) runtime

>>> Redirecting RubyCAS-Server log to /log/casserver.log

Starting ProtocolHandler ["http-bio-8443"]
Starting ProtocolHandler ["http-bio-3000"]


But when I go to the site:

https://hostname:8443/authentication/login

I get the Sinatra message:

Sinatra doesn’t know this ditty.


--- Note:
My rubycas-server/config.yml contains the entry:
uri_path: /authentication

Any suggestions would be greatly appreciated.

Thanks,
Tina









Matt Zukowski

unread,
Nov 1, 2012, 3:19:53 PM11/1/12
to rubycas...@googlegroups.com
I've never tried running under Trinidad, but the error your getting in Sinatra usually means that the URL mapping isn't working for some reason. Not knowing much about Trinidad, I can't really tell you why it's not working. Have you tried going to just https://hostname:8443 ? does anything come up there? From your console output, it does look like Trinidad is at least starting up the rubycas-server app, so that's good, but not sure if/how it's being mapped.

By the way, for adding your own dependencies, adding them to the gemspec is okay, but might be cleaner to do it in your Gemfile. i.e. something like:

gem 'activerecord-jdbc-adapter' ,'~1.2'
gem 'jruby-openssl', '~0.7',
etc..

(run 'bundle install' afterwards)

Tina Tsui

unread,
Nov 2, 2012, 9:37:27 AM11/2/12
to rubycas...@googlegroups.com
Matt,

Thanks!  That was it.  I had the sub-uri "authentication" in both the trinidad.yml and rubycas-server/config.yml  -- so Trinidad was stripping the context_path "authentication" before passing it to Sinatra. 

It worked when I changed the

context_path: /authentication

to:

context_path: /

in trinidad.yml  file

It's working fine -- currently I'm using the PostgreSQL JDBC adapter (I find it easier to get that working first).  I will be moving it over to the Oracle JDBC adapter.

I also had to make some other changes in order to deploy to Production -- I added Rack::Csrf  to prevent Cross Site Request Forgery -- I'll post the changes I made in another thread.

Thanks,
Tina
Reply all
Reply to author
Forward
0 new messages