Laravel. View, Forms, Input, Validation, Authentication Layer. Web Technologies II. Darja Solodovnikova. Adopted from Artūrs Lavrenovs

Size: px
Start display at page:

Download "Laravel. View, Forms, Input, Validation, Authentication Layer. Web Technologies II. Darja Solodovnikova. Adopted from Artūrs Lavrenovs"

Transcription

1 Laravel View, Forms, Input, Validation, Authentication Layer Web Technologies II Darja Solodovnikova Adopted from Artūrs Lavrenovs

2 View Visual representation of a model Job is simple - take variable and output it inside HTML (or other markup) Default approach (for most frameworks) HTML with PHP snippets echoing variables Laravel has Default View engine (most PHP MVC frameworks also have such) Blade templating engine

3 Laravel Default View Goal of the most browser requests is to receive a rendered view You have to return the result from the Controller Code to call View rendering View::make($viewname, $data); Where View is Laravel view class and make is method rendering the view $viewname is the name of the view, actual view is stored as $viewname.php in resources/views/ $data is associative array containing data to display which gets expanded inside a view Alternative view($viewname, $data);

4 Laravel Simple View File HTML file containing PHP code for only printing variables received only from $data Code inside app/http/routes/web.php Route::get('/post/{action}/{post_id?}', function($action, $post_id = "default") { $data = array('action'=>$action,'postid'=>$post_id); return view('simple', $data); }); Code inside resources/views/simple.php <!doctype html> <html lang="en"> <head><meta charset="utf-8"> <title><?php echo $action;?></title> </head> <body><p><?php echo $postid;?></p></body> </html>

5 Blade Templating Engine

6 Why Blade? Default View approach still has some ugliness inside HTML template PHP tags <?php?> echo and ; Additional processing of output htmlspecialchars() or htmlentities() Loops with { } Blade replaces most of the PHP ugliness with its own cleaner syntax But does not restrict you from using plain PHP Views are compiled into plain PHP code and cached until they are modified zero overhead

7 How to Use Blade Put Blade templates in resources/views But there is a difference in naming, Blade templates should be named $viewname.blade.php Calling the view is the same View::make($viewname, $data); or view($viewname, $data);

8 Blade Syntax Outputting Variables To output the variable, use {{ $variable }} It automatically converts HTML entities and acts as a defense against XSS If you do not need escaping and you are sure data is not from user input then you can use {!! $variable!!} If you aren't sure if the variable has been set {{ $variable or 'Default' }} Other special Blade things are prefixed

9 Blade Control Structures ($color == 'white') <p>good ($color == 'black') <p>classic ($color == 'white') <p>color is not

