Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Enterprise Integration with Ruby (29 Mar 2016 S...

Enterprise Integration with Ruby (29 Mar 2016 Singapore Ruby Meetup)

Sheng-Loong Su

March 29, 2016
Tweet

More Decks by Sheng-Loong Su

Other Decks in Technology

Transcript

  1. Who am I? • SU Sheng Loong (@code_ssl) • Work

    for Infocomm Development Authority (IDA) • Develop eServices at Ministry of Manpower (MOM) • Opinions are all mine
  2. Background • It is fairly common to have integration with

    other systems. • Enterprises are already invested in some proprietary or Commercial Off-The- Shelf (COTS) products. • Java/.Net are still mainstream for bespoke enterprise software development. • IMHO, Ruby is catching up with Java/.Net but vendor support is still limited as of today.
  3. This Talk is NOT about • Government • Architectural patterns

    ▪ Service-oriented Architecture (SOA) ▪ Micro-services Architecture (MSA) • Starship “Enterprise” http://i.imgur.com/u4AEbmh.gif
  4. Database - Level 1 • Oracle is the “king” of

    databases in enterprise. • Ruby gems:- 1. ruby-oci8 2. activerecord-oracle_enhanced-adapter
  5. Database - Level 2 (continued) • Add multiple database config

    into database.yml another_oracle_db: adapter: oracle_enhanced host: 192.168.0.8 port: 1521 database: xe username: user password: secret
  6. Database - Level 2 (continued) • Call establish_connection explicitly to

    connect to the different database server ActiveRecord::Base.establish_connection(:another_oracle_db)
  7. Database - Level 3 (continued) • Use database user with

    “just enough power” for your application. • “select”, “insert” and “update” are sufficient for typical public facing web application. • Mark record as deleted (soft-delete) instead of deleting the record from the database table. ▪ “paranoia” gem uses “deleted_at” column
  8. Database - Level 3 (continued) • Enhance the few necessary

    rake tasks - such as schema migration - to switch to more powerful database user.
  9. Authentication - Level 2 • Enterprises usually have Active Directory

    (AD). • AD is Microsoft’s implementation of directory service which manages data, eg. Users, Groups, Computers, Services, etc. in hierarchical structure.
  10. Authentication - Level 2 • Protocols for integration with AD:-

    1. Lightweight Directory Access Protocol (LDAP) 2. Kerberos
  11. Authentication - Level 2 (continued) • How to do LDAP

    in Ruby? • Ruby gems:- 1. net/ldap (standard library) 2. devise_ldap_authenticatable (https://github. com/cschiewek/devise_ldap_authenticatable)
  12. Authentication - Level 2 (continued) • How to do Kerberos

    in Ruby? • Ruby gems:- 1. timfel-krb5-auth (https://github.com/timfel/krb5-auth) 2. devise-kerberos-authenticatable (https://github.com/ueokande/devise- kerberos-authenticatable)
  13. Authentication - Level 2 (continued) • AD alternative for testing

    - ladle (https://github.com/NUBIC/ladle) • Spins up embedded directory server in Ruby. • Uses ApacheDS (https://directory.apache.org/apacheds/) under the hood.
  14. Single Sign On (SSO) - Level 1 • OAuth •

    Works by:- 1. Delegating user authentication to the service that hosts the user account 2. Authorizing third-party applications to access the user account https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2
  15. Single Sign On (SSO) - Level 1 (continued) • Ruby

    gem for implementing OAuth 2.0 Provider ▪ doorkeeper (https://github.com/doorkeeper-gem/doorkeeper)
  16. Single Sign On (SSO) - Level 1 (continued) • Ruby

    gem for implementing OAuth 2.0 Consumer ▪ oauth2 (https://github.com/intridea/oauth2)
  17. Single Sign On (SSO) - Level 2 • Security Assertion

    Markup Language (SAML) • XML-based
  18. Single Sign On (SSO) - Level 2 (continued) • Ruby

    gem for implementing service provider and identity provider ▪ libsaml (https://github.com/digidentity/libsaml)
  19. Web Services - Level 2 (continued) • For some reasons,

    enterprise IT still loves SOAP more than REST. • But more and more enterprise applications are embracing REST.
  20. Web Services - Level 2 (continued) • Ruby gem for

    implementing SOAP Provider ▪ wash_out (https://github.com/inossidabile/wash_out)
  21. Web Services - Level 2 (continued) • Ruby gem for

    implementing SOAP Consumer ▪ savon (https://github.com/savonrb/savon)
  22. Web Service Security - Level 2 (continued) 1. Consumer buys

    SSL certificate from Certificate Authority (CA). 2. Consumer generates DigestValue from the SOAP message body. 3. Consumer signs DigestValue with consumer’s private key to create SignatureValue. 4. Consumer encodes and includes public key certificate, message digest and signature in the SOAP message.
  23. Web Service Security - Level 2 (continued) 1. Provider computes

    message digest #1 from the message body. 2. Provider decrypts SignatureValue with consumer’s certificate to create message digest #2. 3. Provider ascertain whether both message digest #1 and #2 are the same.
  24. Web Service Security - Level 2 (continued) • Most of

    these signing/verification steps can be taken care of by “akami” gem (https://github.com/savonrb/akami). • “savon” also uses “akami”.
  25. Web Service Security - Level 3 (continued) • Mutual (two-way)

    SSL authentication http://www. codeproject. com/KB/IP/326574/
  26. Printer • cups - Ruby bridge to CUPS API ▪

    Segmentation fault issue remains unresolved • lpr - shell out from Ruby program to submit files for printing lpr -H 192.168.0.8:631 -P printer_name_1 -o media=a4 -o sides=two-sided-long-edge
  27. There are more... • Messaging Queues (MQ) • Enterprise Service

    Bus (ESB) • File Transfer Protocol (FTP) • Log aggregation • Monitoring • Payment Gateway • Continuous Integration/Delivery
  28. Stubbing/Mocking • WebMock and VCR ▪ https://robots.thoughtbot.com/how-to-stub-external-services-in-tests • Dummy Rails

    / Sinatra application • Vagrant box / Docker container • Mountebank (http://www.mbtest.org/)