SlideShare a Scribd company logo
Curriculum:
Authentication, Validation & Basic Testing
Spring, 2016
Authentication, Validation, & Testing PART 1
1.) Authentication (~ 60 minutes)
2.) Validation (~ 30 minutes)
3.) Pairing (~30 minutes)
Agenda
Introductions
Matthew Gerrior
Devpost, Head of Engineering
ABOUT ME
● Grew up outside Boston
● Went to school upstate
● Worked in consulting for ~ 3.5 years
● Got tired of building other people’s products
● Moved to NYC to join Devpost (known as
ChallengePost at the time)
devpost.com/MGerrior
Devpost
Get an inside look at Dev teams who are hiring
ABOUT US
● Online Hackathons (Uber, Oculus, AT&T)
● In-Person Hackathons (PennApps, HackNY)
● Developer Portfolios to showcase skills,
technologies, projects
● Team Pages give an inside look at hot
startups in NYC (Blue Apron, Buzzfeed,
Genius)
devpost.com/teams
ScriptEd
Coding Skills for under-resourced schools
ScriptEd equips students in under-resourced schools with the fundamental
coding skills and professional experiences that together create access to
careers in technology.
● GitHub accounts from Day 1
● Two hackathons every year
● Field trips to Tech Companies
● Summer internship opportunities
Authentication
Cookies
Cookies
- Key-value data pairs
- Stored in the user’s browser
- Stored until they reach their specified expiration
data.
Cookies
Cookies
Good for:
- Storing temporary data
- Storing data that isn’t sensitive
Bad for:
- Storing permanent/persistent data
- Storing sensitive data like passwords or
shopping carts
Cookies
Why is it bad to store sensitive data or persistent
data in a cookie?
- Very easy for users to delete cookies
- Doesn’t persist across browser sessions/devices
- Easy to steal/manipulate cookies
Cookies
Cookies
Cookie Jars
Rails also provides access to two
cookie jars:
- “Signed” cookies prevent
tampering by the end user by
signing the cookies with your
applications “Secret Base Key”
- “Encrypted” cookies are secured
even further by first encrypting
the values, and then signing them
with the “Secret Base Key”
Cookie Jar
Session
Session
How can we tell which user is making a request to
our site if HTTP requests are stateless?
Rails stores a cookie on the user’s browser
containing their session hash.
- Secure
- Tamper-Proof
- Expires when the browser is closed
Session
Session
That looks like the cookies you just taught us about,
why do we need both?
The session is an entire hash that gets stored in a
secure cookie that expires when the browser is
closed. Each value in the cookies hash is stored as an
individual cookie, since they are key-value data pairs.
Session
- Not really a hash, that’s just how Rails presents it
to you to make it easier to work with. Cookies
are not hashes either.
- Size of an individual cookie is limited to roughly
4kb, which is sufficient for normal usage, but
prevents them from acting as a database of any
sort.
Session
Session
Which Session Store should I choose?
- Cookie store is the default, and recommended
store. It’s lightweight and requires zero setup in
a new application to use.
Session
Why would I use a different store then?
- You need more than 4kb of session data
- You probably don’t, but sometimes you do
- Cookies are sent along with every request you
make
- Bigger Cookies means bigger (and slower)
requests
Session
- If you accidentally expose your
“secret_base_key”, users can change their
session data
- Since the key is used to sign/encrypt the
cookie, exposing the key exposes the
session
- Storing the wrong kind of data is insecure
- Vulnerable to attacks like the replay attack if
sensitive data stored in cookie
Session
What is it useful for besides knowing which user is
currently logged in?
Session
Session
Flash
Flash
Special “hash” that persists only from one request to
the next. A self-destructing session hash.
Commonly used for sending messages from the
controllers to the view, because they persist across a
redirect from a “New Object” form to the details
page for that object.
Flash
Flash
Flash
Flash
Why can’t I just use instance variables?
Instance variables only exist for the current request,
and are lost when a new request takes place such as
when the user is redirected.
Flash
What if I’m not redirecting the user and I’m just
rendering a page?
Make flash messages available to the current
request using flash.now just like you would with a
regular flash.
Flash
Devise
Devise
Flexible authentication solution for Rails with
Warden.
https://github.com/plataformatec/devise
Authenticating users is easy. I’ll just build a
SessionsController with some CRUD actions and
store the user id in the cookie. Problem solved.
Devise
No. Authenticating users is not easy. What about:
- Securely storing user passwords
- Confirming email addresses?
- Log in With Twitter/GitHub/Facebook?
- Forgot Password email?
- Remember me checkbox?
Devise
You’re not getting paid to build an authentication
system (unless you are), you’re getting paid to build
a new and exciting product that no one has ever
built before.
Devise
Hashes and stores a password in the database to
validate the authenticity of a user while signing in.
Devise
Database Authenticatable
Adds OmniAuth (sign in with
Twitter/Facebook/GitHub/whatever) support.
Devise
Omniauthable
Sends emails with confirmation instructions and
verifies whether an account is already confirmed
during sign in.
Devise
Confirmable
Resets the user password and sends reset
instructions.
Devise
Recoverable
Handles signing up users through a registration
process, also allowing them to edit and destroy their
account.
Devise
Registerable
Manages generating and clearing a token for
remembering the user from a saved cookie.
Devise
Rememberable
Tracks sign in count, timestamps and IP address.
Devise
Trackable
Expires sessions that have not been active in a
specified period of time.
Devise
Timeoutable
Provides validations of email and password. It's
optional and can be customized, so you're able to
define your own validations.
Devise
Validatable
Locks an account after a specified number of failed
sign-in attempts. Can unlock via email or after a
specified time period.
Devise
Lockable
Should I always use Devise?
No, not always. There are other alternatives such as
Sorcery that provide authentication.
More importantly, it is a very enlightening exercise to
try to build your own authentication system from
scratch (just not for a production application).
Devise
Where can I learn more about rolling my own
authentication system?
● Michael Hartl's online book: https://www.railstutorial.
org/book/modeling_users
● Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-
from-scratch
● Codecademy's Ruby on Rails: Authentication and Authorization: http:
//www.codecademy.com/en/learn/rails-auth
Devise
Validation
Validation
- Make testing/maintenance more difficult
- Beneficial when multiple applications access
database
- Can handle some constraints more efficiently
than application-level code
Database-level Validation
- Convenient way to provide immediate feedback
without submitting form/performing request
- Unreliable if used alone and implemented in
JavaScript, as they can easily be bypassed.
Validation
Client-side Validation
- Unwieldy to use and difficult to test/maintain
- Goes against the Skinny Controller/Fat Model
design paradigm of Rails
Validation
Controller-level Validation
- Best way to ensure that only valid data is stored
in the database
- Database agnostic
- Cannot be bypassed by end users
- Convenient to test and maintain
Validation
Model-level validations
- Important to ensure consistency in your
database
- Easier to render things like user profiles if you
know things like name are guaranteed to be
present
- Ensure proper functioning of application by
enforcing things like uniqueness of screen
names, or valid formats of email addresses.
Validations
Validations
Validations
Validations
Validations
Acceptance
Validations
Associated
Validations
Confirmation
Validations
Exclusion
Validations
Format
Validations
Inclusion
Validations
Length
Validations
Numericality
Validations
Presence
Validations
Absence
Validations
Uniqueness
Validations
Validations
Validations
Validations
Validations
Validations
Validations
Validations
Validations
Testing
Testing
TDD - Test Driven Development
Testing
TDD
Testing
RSpec
Testing
RSpec
Testing
RSpec & TDD
Testing
RSpec & TDD
Testing
RSpec & TDD
Testing
- Earliest phase of testing
- Focuses on individual unit or component
- Best/Easiest phase to catch bugs in
- Can have 100% passing unit tests but still have
code that doesn’t work as intended
Unit Testing
- Ensure that model validations are present
- Ensure that relationships exist with correct
options
- Ensure helper methods perform as expected
Testing
Unit Testing
Testing
Unit Testing
Testing
Unit Testing
Testing combinations of separate
components/modules that have been independently
unit tested already.
Testing
Integration Testing
Testing
Integration
Testing
Integration
Testing
http://i.imgur.com/qSN5SFR.gifv
Integration
Testing
Verifying that all of the product/business needs have
been met and that end users have the desired
experience.
Acceptance
Testing
Cucumber (with Gherkin)
Testing
Cucumber (with Gherkin)
Testing
Cucumber (with Gherkin)
Testing
Capybara
Testing
Capybara
Testing
Resources
http://www.theodinproject.com/ruby-on-
rails/sessions-cookies-and-authentication
https://gorails.com/episodes/user-authentication-
with-devise
http://www.bitspedia.com/2012/05/how-session-
works-in-web-applications.html
http://www.justinweiss.com/articles/how-rails-
sessions-work/
http://www.w3schools.
com/bootstrap/bootstrap_alerts.asp
https://github.com/plataformatec/devise
http://guides.rubyonrails.
org/active_record_validations.html
http://blog.arkency.com/2014/04/mastering-rails-
validations-contexts/
https://octoberclub.files.wordpress.
com/2011/10/red-green-refactor.png
http://david.heinemeierhansson.com/2014/tdd-is-
dead-long-live-testing.html
Resources
http://www.rainforest-alliance.
org/sites/default/files/uploads/4/capybara-
family_15762686447_f9f8a0684a_o.jpg
http://www.can-technologies.
com/images/services/test2.png
http://stumbleapun.magicalfartwizard.org/wp-
content/uploads/2011/06/just-the-tips.jpg
http://stumbleapun.magicalfartwizard.org/wp-
content/uploads/2011/06/just-the-tips.jpg
Resources
http://www.seguetech.com/blog/2013/07/31/four-
levels-software-testing
http://softwaretestingfundamentals.com/unit-
testing/
https://www.inflectra.com/Ideas/Topic/Testing-
Methodologies.aspx
http://www.can-technologies.
com/images/services/test2.png
Resources

