SlideShare a Scribd company logo
Giving your website a command line interfaceMichael Hudson-Doylemichael.hudson@linaro.org
Linaro and its missionLinaro aims to make Linux work better on ARM processors
The ProblemThe ARM ecosystem is very fragmented, and the kernel has a lot of copy and paste code"Gaah. Guys, this whole ARM thing is a f*cking pain in the ass."— Linus Torvalds, 17 Mar 2011https://lwn.net/Articles/437170/
Enter Linaro!"Linaro is a not-for-profit software engineering company investing in core Linux software and tools for ARM SoCs."Also about educating the members in how to do open source development...
LAVA - Linaro Automated ValidationA bit part of Linaro is about automated validation:Find regressions earlier
Also benchmark toolchain improvements
Maybe even power management changes too...LAVAWe have a bunch of hardware
LAVASome scripts and tricks that can boot a board with a new kernel and run some tests.Quick Demo(ever the optimist)
LAVAAnd a website that lets you see whats going on
The Problem (finally!)We want to do things like trigger test runs when a kernel build finishes.This basically means some kind of Remote Procedure Call (RPC).
ParanoiaFor a bunch of reasons, we need some kind of security in our system:The boards in our lab are a limited resource
Some risk of mischief
Eventually may have test results from unreleased hardware or benchmarks with licenses that forbid publication of resultsProtocol ChoicesWe use XML-RPC
We didn't think about this very hard but it is well supported in most languages
Will probably add JSON-RPC support at some point for easier browser accessFirst idea: OAuthAn open protocol to allow secure API authorization in a simple and standard method from desktop and web applications.– http://oauth.net/
The great thing about standards...<bob2> kennethreitz: oauth        is a font of villany        and dispair -- #python, Jun 09 11:55:08
Also doesn't solve our problemOAuth specifies that various aspects of the request are signed, but not, crucially for us, the body of the request – an important detail, because in XML-RPC the body of the request is where all the important stuff is.
Transport Layer Security, here we comeIf you're going as far as to cryptographically sign something, it's not much further to go to actually just encrypt it!
And what does everyone know about encryption?Don't implement it yourself(i.e. use HTTPS)
Back to BasicAnd if you're operating over HTTPS, you might as well just just good old RFC 2617 Basic Authentication...... but with tokens rather than passwords
Tokens > PasswordsBecause we expect the RPC to be invoked from build systems and so on, there is a moderate chance of the token being leaked – so it should not let you take over the owning user's account.In the future, a token might only let you access some APIs.
Also, we use SSO...In addition we use Launchpad's SSO service for authentication, so most users don't have a LAVA password!
Show me the code!On the server side, we've built a library that lets you add a authenticating XML-RPC to a Django project:https://launchpad.net/linaro-django-xmlrpcIt includes views and models (and very very simple templates) for creating and managing tokens.
Server side codeexample/api.py:from linaro_django_xmlrpc.models import ExposedAPIfrom linaro_django_xmlrpc.globals import mapperclass ExampleAPI(ExposedAPI):    def whoami(self):        if self.user:            return self.user.username        else:            return Nonemapper.register(ExampleAPI)in your urlconf:    url(r'', include('linaro_django_xmlrpc.urls')),
Client side libraryThis isn't properly factored yet really (it's it all mashed up with our toolkit for doing command line tools), but the code is in "lava-tool":https://launchpad.net/lava-toolIt uses python-keyring for token management.
Client-side codefrom lava_tool.authtoken import \     AuthenticatingServerProxy, KeyringAuthBackendauth_backend = KeyringAuthBackend()auth_backend.add_token(    "user", "http://server/RPC2/", token)sp = AuthenticatingServerProxy(    "http://user@server/RPC2/",    auth_backend=auth_backend)print server.whoami()

More Related Content

ODP
PHPNW Test Fest Pre-presentation
PPTX
Phalcon 2 - PHP Brazil Conference
PPTX
Phalcon 2 High Performance APIs - DevWeekPOA 2015
PPTX
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
PPTX
The better PHP API (EN)
PPTX
PHP Conference - Phalcon hands-on
PPTX
Getting Started With PowerShell Scripting
PDF
Fluentd v0.12 master guide
PHPNW Test Fest Pre-presentation
Phalcon 2 - PHP Brazil Conference
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
The better PHP API (EN)
PHP Conference - Phalcon hands-on
Getting Started With PowerShell Scripting
Fluentd v0.12 master guide

