Jump to content

You're browsing the 2004-2023 VATSIM Forums archive. All content is preserved in a read-only fashion.
For the latest forum posts, please visit https://forum.vatsim.net.

Need to find something? Use the Google search below.
PLEASE READ - Webmaster Support Forum
This forum will be retired in the near future. Please direct all queries to our dedicated GitHub support page https://github.com/vatsimnetwork/developer-info/discussions 
Here you can find documentation on our services and we are continuing to migrate pertinent information into the Wiki pages https://github.com/vatsimnetwork/developer-info/wiki

Python Integration


Kieran Hardern
 Share

Recommended Posts

Kieran Hardern
Posted
Posted

I'm pleased to announce that Nick Harasym (from Vatstats) has put together a wrapper for those of you wanting to integrate with the VATSIM SSO using Python.

 

Code and instructions can be found here: https://bitbucket.org/nharasym/vatsim-sso/

 

Thanks Nick

Link to comment
Share on other sites

Colin Schoen
Posted
Posted

Thank you, Nick.

Colin Schoen

VATSIM Senior Network Supervisor

Link to comment
Share on other sites

  • 2 weeks later...
Florian Rimoli
Posted
Posted

Great thanks Kieran !

 

Any idea/news for a Ruby (RoR) integration ?

Florian Rimoli

French vACC 

vatsim.fr

 

Link to comment
Share on other sites

Ozgur Karatas 961628
Posted
Posted
I'm pleased to announce that Nick Harasym (from Vatstats) has put together a wrapper for those of you wanting to integrate with the VATSIM SSO using Python.

 

Code and instructions can be found here: https://bitbucket.org/nharasym/vatsim-sso/

 

Thanks Nick

 

Great! thanks.

 

Regards

 

Ozgur Karatas

generate.php?mid=961628
Link to comment
Share on other sites

Nick Harasym
Posted
Posted

I might be able to toss something together for Ruby

Nick Harasym
Senior Network Infrastructure Engineer 
## [email protected]
## www.vatsim.net
## ##
7JRF7kO.png
Link to comment
Share on other sites

Florian Rimoli
Posted
Posted
I might be able to toss something together for Ruby

 

Hey, thanks

 

I've spent my night to create a simple gem that works perfectly ( using the old oauth gem ).

Now, i'm forking sorcery ( https://github.com/NoamB/sorcery ) and working on adding a "vatsim provider"

Florian Rimoli

French vACC 

vatsim.fr

 

Link to comment
Share on other sites

Nick Harasym
Posted
Posted

mmm well mine would be like the python module where you just p[Mod - Happy Thoughts] in what you need and it hands back what is needed.

 

Simple and easy

Nick Harasym
Senior Network Infrastructure Engineer 
## [email protected]
## www.vatsim.net
## ##
7JRF7kO.png
Link to comment
Share on other sites

Florian Rimoli
Posted
Posted

Yep, i've done a gem which is pretty simple like your Py script.

Looks like this ( not so mature and ready for wide use, but works )

 

require "vatsim_sso/version"
require 'oauth'
require 'json'


module VatsimSso

 def self.login(key,cert_path)

   callback_url = "http://127.0.0.1:3000/oauth/callback"
   public_key = IO.read(cert_path)
   @consumer = OAuth::Consumer.new(key, public_key , :site => "http://sso.hardern.net/server",:request_token_path=>"/api/login_token", :authorize_path=>"/auth/pre_login", :access_token_path=>"/api/login_return",:signature_method => "RSA-SHA1")

   @request_token = @consumer.get_request_token(
       :oauth_callback => callback_url
   )

   h = JSON.p[Mod - Happy Thoughts](@request_token.params.keys.first.to_s)
   redirect_url = 'http://sso.hardern.net/server/auth/pre_login/?oauth_token=' + h['token']['oauth_token']
   if defined? redirect_to
     redirect_to redirect_url
   else
     redirect_url
   end

 end

 def self.login_return(auth_token,auth_verifier)
   resp = OAuth::RequestToken.new(@consumer,auth_token).get_access_token(:oauth_verifier => auth_verifier)
   h = JSON.p[Mod - Happy Thoughts](resp.params.keys.first.to_s)
   h['user']
 end

end

 

 