More Related Content

What's hot (18)

PDF
Social Connections VI Prague - An introduction to ibm connections as an appde...
Mikkel Flindt Heisterberg
 
PDF
Ajax learning tutorial
bharat_beladiya
 
DOC
QuickConnect
Annu G
 
PPTX
Web 2.0 security woes
SensePost
 
PPT
Top Ten Tips For Tenacious Defense In Asp.Net
alsmola
 
PPTX
SSO IN/With Drupal and Identitiy Management
Manish Harsh
 
PDF
Authentication: Cookies vs JWTs and why you’re doing it wrong
Derek Perkins
 
PPTX
Token Authentication for Java Applications
Stormpath
 
PPTX
Html5 Fit: Get Rid of Love Handles
Chris Love
 
PDF
Our application got popular and now it breaks
ColdFusionConference
 
PPTX
Responsive Web Design for Universal Access 2016
Kate Walser
 
PDF
Difference between authentication and authorization in asp.net
Umar Ali
 
PPTX
Microsoft Azure Identity and O365
Kris Wagner
 
PPTX
Advanced Error Handling Strategies for ColdFusion
Mary Jo Sminkey
 
PPTX
Secure Your REST API (The Right Way)
Stormpath
 
PPTX
Build A Killer Client For Your REST+JSON API
Stormpath
 