What's hot (20)

PPTX
Windows PowerShell - Billings .NET User Group - August 2009
PPTX
PDF
2021laravelconftwslides6
PPTX
PHP Presentation
PPTX
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
ODP
Website releases made easy with the PEAR installer - Barcelona 2008
PPT
Flyr PHP micro-framework
PDF
Remote File Inclusion / Local File Inclusion [Attack and Defense Techniques]
PDF
RMLL 2014 - OpenLDAP - Manage password policy
PPTX
Document Databases e RavenDB
PPT
LOGBack and SLF4J
PPT
香港六合彩
PPT
PPT
Ruby Projects and Libraries
ODP
Website releases made easy with the PEAR installer, OSCON 2009
PPT
Another Test
PPTX
How i-won-club hack-precon-ctf-v2
PPT
Apache
ODP
Developing high-performance network servers in Lisp
DOCX
How to save log4net into database
Windows PowerShell - Billings .NET User Group - August 2009
2021laravelconftwslides6
PHP Presentation
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
Website releases made easy with the PEAR installer - Barcelona 2008
Flyr PHP micro-framework
Remote File Inclusion / Local File Inclusion [Attack and Defense Techniques]
RMLL 2014 - OpenLDAP - Manage password policy
Document Databases e RavenDB
LOGBack and SLF4J
香港六合彩
Ruby Projects and Libraries
Website releases made easy with the PEAR installer, OSCON 2009
Another Test
How i-won-club hack-precon-ctf-v2
Apache
Developing high-performance network servers in Lisp
How to save log4net into database
Ad

Viewers also liked (6)

ZIP
How we use Twisted in Launchpad
DOC
Projektdokumentation Kai Aras Ss08
ZIP
An Introduction to PyPy
PDF
Design patterns - Singleton&Command
PPT
a quick Introduction to PyPy
KEY
Jailbreaking iOS
How we use Twisted in Launchpad
Projektdokumentation Kai Aras Ss08
An Introduction to PyPy
Design patterns - Singleton&Command
a quick Introduction to PyPy
Jailbreaking iOS
Ad

Similar to Kiwipycon command line (20)

PDF
Python RESTful webservices with Python: Flask and Django solutions
PDF
API Design & Security in django
PDF
Getting Started with Public APIs
PPTX
How to build Simple yet powerful API.pptx
PDF
OpenStack API's and WSGI
PDF
Fun! with the Twitter API
PDF
Creating Restful Web Services with restish
PDF
Dennis Byrne - Full Stack Python Security_ Cryptography, TLS, and attack resi...
PDF
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
PDF
OAuth and OEmbed
PDF
How to Implement Token Authentication Using the Django REST Framework
PPT
Learn REST API with Python
PDF
PDF
Rest api with Python
PPTX
Automate that
PPTX
Automate That! Scripting Atlassian applications in Python
PDF
Rest api titouan benoit
PDF
Protecting Your APIs Against Attack & Hijack
PDF
How LinkedIn changed its security model in order to offer an API
PDF
Cloud Native API Design and Management
Python RESTful webservices with Python: Flask and Django solutions
API Design & Security in django
Getting Started with Public APIs
How to build Simple yet powerful API.pptx
OpenStack API's and WSGI
Fun! with the Twitter API
Creating Restful Web Services with restish
Dennis Byrne - Full Stack Python Security_ Cryptography, TLS, and attack resi...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
OAuth and OEmbed
How to Implement Token Authentication Using the Django REST Framework
Learn REST API with Python
Rest api with Python
Automate that
Automate That! Scripting Atlassian applications in Python
Rest api titouan benoit
Protecting Your APIs Against Attack & Hijack
How LinkedIn changed its security model in order to offer an API
Cloud Native API Design and Management

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Machine Learning_overview_presentation.pptx
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation_ Review paper, used for researhc scholars
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
The AUB Centre for AI in Media Proposal.docx
Diabetes mellitus diagnosis method based random forest with bat algorithm
MYSQL Presentation for SQL database connectivity
Review of recent advances in non-invasive hemoglobin estimation
sap open course for s4hana steps from ECC to s4
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Machine Learning_overview_presentation.pptx