Since we're rebuilding all VAT France's website in RoR, i was looking for an "integrated" solution for user management, so creating a VATSIM provider to sorcery was a good solution.

Now it works, and i'm getting prepared for live sso tests

Florian Rimoli

French vACC 

vatsim.fr

 

Link to comment
Share on other sites

Nick Harasym
Posted
Posted

Looks good basically what I have done so far in ruby but not as complete. Maybe this gem could go onto a git site?

Nick Harasym
Senior Network Infrastructure Engineer 
## [email protected]
## www.vatsim.net
## ##
7JRF7kO.png
Link to comment
Share on other sites

Florian Rimoli
Posted
Posted

Yes, it will, but like i said, not ready for a wide deployment

 

I've to test it a bit more, prepare it for a public use, and i will publish both lightweight gem and sorcery-vatsim integration gem.

Florian Rimoli

French vACC 

vatsim.fr

 

Link to comment
Share on other sites

Rahul Parkar
Posted
Posted

Well,

 

I was planning on creating a gem but looks like you two have it covered so far, put it up in a repo when ready and I'll help out as well

 

Cheers!

Rahul

VATEUD7

Rahul Parkar

"On second thoughts Nappa, catch it, catch it with your teeth" -- Vegeta

Professional Nerd. (Professionally not professional)

Link to comment
Share on other sites

Florian Rimoli
Posted
Posted

Hey Rahul !

 

I'm having trouble to make it work in live env.

I generated openssl keys (like explained), but i always have an Invalid consumer key error...

The pub key is set on the sso dashboard, everything looks good, and i'm using exactly the same function for both live and test... but only works on test...

Do you have Skype ?

Florian Rimoli

French vACC 

vatsim.fr

 

Link to comment
Share on other sites

  • 2 years later...
Jonathan Voss 819172
Posted
Posted

Hi Florian,

 

Not to bring up an old issue but I have this exact issue with "Invalid consumer key" using a Omniauth strategy I wrote for VATSIM to be able to use SSO with Ruby/Rails applications.

 

It works fine with the test server but no matter what iteration of private key I generate and update on the VATSIM SSO side it always returns with an "Invalid consumer key".

 

Did you ever figure out why this was happening with your implementation?

Link to comment
Share on other sites

Jamie Fox 811029
Posted
Posted

This may be the obvious question, but are you completely sure you're using the right consumer key? The 'Invalid consumer key' error comes before the check of the RSA/HMAC key, so it won't be a problem with that.

Link to comment
Share on other sites

Jonathan Voss 819172
Posted
Posted

Unfortunately yes, I've even directly copied it from the SSO configuration page into our site configuration locally. Unless for some reason it really is not activate yet on VATSIM's side but as far as I am aware it shows 'Public' so I am [Mod - Happy Thoughts]uming that means we should be all set.

Link to comment
Share on other sites

Jamie Fox 811029
Posted
Posted

The best thing you can do, if at all possible, would be to install the PHP Client Demo code and see what happens when you try to log in with that. That should then give you a clear answer about whether the problem is with the Ruby code, or else a different problem with your server/SSO account.

Link to comment
Share on other sites

Jonathan Voss 819172
Posted
Posted

That may prove to be very difficult to do with our setup.

 

Is there a difference between the demo SSO and production? I would think if it validates just fine with the demo environment it should work in production, or am I missing something here?

Link to comment
Share on other sites

Jamie Fox 811029
Posted
Posted

Everything should be the same on the production system. The only differences are the obvious ones: you're using a different consumer key (i.e. the real one, not SSO_DEMO) and it's running on HTTPS not HTTP.

Link to comment
Share on other sites

Jonathan Voss 819172
Posted
Posted

Thanks, I appreciate your insight. I've figured it out with the help of Florian's Ruby code within the list of Python code you had previously sent.

 

It turns out that in production the OAuth scheme is dependent on body signatures. The demo system either does not check this or enforce it which is why it was working in development versus production. I will be updating my OmniAuth strategy soon for anyone that may be interested in Rails/OmniAuth/Devise type setups in the future.

Link to comment
Share on other sites

Jamie Fox 811029
Posted
Posted

Thanks for doing the detective work to find out exactly where the problem was. I'll have a look into the demo/live systems to see what's going on there, and why we're seeing a difference.

Link to comment
Share on other sites

 Share