0.0
No commit activity in last 3 years
No release in over 3 years
It is inspired on this post (http://blogs.msdn.com/b/silverlining/archive/2011/10/03/ruby-web-sites-and-windows-azure-appfabric-access-control.aspx) by Larry Franks.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

SWT Federation for Ruby¶ ↑

<img src=“https://secure.travis-ci.org/nicopaez/SWT-Federation.png?branch=master” alt=“Build Status” />

This library provides SWT-based federation for Ruby applications (ruby 1.9)

The entry point of this library is the TokenHandler class. Before using it you have to set some class instance variables that hold configuration information. You can do this, int he config.ru file as shown below.

# config.ru
require './application.rb'
require 'swt_federation'

SwtFederation::TokenHandler.realm = 'yourrealmhere'
SwtFederation::TokenHandler.issuer = 'https://yourservicenamespacehere.accesscontrol.windows.net/'
SwtFederation::TokenHandler.token_key = 'yourkeyhere'
SwtFederation::TokenHandler.token_type = 'http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0'

run Sinatra::Application

Below you can find an example of how to use it with Sinatra.

# application.rb
before do

  next if request.path_info == '/swt' 
  if(session['user']==nil)
    redirect ("<your_identity_provider_url>")
  end
end

post '/swt' do
  response = TokenHandler.new(params[:wresult])
  if (response.is_valid?)
    session['user'] = response.claims['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress']
    target_url = params[:wctx]
    if (target_url != nil)   
      redirect(target_url)
    else
      redirect('/home') 
    end
  else
    status(403)
    halt('access denied')
  end
end

get '/'
  user = session['user']
  "Hello #{user}!"
end

This is the second drop, I have added some tests and now there is a good coverage rate but there are many things to improve(check coding conventions, add more features, deeper Rack integration, etc). If you want to use it and have any doubt, just contact me.

Hope you find it useful!