Kiwipycon command line

  • 1. Giving your website a command line interfaceMichael Hudson-Doylemichael.hudson@linaro.org
  • 2. Linaro and its missionLinaro aims to make Linux work better on ARM processors
  • 3. The ProblemThe ARM ecosystem is very fragmented, and the kernel has a lot of copy and paste code"Gaah. Guys, this whole ARM thing is a f*cking pain in the ass."— Linus Torvalds, 17 Mar 2011https://lwn.net/Articles/437170/
  • 4. Enter Linaro!"Linaro is a not-for-profit software engineering company investing in core Linux software and tools for ARM SoCs."Also about educating the members in how to do open source development...
  • 5. LAVA - Linaro Automated ValidationA bit part of Linaro is about automated validation:Find regressions earlier
  • 7. Maybe even power management changes too...LAVAWe have a bunch of hardware
  • 8. LAVASome scripts and tricks that can boot a board with a new kernel and run some tests.Quick Demo(ever the optimist)
  • 9. LAVAAnd a website that lets you see whats going on
  • 10. The Problem (finally!)We want to do things like trigger test runs when a kernel build finishes.This basically means some kind of Remote Procedure Call (RPC).
  • 11. ParanoiaFor a bunch of reasons, we need some kind of security in our system:The boards in our lab are a limited resource
  • 12. Some risk of mischief
  • 13. Eventually may have test results from unreleased hardware or benchmarks with licenses that forbid publication of resultsProtocol ChoicesWe use XML-RPC
  • 14. We didn't think about this very hard but it is well supported in most languages
  • 15. Will probably add JSON-RPC support at some point for easier browser accessFirst idea: OAuthAn open protocol to allow secure API authorization in a simple and standard method from desktop and web applications.– http://oauth.net/
  • 16. The great thing about standards...<bob2> kennethreitz: oauth is a font of villany and dispair -- #python, Jun 09 11:55:08
  • 17. Also doesn't solve our problemOAuth specifies that various aspects of the request are signed, but not, crucially for us, the body of the request – an important detail, because in XML-RPC the body of the request is where all the important stuff is.
  • 18. Transport Layer Security, here we comeIf you're going as far as to cryptographically sign something, it's not much further to go to actually just encrypt it!
  • 19. And what does everyone know about encryption?Don't implement it yourself(i.e. use HTTPS)
  • 20. Back to BasicAnd if you're operating over HTTPS, you might as well just just good old RFC 2617 Basic Authentication...... but with tokens rather than passwords
  • 21. Tokens > PasswordsBecause we expect the RPC to be invoked from build systems and so on, there is a moderate chance of the token being leaked – so it should not let you take over the owning user's account.In the future, a token might only let you access some APIs.
  • 22. Also, we use SSO...In addition we use Launchpad's SSO service for authentication, so most users don't have a LAVA password!
  • 23. Show me the code!On the server side, we've built a library that lets you add a authenticating XML-RPC to a Django project:https://launchpad.net/linaro-django-xmlrpcIt includes views and models (and very very simple templates) for creating and managing tokens.
  • 24. Server side codeexample/api.py:from linaro_django_xmlrpc.models import ExposedAPIfrom linaro_django_xmlrpc.globals import mapperclass ExampleAPI(ExposedAPI): def whoami(self): if self.user: return self.user.username else: return Nonemapper.register(ExampleAPI)in your urlconf: url(r'', include('linaro_django_xmlrpc.urls')),
  • 25. Client side libraryThis isn't properly factored yet really (it's it all mashed up with our toolkit for doing command line tools), but the code is in "lava-tool":https://launchpad.net/lava-toolIt uses python-keyring for token management.
  • 26. Client-side codefrom lava_tool.authtoken import \ AuthenticatingServerProxy, KeyringAuthBackendauth_backend = KeyringAuthBackend()auth_backend.add_token( "user", "http://server/RPC2/", token)sp = AuthenticatingServerProxy( "http://user@server/RPC2/", auth_backend=auth_backend)print server.whoami()
  • 27. Demo(assuming the first one wasn't a disaster)
  • 28. ConclusionThe lesson:Don't try to be clever – just use HTTPS and Basic auth.The code:lp:linaro-django-xmlrpclp:lava-tool