PPTX
User Authentication and Cloud Authorization in the Galaxy project: https://do...
Vahid Jalili
 
PDF
Web Development for UX Designers
Ashlimarie
 
Social Connections VI Prague - An introduction to ibm connections as an appde...
Mikkel Flindt Heisterberg
 
Ajax learning tutorial
bharat_beladiya
 
QuickConnect
Annu G
 
Web 2.0 security woes
SensePost
 
Top Ten Tips For Tenacious Defense In Asp.Net
alsmola
 
SSO IN/With Drupal and Identitiy Management
Manish Harsh
 
Authentication: Cookies vs JWTs and why you’re doing it wrong
Derek Perkins
 
Token Authentication for Java Applications
Stormpath
 
Html5 Fit: Get Rid of Love Handles
Chris Love
 
Our application got popular and now it breaks
ColdFusionConference
 
Responsive Web Design for Universal Access 2016
Kate Walser
 
Difference between authentication and authorization in asp.net
Umar Ali
 
Microsoft Azure Identity and O365
Kris Wagner
 
Advanced Error Handling Strategies for ColdFusion
Mary Jo Sminkey
 
Secure Your REST API (The Right Way)
Stormpath
 
Build A Killer Client For Your REST+JSON API
Stormpath
 
User Authentication and Cloud Authorization in the Galaxy project: https://do...
Vahid Jalili
 
Web Development for UX Designers
Ashlimarie
 

Viewers also liked (16)

PPTX
Pec4 final version cortina.pptx
Carlos Mario Cortina
 
PDF
POSTER 1
Bethany Lilly
 
PDF
4.1.4torque
Talia Carbis
 
PDF
Les a2 1 2-2012
SpaanIt
 
PDF
Professional Media Kit for Alex Ihama (v2017)
Alex Ihama
 
DOCX
Leeson plan for Septa3
Alina John
 
PDF
LocalGeo Торговый центр
Александр Васильев
 
PPTX
Introducing Virtual Reality in Your Geography Classroom
Michael DeMers
 
PPT
eidan mosa ali alzahrani- evaluation and measurement- educational administration
alzahrani_eidan
 
PDF
Grobuchkina tsc ekbpromo_almaty_2016
ekbpromo
 
PDF
Sklad russia 2016
ekbpromo
 
PDF
Resumen Phyla reino Animalia
Fernanda Monguí
 
PPTX
(Webinar Slides) Choosing Legal Tech for Your Office
MyCase Legal Case and Practice Management Software
 
