APEX & Cookie Monster

22
Apex & Cookie Monster Christian Rokitta

Transcript of APEX & Cookie Monster

Page 1: APEX & Cookie Monster

Apex &Cookie

Monster

Christian Rokitta

Page 2: APEX & Cookie Monster

Apex &Cookie

Monster

Christian Rokitta

This presentation uses cookies.

EU regulations require us to gain your consent before continuing.

No, thanks Accept

Page 3: APEX & Cookie Monster

Agenda

• Cookie Basics• Anatomy of a Cookie• Cookies in APEX• Use Case:

Another Approach to Authentication

Page 4: APEX & Cookie Monster

Cookie Basics - HTTP

Page 5: APEX & Cookie Monster

What are Cookies…. Really?

• Small bits of text data that are stored in and shared by the browser.

• Can be for any purpose:

Page 6: APEX & Cookie Monster

Are Cookies Bad For You?

• Cookies have been given a bad reputationo Developer Designso Hackerso Advertisers

• Cookies can be useful• As with real cookies …

Too many is probably not good for you

Page 7: APEX & Cookie Monster

Anatomy of a Cookie

Page 8: APEX & Cookie Monster

Domain

• Cookies from different sites are separated by Domain

• Browsers only send cookies for the current domain

• Super Cookies (*.com, *.org) are (and should be) blocked by most browsers

Page 9: APEX & Cookie Monster

Path

• Setting a Path dictates when a cookie is sent by the browser.

• Path cookies are hierarchical, meaning that cookies at higher path value will be sent when lower paths are requested

Example: hbp://domain/applica6on/area/sub_area

Cookie for: /applica6on/area/sub_areaCookie for: /applica6on/areaCookie for: /applica6onCookie for: /

Page 10: APEX & Cookie Monster

Expires

• Session: When the browser is closed, the cookie value will be lost

• Date: Configurable date to allow persistence of a cookie after the browser has been closed

Page 11: APEX & Cookie Monster

HTTP_ONLY

• Modern browsers respect the separation of cookies that should not be available to JavaScript

• Reduces the risk of malicious JavaScript from reading or adjus6ng the cookie values

Page 12: APEX & Cookie Monster

Secure

• Only sent (by browser) when using HTTPS

• Secure cookies can be received via HTTP

Page 13: APEX & Cookie Monster

Tools

• Different browsers provide different tools

• Cookies can be added, removed, and edited

• Most modern browsers will include easy visibility into the cookies being used

Page 14: APEX & Cookie Monster

APEX & Cookies

Page 15: APEX & Cookie Monster

Page Render

• “I just did set it! Where did it go …?”

• You cannot read a cookie that you just did set to use in your current page rendering

Page 16: APEX & Cookie Monster

Why use?

The reason cookies are not seen as valuable to APEX users is because of easy DB access and session framework.

How can cookies provide value to an APEX application?

Page 17: APEX & Cookie Monster

Demo – Cookie Authentication

Page 18: APEX & Cookie Monster

PL/SQL Packages

• SYS.UTL_HTTP is not available(by default grants)

• OWA_COOKIE• OWA_UTIL

Page 19: APEX & Cookie Monster

OWA Cookie Record

TYPE vc_arr IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;

TYPE COOKIE IS RECORD ( name VARCHAR2(4000), vals vc_arr, num_vals INTEGER);

Page 20: APEX & Cookie Monster

APEX JavaScript API

• apex.storage.getCookie(pName)

• apex.storage.setCookie(pName,pValue)

Page 21: APEX & Cookie Monster

Resources & Kudos

• Demo Applicationhttps://apex.oracle.com/pls/apex/f?p=63242:1::::::

• Blog Post (explaining the demo application)http://rokitta.blogspot.nl/2012/10/remember-me-apex-autologin.html

• Many thanks to: Tim St. Hilaire, the original Cookie Monsterhttp://wphilltech.com/apex-authentication-with-cookie/

Page 22: APEX & Cookie Monster

Fragen & Antworten

http://rokitta.blogspot.com

@crokitta

[email protected]

http://www.themes4apex.com

? ? ?

http://plus.google.com/+ChristianRokitta

http://nl.linkedin.com/in/rokit/