180 likes | 407 Views
Public Facing API’s. Simon Free Senior Developer. Topics. What are APIs? Why would you create an API? What can you do with APIs? How are APIs created with ColdFusion Planning Rules Pitfalls Security Development Strategies. What are APIs?. Application Programming Interface
E N D
Public FacingAPI’s • Simon Free • Senior Developer
Topics • What are APIs? • Why would you create an API? • What can you do with APIs? • How are APIs created with ColdFusion • Planning • Rules • Pitfalls • Security • Development Strategies
What are APIs? • Application Programming Interface • A collection of methods, functions, procedures or protocols available to developers • They can be private, public or on limited access • A gateway into your system
Why would you create an API? • Allow for code reuse and / or service reuse • Allow for access via different mediums • Increase use of your product (think twitter) • Allow your product to be combined with another product (Mash-ups) • Let the community to do all the work for you :-)
What can you do with an API? • Pretty much anything! • Post and return data • Return small and large amounts of data • Open up a security hole in your system a mile wide that will allow people to steal all your data, access the client database and cause you to have endless amounts of legal problems and eventually drive you to php or worse, .NET
How are APIs created with CF? • cfc’s with access set to remote • Usually a singular cfc is the access point • Other cfc’s can be accessed via the access cfc (similar to a facade)
Planning • Think of all technologies • Think of common tasks and make them one call • Limit the number of calls needed • Create a standardized data return structure • If there is an error should that break the mold? How are they going to be handled? • Document
Rules • Return XML • For success and failure keep the same structure • Keep function names the same style • Only have necessary functions set to remote • Add hints, comments and display names • DOCUMENT!!!!
Pitfalls • Can not rely on the session scope • If you are not using cfc’s already you will spend a lot of re-factoring • Fulfilling everyones needs without overloading on data • Over complicating the process for the user • Opening up a potential security hole • lack of DOCUMENTATION!!!!!!!
Security • The biggest security risk is YOU! • Do not give detailed error messages • Track # of incorrect logins and block people if necessary • Use a token authentication system • Never pass back session information
Security cont. • When returning an ID use uuid • Don’t return sensitive information • Try and limit the amount of data returned (say 50 records)
Development Strategies One Pot
Development Strategies Facade
Development Strategies Facade
Development Strategies Half and Half
Thats All! • Questions or Comments? • simon@simonfree.com • Slides will be posted at: • http://www.simonfree.com