PPT
Fijacion del nitrogeno ppt
Marcia Pereira
 
PPTX
Passive voice
becorbedomi99
 
DOCX
doc
Serena Lee
 
Pec4 final version cortina.pptx
Carlos Mario Cortina
 
POSTER 1
Bethany Lilly
 
4.1.4torque
Talia Carbis
 
Les a2 1 2-2012
SpaanIt
 
Professional Media Kit for Alex Ihama (v2017)
Alex Ihama
 
Leeson plan for Septa3
Alina John
 
LocalGeo Торговый центр
Александр Васильев
 
Introducing Virtual Reality in Your Geography Classroom
Michael DeMers
 
eidan mosa ali alzahrani- evaluation and measurement- educational administration
alzahrani_eidan
 
Grobuchkina tsc ekbpromo_almaty_2016
ekbpromo
 
Sklad russia 2016
ekbpromo
 
Resumen Phyla reino Animalia
Fernanda Monguí
 
(Webinar Slides) Choosing Legal Tech for Your Office
MyCase Legal Case and Practice Management Software
 
Fijacion del nitrogeno ppt
Marcia Pereira
 
Passive voice
becorbedomi99
 
Ad

Similar to Startup Institute NY - Authentication, Validation, and Basic Testing (20)

PDF
CIS14: Authentication: Who are You? You are What You Eat
CloudIDSummit
 
PPTX
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
edm00se
 
PPT
Session and cookies,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
1,2,3 … Testing : Is this thing on(line)? with Mike Martin
NETUserGroupBern
 
PDF
Brown aug11 bsdmag
Dru Lavigne
 
PPTX
Job portal at jiit 2013-14
kbabhishek4
 
PPTX
Developer Night - Opticon18
Optimizely
 
PPTX
Code your Own: Authentication Provider for Blackboard Learn
Dan Rinzel
 
PDF
Azure for AWS & GCP Pros: Which Azure services to use?
Daniel Zivkovic
 
PPTX
SEO benefits | ssl certificate | Learn SEO
devbhargav1
 
PPT
A A A
Cristian Vat
 
PPTX
Job portal
LoveBug Shashank
 
PDF
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
HashiCorp
 
PPT
session and cookies.ppt
Jayaprasanna4
 
PDF
wapt lab 6 - converted (2).pdfwaptLab09 tis lab is used for college lab exam
imgautam076
 
PPT
Proxy Caches and Web Application Security
Tim Bass
 
PPTX
Creating a Single Source of Truth: Leverage all of your data with powerful an...
Looker
 
PDF
The Testing Planet Issue 2
Rosie Sherry
 
PPTX
Cookies authentication
Rsilwal123
 
PPTX
Zendesk User Group - May 14 2013 - OpenDNS & Zendesk
Scott Cressman
 
CIS14: Authentication: Who are You? You are What You Eat
CloudIDSummit
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
edm00se
 
Session and cookies,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
1,2,3 … Testing : Is this thing on(line)? with Mike Martin
NETUserGroupBern
 
Brown aug11 bsdmag
Dru Lavigne
 
Job portal at jiit 2013-14
kbabhishek4
 
Developer Night - Opticon18
Optimizely
 
Code your Own: Authentication Provider for Blackboard Learn
Dan Rinzel
 
Azure for AWS & GCP Pros: Which Azure services to use?
Daniel Zivkovic
 
SEO benefits | ssl certificate | Learn SEO
devbhargav1
 
Job portal
LoveBug Shashank
 
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
HashiCorp
 
session and cookies.ppt
Jayaprasanna4
 
wapt lab 6 - converted (2).pdfwaptLab09 tis lab is used for college lab exam
imgautam076
 
Proxy Caches and Web Application Security
Tim Bass
 
Creating a Single Source of Truth: Leverage all of your data with powerful an...
Looker
 
The Testing Planet Issue 2
Rosie Sherry
 
Cookies authentication
Rsilwal123
 
Zendesk User Group - May 14 2013 - OpenDNS & Zendesk
Scott Cressman
 
Ad

Recently uploaded (20)

PPTX
Library_Management_System_PPT111111.pptx
nmtnissancrm
 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PPTX
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
PPTX
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PDF
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
PPTX
From spreadsheets and delays to real-time control
SatishKumar2651
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PDF
Is Framer the Future of AI Powered No-Code Development?
Isla Pandora
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Library_Management_System_PPT111111.pptx
nmtnissancrm
 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
From spreadsheets and delays to real-time control
SatishKumar2651
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
Is Framer the Future of AI Powered No-Code Development?
Isla Pandora
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 

Startup Institute NY - Authentication, Validation, and Basic Testing