10 Blade Control Structures ($names as $name) <p>{{ ($i = 0; $i < 99; $i++) <p>{{ $i (false) <p>should not see

11 Blade Control Structures Loop Variable $loop variable is available inside the ($conferences as ($loop->first) This is the ($loop->last) This is the last <p>this is a conference {{ $conf->name Other properties $loop->index, $loop->iteration, $loop->remaining, $loop->count $loop->depth, $loop->parent

12 Blade Templating All of the above was just a syntactic sugar Blade best features are templating which allows to get rid of the majority HTML in view files Separating data output from HTML These features are Inclusion join multiple separate views Inheritance inherit view skeleton Sectioning separating HTML from data output

13 Blade Parent Template (master.blade.php) <html> <head> </head> <div </div> </body> </html>

14 @extends('master') Blade Child Template without 'Conferences') ($i = 0; $i < count($conferences); $i++) <p>conference {{$i}}

15 Using Blade for Elements of @each('confinfo', $conferences, confinfo.blade.php <p>name: {{$conference->name}}</p> <p>description: {{$conference->description}}</p>

16 URL Laravel offers helper functions to deal with URL Generate full URL - includes domain and protocol Eliminates mistakes using absolute/relative paths Usable inside Views {{ }} and other code Code url('login') will generate for our project Similarly asset() allows to generate link to static content in case you move your static files to other place (like CDN) If you use route() and action() inside your Views Actual URL will change automatically These functions maps to routes and controllers not fixed path

17 URL Redirection Action of telling user browser to go to a different URL, handled by HTTP 3xx codes Usually you want redirect functionality in your web application For login, logout, registration Laravel code for redirects return redirect('/'); return redirect()->route('hotel.index'); return redirect()->action('hotelcontroller@index');

18 Laravel Collective Forms

19 Forms Creating forms in HTML can be gruesome task Creating forms with HTML and PHP (populating data) even gruesomer task It is possible to use special syntax to define and populate your forms in the View using Form class Generated Form has CSRF token For advanced functionality (e.g., Form autofilling from Model, resetting, custom buttons) review documentation

20 Laravel Collective Forms Older versions of Laravel supported forms (Illuminate/Html/FormBuilder) Laravel 5 does not support Forms out of the box Forms are maintained by Laravel Collective Installation composer require laravelcollective/html In config/app.php add new provider Collective\Html\HtmlServiceProvider::class, to the providers array In config/app.php add new class aliases to the aliases array: 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class,

21 Creating Form Form is just another View, create View and use it from Controller or route You need to open the Form inside the View, you can use static url, routes, controllers as target {!! Form::open(array('url' => 'login'))!!} //Put your form fields here! {!! Form::close()!!} To imitate PUT and DELETE methods add a hidden field _method to the form {!! Form::open(array('url' => 'login', 'method' => 'put'))!!}

22 Creating Form fields To create field description (label) bound by name {!! Form::label(' ', ' Address')!!} After creating a label, any form element you create with a name matching the label name will automatically receive an ID matching the label name as well. To create text field (most common type of field), argument is name {!! Form::text(' ')!!} To create other type of fields use other Form methods textarea(), password(), checkbox(), radio(), select(), file(), hidden(), etc.

23 Filling Form Fields with Default Values You can fill form fields with default values or data from the database Depending on the field type, the default value can be after the name as the 2nd argument {!! Form::text(' ', Some types of fields allow selecting/checking them by using the 3rd argument {!! Form::checkbox('receive_ ', 'yes', true)!!}

24 Submitting Form You can submit forms by pressing Enter Usually users expect some button to be pressed to submit forms In Laravel Form you can add submission button {{ Form::submit('login') }}

25 Form Model Binding You can populate form elements with data from the model automatically {!! Form::model($conference, ['method' => 'PUT', 'url'=> ['conference.update', $conference->id]])!!} Now all form elements will be filled with the model's value matching the field's name. However, if there is an item in the Session flash data matching the input name, that will take precedence over the model's value. The priority looks like this: Session flash data (old Input) Explicitly Passed Value default values Model attribute data

26 Model Form Example {!! Form::model($conference, ['method' => 'PUT', 'url'=> ['conference.update', $conference->id]])!!} <div> {!! Form::label('name', 'Name')!!} {!! Form::text('name')!!} </div><div> {!! Form::label('acronym', 'Acronym')!!} {!! Form::textarea('acronym')!!} </div><div> {!! Form::label('rating', 'Rating')!!} {!! Form::number('rating')!!} </div> {!! Form::submit('Save')!!} {!! Form::close()!!}

27 Input

28 User Input $_GET is not the recommended way of handling user input in Laravel Path parameters using routes or Controller mapping allow a way for accessing simple/short data from the users, also use for only reading data Complicated input and also data modification (CUD from CRUD) should be handled by POST requests default for Laravel Collective Forms from the previous chapter

29 Laravel Input We already reviewed how to access Path parameters in routes and Controllers POST (and GET) input is accessed by Input class But there are also other often forgotten methods of user input COOKIES SESSION REQUEST itself

30 Input Class - input() Helper Function We will use it to handle POST data but can be used also for GET You can get all the input with $request->all(); or single variable $request->input('name'); or $request->name; Default value $request->input('name', 'Default Name'); Can get multiple variables $request-> only('username', 'password'); or remove some $request->except(' '); Check if variable is provided $request->has('name') or is filled $request->filled('name')

31 input()helper Example public function update(request $request, $id) { $city = City::findOrFail($id); $city->fill($request->all()); $city->save(); return redirect('city'); } In City.php protected $guarded = ['id', 'created_at', 'updated_at'];

32 Cookie Class - cookie() helper function Cookies allow to store some (small) data in the clients browsers Laravel Cookies are signed and encrypted users don't see Cookie value only name when accessing Cookies, Laravel will check if they have been tampered with Still you should not completely rely of the data being good, e.g., user can remove a cookie or put a different cookie Cookies should be used for something Not important, e.g., template choice and not storing user rights Not associated with User Model, e.g., template choice for unregistered user Old school: Cookies were used to communicate between PHP and JavaScript, now should use AJAX

33 Using Cookie Cookies may be attached to a Illuminate\Http\Response instance For specified time span, where 3rd argument is minutes $response->withcookie(cookie('color', 'blue', 10)); Forever (technically 5 years) $response->withcookie(cookie()-> forever('color', 'blue')); Cookies are read by $request->cookie('color');

34 Using Cookie with a view $response = new Response(view('welcome')); $response->withcookie(cookie('referrer', $request->referrer, 45000)); return $response; public function index() { Cookie::queue('visible', true, 15); return view('dashboard'); }

35 Session Class - flash() helper functions Session is the way to store data associated to the user on the server (opposite to cookie) As a result, you can put there all the important data and user specific data, you can trust this data Using session, Laravel allows you to keep input from one request during the next request. This feature is particularly useful for re-populating forms after detecting validation errors. Session is created for ALL requests (not only logged in users) by creating cookie laravel_session with unique id This id is used to map between browser and session data Session limitations By default session lives short time (in Laravel 2h) Session storage (FS/DB/RAM) can cause performance issues

36 Using Session Session works as key value store, same as cookie Creating new session field $request->session()->put('color', 'blue'); Using array as the value $request->session()->push('colors', 'blue'); $request->session()->push('colors', 'red'); Flashing input to the session All $request->flash(); Part of input $request->flashonly('title', 'body'); $request->flashexcept('password');

37 Using Session II Retrieving session data By key $request->session()->get('color'); All $request->session()->all(); Old data $request->old('name'); Deleting session data Retrieving and then deleting $request-> session()->pull('color'); Single $request->session()-> forget('color'); or all $request->session()->flush();

38 Request Class You can access data associated with a request Get Request object in the controller method public function update(request $request, $id) Methods to retrieve data from a request URI $request->path(); and $request-> is('admin/*'); full URL $request->url(); Method $request->method(); and $request->ismethod('post') Headers $request->header('useragent'); Server variable $request-> server('script_filename'); Be careful this data could be affected by the user

39 Validation

40 Input Validation User input data is the evil that causes the most problems Checking user input in Vanilla PHP is gruesome and error prone task Laravel filters 2 biggest input problems SQL and XSS injections well automatically (if you don't make errors) Still you should filter data to match your business logic Such filtering in Laravel is done using Validation class

41 Simple Approach to Validation $this->validate($request, $rules); If the validation passes the execution will continue. If the validation fails the user will be redirected to his/her previous location. Validation errors will automatically be flashed to the session. You can access validation errors in $errors variable.

42 Validator Class To validate input data $validator = Validator::make($data, $rules); Where $data is user input, e.g., Input::all() or $request Where $rules is an associative array where Keys are the name of Form input field Values are the validation rules After validation you can Determine result: $validator->passes() or $validator->fails() Get error messages: $validator->messages() Validation is complex topic so we will review example

43 Validation Rules for a Form $rules = $rules = array( 'name' => 'required min:3 max:250', 'description' => 'required min:3', 'city' => 'required exists:cities,id', 'rating' => 'required integer min:0 max:5', 'price' => 'required numeric', 'logo' => 'required image mimes:jpeg', ); $this->validate($request, $rules); More validation rules are available in the documentation

44 Error Messages in the (count($errors) > 0) <div> ($errors->all() as $error) <li>{{ $error </ul>

45 Error Messages for Each Field {!! Form::open(['action' => <div> {!! Form::label('name', 'Conference name')!!} {!! ($errors->has('name')) <span class="help-block"> <strong>{{ $errors->first('name') }}</strong> </div><div> {!! Form::label('description', 'Description')!!} {!! as $message) <span class="help-block"> <strong>{{ $message }}</strong> </div> {!! Form::submit('Create')!!} {!! Form::close()!!}

46 For More Complex Tasks Create a form request php artisan make:request UpdateCountryRequest Define validation rules public function rules() { return ['name' => 'required alpha_dash min:5 max:20 unique:countries,name,'.$this->route()-> getparameter('country')]; } Type-hint the request on your controller method public function update(updatecountryrequest $request, $id) You can also check, whether a user has rights to update the country in the method authorize()

47 Validation Summary Laravel simplifies working with input data There are a lot of validation rules available If the validation does not pass the user is redirected back Error display Validation errors are automatically included into session $errors variable is available in all the Views In the View Forms you can access and display error for each field Generated errors are human readable and directly usable (if necessary, you can define your own messages

48 Laravel Authentication Layer

49 Authentication User authentication is a common functionality of a generic web application Laravel provides authentication layer built on top of the User Model It is meant for you to integrate authentication layer in your own code, e.g., adding middleware We will review only the basics of authentication

50 Authentication out of the Box Auth\RegisterController handles new user registration. Auth\LoginController handles authenticating users for the application Auth\PasswordController contains the logic to help existing users reset their forgotten passwords. Authenticate middleware (accessed as auth) is used to allow only authenticated users to access a given route. Model User with automatic password encryption

51 RegisterController LoginController Methods for handling logging and registering If login/registering was unsuccessful by default the user is redirected to the login page and $errors variable is populated with login error If login/registering was successful by default the user is redirected to the home page (/home).

52 Adding Authentication Run php artisan make:auth on fresh application, which creates layout and views for login, registering (resources/views/auth) routes for all authentication end-points HomeController to handle post-login requests Optionally in the RegisterController and LoginController define The path for successful authentication protected $redirectpath = '/conf';

53 Checking if User is Logged in To check if user is logged in (previous slide) if (Auth::check()) { // You should use this to change // parts of the web page // depending of login status } Laravel uses User Model so when user is logged in you can access User fields $ = Auth::user()-> ; $user_id = Auth::id;

54 Example Usage in RegistrationUpdateRequest public function authorize() { if (Auth::check()) { $regid = $this->route('registration'); return Registration::where('id', $regid)-> where('user_id', Auth::id())-> exists(); } return false; }

55 Checking if User is Logged in II But if you want to limit access to the whole Routes or Controllers you should use Middleware Route::get('profile', ['middleware' => 'auth', function() { }]); // Only authenticated users may enter... public function construct() { } $this->middleware('auth', ['except' => 'index']);

56 We Have Finished Laravel We have reviewed only the Laravel basics required to build simple generic web application Most of the reviewed functionality can be combined or utilized in more efficient manner We have skipped A LOT of useful stuff We have not touched any of the advanced stuff Now you have to study Laravel documentation on Your own

Laravel. Routing Filtering Model View Controller. Web Technologies II Artūrs Lavrenovs

Laravel. Routing Filtering Model View Controller. Web Technologies II Artūrs Lavrenovs Laravel Routing Filtering Model View Controller Web Technologies II Artūrs Lavrenovs Laravel Routing+MVC http://laravelbook.com/laravel-architecture/ Routing Study documentation http://laravel.com/docs/4.2/routing

More information

Static Webpage Development

Static Webpage Development Dear Student, Based upon your enquiry we are pleased to send you the course curriculum for PHP Given below is the brief description for the course you are looking for: - Static Webpage Development Introduction

More information

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Laravel

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Laravel About the Tutorial Laravel is a powerful MVC PHP framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Laravel was created by Taylor Otwell.

More information

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes Course Title Course Code WEB DESIGNING TECHNOLOGIES DCE311 Lecture : 3 Course Credit Practical : Tutorial : 0 Total : 5 Course Learning Outcomes At end of the course, students will be able to: Understand

More information

Web development using PHP & MySQL with HTML5, CSS, JavaScript

Web development using PHP & MySQL with HTML5, CSS, JavaScript Web development using PHP & MySQL with HTML5, CSS, JavaScript Static Webpage Development Introduction to web Browser Website Webpage Content of webpage Static vs dynamic webpage Technologies to create

More information

Laravel 4 Cookbook. Christopher Pitt and Taylor Otwell. This book is for sale at

Laravel 4 Cookbook. Christopher Pitt and Taylor Otwell. This book is for sale at Laravel 4 Cookbook Christopher Pitt and Taylor Otwell This book is for sale at http://leanpubcom/laravel4cookbook This version was published on 014-07-04 This is a Leanpub book Leanpub empowers authors

More information

Web Security: Vulnerabilities & Attacks

Web Security: Vulnerabilities & Attacks Computer Security Course. Web Security: Vulnerabilities & Attacks Type 2 Type 1 Type 0 Three Types of XSS Type 2: Persistent or Stored The attack vector is stored at the server Type 1: Reflected The attack

More information

Getting Started with Laravel 4

Getting Started with Laravel 4 Getting Started with Laravel 4 Raphaël Saunier Chapter No. 4 "Authentication and Security" In this package, you will find: A Biography of the author of the book A preview chapter from the book, Chapter

More information

Alpha College of Engineering and Technology. Question Bank

Alpha College of Engineering and Technology. Question Bank Alpha College of Engineering and Technology Department of Information Technology and Computer Engineering Chapter 1 WEB Technology (2160708) Question Bank 1. Give the full name of the following acronyms.

More information

Web 2.0 and AJAX Security. OWASP Montgomery. August 21 st, 2007

Web 2.0 and AJAX Security. OWASP Montgomery. August 21 st, 2007 Web 2.0 and AJAX Security OWASP Montgomery August 21 st, 2007 Overview Introduction Definition of Web 2.0 Basics of AJAX Attack Vectors for AJAX Applications AJAX and Application Security Conclusions 1

More information

Information Security CS 526 Topic 8

Information Security CS 526 Topic 8 Information Security CS 526 Topic 8 Web Security Part 1 1 Readings for This Lecture Wikipedia HTTP Cookie Same Origin Policy Cross Site Scripting Cross Site Request Forgery 2 Background Many sensitive

More information

Ruby on Rails Secure Coding Recommendations

Ruby on Rails Secure Coding Recommendations Introduction Altius IT s list of Ruby on Rails Secure Coding Recommendations is based upon security best practices. This list may not be complete and Altius IT recommends this list be augmented with additional

More information

Information Security CS 526 Topic 11

Information Security CS 526 Topic 11 Information Security CS 526 Topic 11 Web Security Part 1 1 Readings for This Lecture Wikipedia HTTP Cookie Same Origin Policy Cross Site Scripting Cross Site Request Forgery 2 Background Many sensitive

More information

Web Focused Programming With PHP

Web Focused Programming With PHP Web Focused Programming With PHP May 20 2014 Thomas Beebe Advanced DataTools Corp (tom@advancedatatools.com) Tom Beebe Tom is a Senior Database Consultant and has been with Advanced DataTools for over

More information

OWASP TOP 10. By: Ilia

OWASP TOP 10. By: Ilia OWASP TOP 10 By: Ilia Alshanetsky @iliaa ME, MYSELF & I PHP Core Developer Author of Guide to PHP Security Security Aficionado WEB SECURITY THE CONUNDRUM USABILITY SECURITY YOU CAN HAVE ONE ;-) OPEN WEB

More information

PHP Security. Kevin Schroeder Zend Technologies. Copyright 2007, Zend Technologies Inc.

PHP Security. Kevin Schroeder Zend Technologies. Copyright 2007, Zend Technologies Inc. PHP Security Kevin Schroeder Zend Technologies Copyright 2007, Zend Technologies Inc. Disclaimer Do not use anything you learn here for nefarious purposes Why Program Securely? Your job/reputation depends

More information

Web Security IV: Cross-Site Attacks

Web Security IV: Cross-Site Attacks 1 Web Security IV: Cross-Site Attacks Chengyu Song Slides modified from Dawn Song 2 Administrivia Lab3 New terminator: http://www.cs.ucr.edu/~csong/sec/17/l/new_terminator Bonus for solving the old one

More information

Get in Touch Module 1 - Core PHP XHTML

Get in Touch Module 1 - Core PHP XHTML PHP/MYSQL (Basic + Advanced) Web Technologies Module 1 - Core PHP XHTML What is HTML? Use of HTML. Difference between HTML, XHTML and DHTML. Basic HTML tags. Creating Forms with HTML. Understanding Web

More information

Creating HTML files using Notepad

Creating HTML files using Notepad Reference Materials 3.1 Creating HTML files using Notepad Inside notepad, select the file menu, and then Save As. This will allow you to set the file name, as well as the type of file. Next, select the

More information

This slide shows the OWASP Top 10 Web Application Security Risks of 2017, which is a list of the currently most dangerous web vulnerabilities in

This slide shows the OWASP Top 10 Web Application Security Risks of 2017, which is a list of the currently most dangerous web vulnerabilities in 1 This slide shows the OWASP Top 10 Web Application Security Risks of 2017, which is a list of the currently most dangerous web vulnerabilities in terms of prevalence (how much the vulnerability is widespread),

More information

An Introduction to JavaScript & Bootstrap Basic concept used in responsive website development Form Validation Creating templates

An Introduction to JavaScript & Bootstrap Basic concept used in responsive website development Form Validation Creating templates PHP Course Contents An Introduction to HTML & CSS Basic Html concept used in website development Creating templates An Introduction to JavaScript & Bootstrap Basic concept used in responsive website development

More information

Helpline No WhatsApp No.:

Helpline No WhatsApp No.: TRAINING BASKET QUALIFY FOR TOMORROW Helpline No. 9015887887 WhatsApp No.: 9899080002 Regd. Off. Plot No. A-40, Unit 301/302, Tower A, 3rd Floor I-Thum Tower Near Corenthum Tower, Sector-62, Noida - 201309

More information

Kendo UI Builder by Progress : Using Kendo UI Designer

Kendo UI Builder by Progress : Using Kendo UI Designer Kendo UI Builder by Progress : Using Kendo UI Designer Notices 2016 Telerik AD. All rights reserved. November 2016 Last updated with new content: Version 1.1 3 Notices 4 Contents Table of Contents Chapter

More information

Instructor s Notes Web Data Management The MVC Pattern. Web Data Management The MVC Pattern

Instructor s Notes Web Data Management The MVC Pattern. Web Data Management The MVC Pattern Web Data Management 152-155 The MVC Pattern Quick Links & Text References Overview Pages 160 161 Controller Pages 170 172 246 247 Including Files Pages Case Include Files Pages Model Pages 168 169 Views

More information

JavaScript Functions, Objects and Array

JavaScript Functions, Objects and Array JavaScript Functions, Objects and Array Defining a Function A definition starts with the word function. A name follows that must start with a letter or underscore, followed by any number of letters, digits,

More information

Survey Creation Workflow These are the high level steps that are followed to successfully create and deploy a new survey:

Survey Creation Workflow These are the high level steps that are followed to successfully create and deploy a new survey: Overview of Survey Administration The first thing you see when you open up your browser to the Ultimate Survey Software is the Login Page. You will find that you see three icons at the top of the page,

More information

BF Survey Pro User Guide

BF Survey Pro User Guide BF Survey Pro User Guide January 2011 v1.0 1 of 41 www.tamlyncreative.com.au/software/ Table of Contents Introduction... 5 Support... 5 Documentation... 5 Installation New Install... 5 Installation Upgrade...

More information

Web Security: Vulnerabilities & Attacks

Web Security: Vulnerabilities & Attacks Computer Security Course. Song Dawn Web Security: Vulnerabilities & Attacks Cross-site Scripting What is Cross-site Scripting (XSS)? Vulnerability in web application that enables attackers to inject client-side

More information

PHP WITH ANGULAR CURRICULUM. What you will Be Able to Achieve During This Course

PHP WITH ANGULAR CURRICULUM. What you will Be Able to Achieve During This Course PHP WITH ANGULAR CURRICULUM What you will Be Able to Achieve During This Course This course will enable you to build real-world, dynamic web sites. If you've built websites using plain HTML, you realize

More information

CERTIFICATE IN WEB PROGRAMMING

CERTIFICATE IN WEB PROGRAMMING COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING

More information

WHY CSRF WORKS. Implicit authentication by Web browsers

WHY CSRF WORKS. Implicit authentication by Web browsers WHY CSRF WORKS To explain the root causes of, and solutions to CSRF attacks, I need to share with you the two broad types of authentication mechanisms used by Web applications: 1. Implicit authentication

More information

week8 Tommy MacWilliam week8 October 31, 2011

week8 Tommy MacWilliam week8 October 31, 2011 tmacwilliam@cs50.net October 31, 2011 Announcements pset5: returned final project pre-proposals due Monday 11/7 http://cs50.net/projects/project.pdf CS50 seminars: http://wiki.cs50.net/seminars Today common

More information

UNIT I. A protocol is a precise set of rules defining how components communicate, the format of addresses, how data is split into packets

UNIT I. A protocol is a precise set of rules defining how components communicate, the format of addresses, how data is split into packets UNIT I Web Essentials: Clients, Servers, and Communication. The Internet- Basic Internet Protocols -The World Wide Web-HTTP request message-response message- Web Clients Web Servers-Case Study. Markup

More information

CS50 Quiz Review. November 13, 2017

CS50 Quiz Review. November 13, 2017 CS50 Quiz Review November 13, 2017 Info http://docs.cs50.net/2017/fall/quiz/about.html 48-hour window in which to take the quiz. You should require much less than that; expect an appropriately-scaled down

More information

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang WEB SECURITY WORKSHOP TEXSAW 2014 Presented by Solomon Boyd and Jiayang Wang Introduction and Background Targets Web Applications Web Pages Databases Goals Steal data Gain access to system Bypass authentication

More information

Introduction to PHP. Handling Html Form With Php. Decisions and loop. Function. String. Array

Introduction to PHP. Handling Html Form With Php. Decisions and loop. Function. String. Array Introduction to PHP Evaluation of Php Basic Syntax Defining variable and constant Php Data type Operator and Expression Handling Html Form With Php Capturing Form Data Dealing with Multi-value filed Generating

More information

OAuth 2 and Native Apps

OAuth 2 and Native Apps OAuth 2 and Native Apps Flows While all OAuth 2 flows can be used by native apps, only the user delegation flows will be considered in this document: Web Server, User-Agent and Device flows. The Web Server

More information

Application Security through a Hacker s Eyes James Walden Northern Kentucky University

Application Security through a Hacker s Eyes James Walden Northern Kentucky University Application Security through a Hacker s Eyes James Walden Northern Kentucky University waldenj@nku.edu Why Do Hackers Target Web Apps? Attack Surface A system s attack surface consists of all of the ways

More information

Mobile Site Development

Mobile Site Development Mobile Site Development HTML Basics What is HTML? Editors Elements Block Elements Attributes Make a new line using HTML Headers & Paragraphs Creating hyperlinks Using images Text Formatting Inline styling

More information

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 INFORMATION TECHNOLOGY TUTORIAL QUESTION BANK Course Name Course Code Class Branch : Web Technologies : ACS006 : B. Tech

More information

Developing ASP.NET MVC Web Applications (486)

Developing ASP.NET MVC Web Applications (486) Developing ASP.NET MVC Web Applications (486) Design the application architecture Plan the application layers Plan data access; plan for separation of concerns, appropriate use of models, views, controllers,

More information

Application Design and Development: October 30

Application Design and Development: October 30 M149: Database Systems Winter 2018 Lecturer: Panagiotis Liakos Application Design and Development: October 30 1 Applications Programs and User Interfaces very few people use a query language to interact

More information

What is PHP? [1] Figure 1 [1]

What is PHP? [1] Figure 1 [1] PHP What is PHP? [1] PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use Figure

More information

CUSTOMER PORTAL. Custom HTML splashpage Guide

CUSTOMER PORTAL. Custom HTML splashpage Guide CUSTOMER PORTAL Custom HTML splashpage Guide 1 CUSTOM HTML Custom HTML splash page templates are intended for users who have a good knowledge of HTML, CSS and JavaScript and want to create a splash page

More information

Penetration Testing. James Walden Northern Kentucky University

Penetration Testing. James Walden Northern Kentucky University Penetration Testing James Walden Northern Kentucky University Topics 1. What is Penetration Testing? 2. Rules of Engagement 3. Penetration Testing Process 4. Map the Application 5. Analyze the Application

More information

Rails: MVC in action

Rails: MVC in action Ruby on Rails Basic Facts 1. Rails is a web application framework built upon, and written in, the Ruby programming language. 2. Open source 3. Easy to learn; difficult to master. 4. Fun (and a time-saver)!

More information

Web basics: HTTP cookies

Web basics: HTTP cookies Web basics: HTTP cookies Myrto Arapinis School of Informatics University of Edinburgh February 11, 2016 1 / 27 How is state managed in HTTP sessions HTTP is stateless: when a client sends a request, the

More information

Web Scripting using PHP

Web Scripting using PHP Web Scripting using PHP Server side scripting So what is a Server Side Scripting Language? Programming language code embedded into a web page PERL PHP PYTHON ASP Different ways of scripting the Web Programming

More information

Security and Privacy. SWE 432, Fall 2016 Design and Implementation of Software for the Web

Security and Privacy. SWE 432, Fall 2016 Design and Implementation of Software for the Web Security and Privacy SWE 432, Fall 2016 Design and Implementation of Software for the Web Today Security What is it? Most important types of attacks Privacy For further reading: https://www.owasp.org/index.php/

More information

Setting Up a Development Server What Is a WAMP, MAMP, or LAMP? Installing a WAMP on Windows Testing the InstallationAlternative WAMPs Installing a

Setting Up a Development Server What Is a WAMP, MAMP, or LAMP? Installing a WAMP on Windows Testing the InstallationAlternative WAMPs Installing a Setting Up a Development Server What Is a WAMP, MAMP, or LAMP? Installing a WAMP on Windows Testing the InstallationAlternative WAMPs Installing a LAMP on Linux Working Remotely Introduction to web programming

More information

How is state managed in HTTP sessions. Web basics: HTTP cookies. Hidden fields (2) The principle. Disadvantage of this approach

How is state managed in HTTP sessions. Web basics: HTTP cookies. Hidden fields (2) The principle. Disadvantage of this approach Web basics: HTTP cookies Myrto Arapinis School of Informatics University of Edinburgh March 30, 2015 How is state managed in HTTP sessions HTTP is stateless: when a client sends a request, the server sends

More information

NukaCode - Front End - Bootstrap Documentation

NukaCode - Front End - Bootstrap Documentation Nuka - Front End - Bootstrap Documentation Release 1.0.0 stygian July 04, 2015 Contents 1 Badges 3 1.1 Links................................................... 3 1.2 Installation................................................

More information

Advanced Web Technology 10) XSS, CSRF and SQL Injection

Advanced Web Technology 10) XSS, CSRF and SQL Injection Berner Fachhochschule, Technik und Informatik Advanced Web Technology 10) XSS, CSRF and SQL Injection Dr. E. Benoist Fall Semester 2010/2011 1 Table of Contents Cross Site Request Forgery - CSRF Presentation

More information

RKN 2015 Application Layer Short Summary

RKN 2015 Application Layer Short Summary RKN 2015 Application Layer Short Summary HTTP standard version now: 1.1 (former 1.0 HTTP /2.0 in draft form, already used HTTP Requests Headers and body counterpart: answer Safe methods (requests): GET,

More information

Progress Exchange June, Phoenix, AZ, USA 1

Progress Exchange June, Phoenix, AZ, USA 1 1 COMP-1: Securing your web application against hackers Edwin Lijnzaad & Ronald Smits Consultants Agenda Introduction Issues How to... Questions 2 COMP-1: Securing your web application against hackers

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2017 CS 161 Computer Security Discussion 4 Week of February 13, 2017 Question 1 Clickjacking (5 min) Watch the following video: https://www.youtube.com/watch?v=sw8ch-m3n8m Question 2 Session

More information

Webthority can provide single sign-on to web applications using one of the following authentication methods:

Webthority can provide single sign-on to web applications using one of the following authentication methods: Webthority HOW TO Configure Web Single Sign-On Webthority can provide single sign-on to web applications using one of the following authentication methods: HTTP authentication (for example Kerberos, NTLM,

More information

Full Stack Web Developer

Full Stack Web Developer Full Stack Web Developer S.NO Technologies 1 HTML5 &CSS3 2 JavaScript, Object Oriented JavaScript& jquery 3 PHP&MYSQL Objective: Understand the importance of the web as a medium of communication. Understand

More information

Contents. xvii xix xxiil. xxvii

Contents. xvii xix xxiil. xxvii Contents FOREWORD INTRODUCTION INDUSTRY ANALYSIS PREFACE ACKNOWLEDGMENTS BIOGRAPHY XV xvii xix xxiil XXV xxvii PART I CHAPTER 1 INTRODUCTION TO MOBILE SECURITY DEVELOPMENT Understanding Secure Web Development

More information

1. Begin by selecting [Content] > [Add Content] > [Webform] in the administrative toolbar. A new Webform page should appear.

1. Begin by selecting [Content] > [Add Content] > [Webform] in the administrative toolbar. A new Webform page should appear. Creating a Webform 1. Begin by selecting [Content] > [Add Content] > [Webform] in the administrative toolbar. A new Webform page should appear. 2. Enter the title of the webform you would like to create

More information

P2_L12 Web Security Page 1

P2_L12 Web Security Page 1 P2_L12 Web Security Page 1 Reference: Computer Security by Stallings and Brown, Chapter (not specified) The web is an extension of our computing environment, because most of our daily tasks involve interaction

More information

PHP INTERVIEW QUESTION-ANSWERS

PHP INTERVIEW QUESTION-ANSWERS 1. What is PHP? PHP (recursive acronym for PHP: Hypertext Preprocessor) is the most widely used open source scripting language, majorly used for web-development and application development and can be embedded

More information

CS637 Midterm Review

CS637 Midterm Review CS637 Midterm Review Coverage: Duckett Chapter 1-2: Basics: Can skip pp. 53-56 Chapter 3: Lists: all important Chapter 4:Links: all important Chapter 5:Images: can skip old code Chapter 6: Tables: all

More information

CS 155 Project 2. Overview & Part A

CS 155 Project 2. Overview & Part A CS 155 Project 2 Overview & Part A Project 2 Web application security Composed of two parts Part A: Attack Part B: Defense Due date: Part A: May 5th (Thu) Part B: May 12th (Thu) Project 2 Ruby-on-Rails

More information

Attacks Against Websites 3 The OWASP Top 10. Tom Chothia Computer Security, Lecture 14

Attacks Against Websites 3 The OWASP Top 10. Tom Chothia Computer Security, Lecture 14 Attacks Against Websites 3 The OWASP Top 10 Tom Chothia Computer Security, Lecture 14 OWASP top 10. The Open Web Application Security Project Open public effort to improve web security: Many useful documents.

More information

NET 311 INFORMATION SECURITY

NET 311 INFORMATION SECURITY NET 311 INFORMATION SECURITY Networks and Communication Department Lec12: Software Security / Vulnerabilities lecture contents: o Vulnerabilities in programs Buffer Overflow Cross-site Scripting (XSS)

More information

PROBLEMS IN PRACTICE: THE WEB MICHAEL ROITZSCH

PROBLEMS IN PRACTICE: THE WEB MICHAEL ROITZSCH Faculty of Computer Science Institute of Systems Architecture, Operating Systems Group PROBLEMS IN PRACTICE: THE WEB MICHAEL ROITZSCH THE WEB AS A DISTRIBUTED SYSTEM 2 WEB HACKING SESSION 3 3-TIER persistent

More information

PHPRad. PHPRad At a Glance. This tutorial will show you basic functionalities in PHPRad and

PHPRad. PHPRad At a Glance. This tutorial will show you basic functionalities in PHPRad and PHPRad PHPRad At a Glance. This tutorial will show you basic functionalities in PHPRad and Getting Started Creating New Project To create new Project. Just click on the button. Fill In Project properties

More information

CSE 127 Computer Security

CSE 127 Computer Security CSE 127 Computer Security Fall 2015 Web Security I: SQL injection Stefan Savage The Web creates new problems Web sites are programs Partially implemented in browser» Javascript, Java, Flash Partially implemented

More information

DevShala Technologies A-51, Sector 64 Noida, Uttar Pradesh PIN Contact us

DevShala Technologies A-51, Sector 64 Noida, Uttar Pradesh PIN Contact us INTRODUCING PHP The origin of PHP PHP for Web Development & Web Applications PHP History Features of PHP How PHP works with the Web Server What is SERVER & how it works What is ZEND Engine Work of ZEND

More information

Robust Defenses for Cross-Site Request Forgery

Robust Defenses for Cross-Site Request Forgery Robust Defenses for Cross-Site Request Forgery Tsampanaki Nikoleta Lilitsis Prodromos Gigis Petros Paper Authors: Adam Barth, Collin Jackson, John C. Mitchell Outline What is CSRF attack? What is a login

More information

Jquery Manually Set Checkbox Checked Or Not

Jquery Manually Set Checkbox Checked Or Not Jquery Manually Set Checkbox Checked Or Not Working Second Time jquery code to set checkbox element to checked not working. Apr 09 I forced a loop to show checked state after the second menu item in the

More information

Highwinds CDN Content Protection Products. August 2009

Highwinds CDN Content Protection Products. August 2009 Highwinds CDN Content Protection Products August 2009 1 Highwinds CDN Content Protection Products August 2009 Table of Contents CDN SECURITY INTRO... 3 CONTENT PROTECTION BY CDN DELIVERY PRODUCT... 3 HTTP

More information

Pro ASP.NET MVC 2 Framework

Pro ASP.NET MVC 2 Framework Pro ASP.NET MVC 2 Framework Second Edition Steven Sanderson Apress TIB/UB Hannover 89 133 297 713 Contents at a Glance Contents About the Author About the Technical Reviewers Acknowledgments Introduction

More information

AngularJS Introduction

AngularJS Introduction AngularJS Introduction Mendel Rosenblum AngularJS JavaScript framework for writing web applications Handles: DOM manipulation, input validation, server communication, URL management, etc. Considered opinionated

More information

Manual Html A Href Onclick Submit Form

Manual Html A Href Onclick Submit Form Manual Html A Href Onclick Submit Form JS HTML DOM. DOM Intro DOM Methods HTML form validation can be done by a JavaScript. If a form field _input type="submit" value="submit" /form_. As shown in a previous

More information

WEB SECURITY: WEB BACKGROUND

WEB SECURITY: WEB BACKGROUND WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018 A very basic web architecture Client Server Browser Web server (Private) Data Database DB is a separate entity, logically (and often physically) A very

More information

Web basics: HTTP cookies

Web basics: HTTP cookies Web basics: HTTP cookies Myrto Arapinis School of Informatics University of Edinburgh November 20, 2017 1 / 32 How is state managed in HTTP sessions HTTP is stateless: when a client sends a request, the

More information

Melis Platform V2. Back-Office. Functionment of modules. Content: Date Version 2.0

Melis Platform V2. Back-Office. Functionment of modules. Content: Date Version 2.0 4, rue du Dahomey 75011 Paris, France (+33 972 386 280 Melis Platform V2 Back-Office Functionment of modules Content: This document explains how to create a module for Melis Platform's backoffice. Date

More information

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37)

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37) PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37) A Server-side Scripting Programming Language An Introduction What is PHP? PHP stands for PHP: Hypertext Preprocessor. It is a server-side

More information

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript PHP Curriculum Module: HTML5, CSS3 & JavaScript Introduction to the Web o Explain the evolution of HTML o Explain the page structure used by HTML o List the drawbacks in HTML 4 and XHTML o List the new

More information

HTTP Protocol and Server-Side Basics

HTTP Protocol and Server-Side Basics HTTP Protocol and Server-Side Basics Web Programming Uta Priss ZELL, Ostfalia University 2013 Web Programming HTTP Protocol and Server-Side Basics Slide 1/26 Outline The HTTP protocol Environment Variables

More information

PHP + ANGULAR4 CURRICULUM 6 WEEKS

PHP + ANGULAR4 CURRICULUM 6 WEEKS PHP + ANGULAR4 CURRICULUM 6 WEEKS Hands-On Training In this course, you develop PHP scripts to perform a variety to takes, culminating in the development of a full database-driven Web page. Exercises include:

More information

Web Security. Jace Baker, Nick Ramos, Hugo Espiritu, Andrew Le

Web Security. Jace Baker, Nick Ramos, Hugo Espiritu, Andrew Le Web Security Jace Baker, Nick Ramos, Hugo Espiritu, Andrew Le Topics Web Architecture Parameter Tampering Local File Inclusion SQL Injection XSS Web Architecture Web Request Structure Web Request Structure

More information

Programming for the Web with PHP

Programming for the Web with PHP Aptech Ltd Version 1.0 Page 1 of 11 Table of Contents Aptech Ltd Version 1.0 Page 2 of 11 Abstraction Anonymous Class Apache Arithmetic Operators Array Array Identifier arsort Function Assignment Operators

More information

Review of HTML. Chapter Pearson. Fundamentals of Web Development. Randy Connolly and Ricardo Hoar

Review of HTML. Chapter Pearson. Fundamentals of Web Development. Randy Connolly and Ricardo Hoar Review of HTML Chapter 3 Fundamentals of Web Development 2017 Pearson Fundamentals of Web Development http://www.funwebdev.com - 2 nd Ed. What Is HTML and Where Did It Come from? HTML HTML is defined as

More information

PHP,HTML5, CSS3, JQUERY SYLLABUS

PHP,HTML5, CSS3, JQUERY SYLLABUS PHP,HTML5, CSS3, JQUERY SYLLABUS AAvhdvchdvchdvhdh HTML HTML - Introduction HTML - Elements HTML - Tags HTML - Text HTML - Formatting HTML - Pre HTML - Attributes HTML - Font HTML - Text Links HTML - Comments

More information

LECT 8 WEB SECURITY BROWSER SECURITY. Repetition Lect 7. WEB Security

LECT 8 WEB SECURITY BROWSER SECURITY. Repetition Lect 7. WEB Security Repetition Lect 7 LECT 8 WEB SECURITY Access control Runtime protection Trusted computing Java as basic model for signed code Trusted Computing Group TPM ARM TrustZone Mobile Network security GSM security

More information

Simple AngularJS thanks to Best Practices

Simple AngularJS thanks to Best Practices Simple AngularJS thanks to Best Practices Learn AngularJS the easy way Level 100-300 What s this session about? 1. AngularJS can be easy when you understand basic concepts and best practices 2. But it

More information

PHP / MYSQL DURATION: 2 MONTHS

PHP / MYSQL DURATION: 2 MONTHS PHP / MYSQL HTML Introduction of Web Technology History of HTML HTML Editors HTML Doctypes HTML Heads and Basics HTML Comments HTML Formatting HTML Fonts, styles HTML links and images HTML Blocks and Layout

More information

Introducing Models. Data model: represent classes that iteract with a database. Data models are set of

Introducing Models. Data model: represent classes that iteract with a database. Data models are set of Models 1 Objectives Define and describe models Explain how to create a model Describe how to pass model data from controllers to view Explain how to create strongly typed models Explain the role of the

More information

CS 142 Winter Session Management. Dan Boneh

CS 142 Winter Session Management. Dan Boneh CS 142 Winter 2009 Session Management Dan Boneh Sessions A sequence of requests and responses from one browser to one (or more) sites Session can be long (Gmail - two weeks) or short without session mgmt:

More information

Web Security, Summer Term 2012

Web Security, Summer Term 2012 IIG University of Freiburg Web Security, Summer Term 2012 Cross Site Scripting - XSS Dr. E. Benoist Sommer Semester Web Security, Summer Term 2012 5 Cross Site Scripting 1 Table of Contents Presentation:

More information

St. Paul s Convent School (Secondary Section) ELMO Student User Guide

St. Paul s Convent School (Secondary Section) ELMO Student User Guide St. Paul s Convent School (Secondary Section) ELMO Student User Guide Version 1.0 Page 1 of 14 1. User Account 1.1 Login Open Chrome browser and go to http://elmo.spcs.edu.hk, a Sign In screen will be

More information

How to Login, Logout and Manage Password (QRG)

How to Login, Logout and Manage Password (QRG) How to Login, Logout and Manage Password (QRG) This Quick Reference Guide covers the following topics: 1. How to login in to the DCC. How to change (reset) your password 3. What to do if you have forgotten

More information

Web Security, Summer Term 2012

Web Security, Summer Term 2012 Table of Contents IIG University of Freiburg Web Security, Summer Term 2012 Cross Site Scripting - XSS Dr. E. Benoist Sommer Semester Presentation: Inject Javascript in a Page Javascript for manipulating

More information

High -Tech Bridge s Web Server Security Service API Developer Documentation Version v1.3 February 13 th 2018

High -Tech Bridge s Web Server Security Service API Developer Documentation Version v1.3 February 13 th 2018 HTB_WEBSECDOCS_v1.3.pdf Page 1 of 29 High -Tech Bridge s Web Server Security Service API Developer Documentation Version v1.3 February 13 th 2018 General Overview... 2 Meta-information... 4 HTTP Additional

More information

Shankersinh Vaghela Bapu Institue of Technology

Shankersinh Vaghela Bapu Institue of Technology Branch: - 6th Sem IT Year/Sem : - 3rd /2014 Subject & Subject Code : Faculty Name : - Nitin Padariya Pre Upload Date: 31/12/2013 Submission Date: 9/1/2014 [1] Explain the need of web server and web browser

More information

CSCI 1320 Creating Modern Web Applications. Content Management Systems

CSCI 1320 Creating Modern Web Applications. Content Management Systems CSCI 1320 Creating Modern Web Applications Content Management Systems Brown CS Website 2 Static Brown CS Website Up since 1994 5.9 M files (inodes) 1.6 TB of filesystem space 3 Static HTML Generators Convert

More information

2/16/18. CYSE 411/AIT 681 Secure Software Engineering. Secure Coding. The Web. Topic #11. Web Security. Instructor: Dr. Kun Sun

2/16/18. CYSE 411/AIT 681 Secure Software Engineering. Secure Coding. The Web. Topic #11. Web Security. Instructor: Dr. Kun Sun CYSE 411/AIT 681 Secure Software Engineering Topic #11. Web Security Instructor: Dr. Kun Sun Secure Coding String management Pointer Subterfuge Dynamic memory management Integer security Formatted output

More information