By Antonio Marques
2010.11.08

cas-rest-client: a rest client to interact with CASified services

So, you need to interact programmatically with a CASified service or API. That's such a boring task. To access any resource, it's necessary to acquire a ticket-granting ticket (TGT) from CAS, use it to ask CAS for a service ticket (ST) and then pass this service ticket as a parameter to access the resource. For every request, this cycle repeats.

For Ruby developers, the CasRestClient gem can be handy. Instead of coding all these ticketing interactions with CAS, just pass the CAS uri and credentials to the CasRestClient instance:

require 'rubygems'
require 'cas_rest_client'

# CAS uri, credentials and service
params = {:uri => 'https://cas_auth_server.com/tickets', :username => 'user', :password => 'pass',
 
:service => 'http://casified_api.com/'}

client
= CasRestClient.new params
response
= client.get "https://casified_api.com/resource", :accept => 'application/xml'

CasRestClient will handle all the interactions with CAS to acquire service tickets, and automatically will use them to access the requested resources.

Read more...
By Antonio Marques
2010.10.31

Deploying Node.js apps with Nginx and God

This article explains how to set up a server to host node.js applications. As node.js processes can't be run as daemons - except by using Upstart, which is by now only stable on Ubuntu; more info here - the idea is to use God to manage and monitor the node.js process running the application and nginx as a reverse proxy.

I'll use a Debian Lenny 5.0 VM in this article, but the steps performed and packages required should be similar in other distros.

Let's start by creating a simple application. Edit /var/www/apps/hello_world.js and paste in the Hello World app.

var http = require("http");
http
.createServer(function (request, response) {
  response
.writeHead(200, {"Content-Type": "text/plain"});
  response
.write("Hello World\n");
  response
.close();
}).listen(3000);

Notice that this process will listen on port 3000.

Read more...