<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Thu, 20 Jun 2013 07:32:37 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Anthony Ferrara: Preventing CSRF Attacks]]></title>
      <guid>http://www.phpdeveloper.org/news/19207</guid>
      <link>http://www.phpdeveloper.org/news/19207</link>
      <description><![CDATA[<p>
<i>Anthony Ferrara</i> has written up a new post to his site looking at <a href="http://blog.ircmaxell.com/2013/02/preventing-csrf-attacks.html">efective use of CSRF tokens</a> and a few different strategies for generating them.
</p>
<blockquote>
There's been a bit of noise in the past week about the proper way to prevent Cross-Site-Request-Forgery (CSRF) attacks. It seemed to have started with this post. There's been discussion in the comments, and on Twitter about it, and there seems to be several opposing viewpoints on the matter. I want to start off by saying that I agree completely with the post in question. But I figured I'd write a post to explain WHY I agree with it.
</blockquote>
<p>
He starts with an overview of a few of the common types of request forgery including from a javascript injection, a Man-in-the-Middle attack and a replay attack. He then breaks up the "lines of defense" part of the post into three different sections - adding a hidden token field to forms, changing the token for each request and using <a href="http://blog.ircmaxell.com/2011/07/random-number-generation-in-php.html">random numbers</a> when regenrating them.
</p>]]></description>
      <pubDate>Wed, 20 Feb 2013 09:36:41 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Kevin Schroeder: Generating secure cross site request forgery tokens (csrf)]]></title>
      <guid>http://www.phpdeveloper.org/news/19164</guid>
      <link>http://www.phpdeveloper.org/news/19164</link>
      <description><![CDATA[<p>
In <a href="http://www.eschrade.com/page/generating-secure-cross-site-request-forgery-tokens-csrf/">this new post</a> to his site <i>Kevin Schroeder</i> has a new post with his take on generating more secure CSRF tokens for use in your site.
</p>
<blockquote>
In researching <a href="http://www.eschrade.com/page/the-ibm-i-programmers-guide-to-php-second-edition/">the second edition</a> for the <a href="http://www.amazon.com/IBM-Programmers-Guide-PHP/dp/1583470832">IBM i Programmer's Guide to PHP</a> Jeff and I decided to include a chapter on security since we really didn't talk much about it in the first edition.  I'm talking about cross site request forgeries right now and I wanted to make sure that what I was going to suggest would not <a href="http://www.youtube.com/watch?v=qdjRwpYM-Kw">break the internet</a> in some way. I did some Google searching to see what other people were recommending. 
</blockquote>
<p>
Most of the examples he saw used <a href="http://php.net/md5">md5</a>, <a href="http://php.net/uniqid">uniqid</a> and <a href="http://php.net/rand"> rand</a> to create a randomized hash. He suggests an alternative - a method using the <a href="http://php.net/hash_hmac">hash_hmac</a> and <a href="http://php.net/openssl_random_pseudo_bytes"> openssl_random_pseudo_bytes</a> methods to generate a sha256 hash for use in your page's submissions.
</p>]]></description>
      <pubDate>Mon, 11 Feb 2013 11:23:10 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sherif Ramadan: How to Write an Operator Precedence Parser in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19068</guid>
      <link>http://www.phpdeveloper.org/news/19068</link>
      <description><![CDATA[<p>
<i>Sherif Ramadan</i> has a post looking at <a href="https://sheriframadan.com/2013/01/how-to-write-an-operator-precedence-parser-in-php/">creating a better operator precedence parser</a> in PHP. <a href="https://github.com/srgoogleguy/Mphp/">His example</a> is a fully PHP implementation that takes equation strings and evaluates them to create the result.
</p>
<blockquote>
Operator precedence parsers are very simple on the surface. So don't feel in the least bit intimidated, because by the time you've read through this I hope to have you walk away with a solid foundation on how to write your very own operator precedence parser. The goal is to understand how to solve the problem of operator precedence parsing, and not necessarily to write your own parser. Learning how the problem can be solved is the most important thing to take away from this article.
</blockquote>
<p>
He starts with an introduction to the concepts behind "operator precedence" including processing order and grouping. He also mentions infix and postfix (RPN) notations for handling different formats of equations. He used the "Shunting-yard Algorithm" and how it relates to handling the different parts of the equation, one at a time, in the correct order. He rest of the post is dedicated to the details of the execution in the tool, including code examples and the tokenization of the strings passed into it.
</p>]]></description>
      <pubDate>Mon, 21 Jan 2013 11:21:22 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Using OAuth2 for Google APIs with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17752</guid>
      <link>http://www.phpdeveloper.org/news/17752</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has <a href="http://www.lornajane.net/posts/2012/using-oauth2-for-google-apis-with-php">a new post</a> to her blog today showing how to use the functionality provided by the <a href="http://pecl.php.net/package/pecl_http">pecl_http</a> extension to make an OAuth2 connection to Google.
</p>
<blockquote>
I've written about Google and OAuth before, but that was OAuth v1.0, and they are introducing OAuth2 for their newer APIs; in this example I was identifying myself in order to use the Google Plus API. [...] OAuth 2 doesn't need an extension or any particular library as it doesn't have the signing component that OAuth 1 had, and OAuth 2 also has fewer round trips. It does require SSL however, because the requests are in the clear.
</blockquote>
<p>
She includes some code snippets with an example of a connection - making a request to the remote HTTPS resource, adding some parameters to the URL (including the response type, your client ID and a redirect url). The response then contains the "code" value you'll need to make the second request to fetch the access token you'll need on future requests. You can find out more about the interface she's accessing in <a href="https://developers.google.com/+/api/">these docs</a> about the Google Plus API.
</p>]]></description>
      <pubDate>Thu, 29 Mar 2012 12:02:21 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Building a simple Parser and Lexer in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17142</guid>
      <link>http://www.phpdeveloper.org/news/17142</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Sameer Borate</i> shows how to <a href="http://www.codediesel.com/php/building-a-simple-parser-and-lexer-in-php/">create a lexer and parser</a> in PHP to work directly with the tokens of a PHP script.
</p>
<blockquote>
After looking around for a while [for a good resource on compilers] I settled for Terence Parr's <a href="http://www.amazon.com/Language-Implementation-Patterns-Domain-Specific-Programming/dp/193435645X/">Language Implementation Patterns</a>. This is exactly what I needed - bit sized patterns on compiler and parser design with working code. The book provides a recipe style approach, gradually moving from simple to complex compiler/parser design issues. As I primarily work with PHP, I thought of porting some code to PHP to see how it works.
</blockquote>
<p>
He shows examples <a href="http://www.codediesel.com/downloads/lexer-parser">using his custom tool</a> to show a basic lexer output for a list and a complete listing of the code involved. Ultimately, though, he finds that PHP isn't overly suited to the task - anything more than his simple example could be more trouble than it's worth.
</p>]]></description>
      <pubDate>Thu, 17 Nov 2011 11:57:59 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Preventing Cross-Site Request Forgeries]]></title>
      <guid>http://www.phpdeveloper.org/news/16920</guid>
      <link>http://www.phpdeveloper.org/news/16920</link>
      <description><![CDATA[<p>
SitePoint' PHPMaster.com has a new tutorial posted today from <i>Martin Psinas</i> about some tactics to <a href="http://phpmaster.com/preventing-cross-site-request-forgeries/">prevent cross-site request forgeries</a> from happening in your PHP application. The article introduces key concepts of CSRF and how you can keep it from happening in your code.
</p>
<blockquote>
Cross-site request forgery (CSRF) is a common and serious exploit where a user is tricked into performing an action he didn't explicitly intend to do. This can happen when, for example, the user is logged in to one of his favorite websites and proceeds to click a seemingly harmless link. In the background, his profile information is silently updated with an attacker's e-mail address. [...] Any action that a user is allowed to perform while logged in to a website, an attacker can perform on his/her behalf, whether it's updating a profile, adding items to a shopping cart, posting messages on a forum, or practically anything else.
</blockquote>
<p>
He shows it to you "in action" with a PHP script for a basic login page that takes a username and password, does some filtering and sets the username to the session. Their "harmless.html" file offers a link to the site's "process" page with a logout action that would allow the "harmless" file access to the current session if clicked. To prevent this from happening, they suggest a unique token be included in interactions on your site. This key is checked against a token in the current session (or other location) and is only valid if they match. 
</p>
<p>
The Symfony framework has <a href="http://www.google.com/#sclient=psy-ab&hl=en&source=hp&q=symfony+csrf">included this as a part of their forms</a> for a while now and includes automatic handling to check its validity. Solutions also exist for other frameworks like <a href="http://www.google.com/#sclient=psy-ab&hl=en&source=hp&q=zend+framework">Zend Framework</a> and many others.
</p>]]></description>
      <pubDate>Wed, 28 Sep 2011 10:12:11 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell' Blog: PHP OAuth Provider: Access Tokens]]></title>
      <guid>http://www.phpdeveloper.org/news/16788</guid>
      <link>http://www.phpdeveloper.org/news/16788</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has posted the latest in her look at OAuth in PHP to her blog today, an <a href="http://www.lornajane.net/posts/2011/php-oauth-provider-access-tokens">introduction to access tokens</a> - generating and handling them in your application.
</p>
<blockquote>
I've been working with <a href="http://oauth.net/">OAuth</a>, as a provider and consumer, and there isn't a lot of documentation around it for PHP at the moment so I thought I'd share my experience in this series of articles. [...] This entry follows on from the ones about the <a href="http://www.lornajane.net/posts/2011/PHP-OAuth-Provider-Initial-Requirements">initial requirements</a>, <a href="http://www.lornajane.net/posts/2011/PHP-OAuth-Provider-Request-Tokens">how to how to handle request tokens</a>, and <a href="http://www.lornajane.net/posts/2011/php-oauth-provider-authenticate-user">authenticating users</a>.
</blockquote>
<p>
In this latest post, she talks about the three different types of tokens - consumer, request and verififier - and how to use them to locate a user in your app's users. Her code validates the request token and verifier against the database and, if successful, inserts the rest of the token information for the user.
</p>]]></description>
      <pubDate>Tue, 30 Aug 2011 08:28:04 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Stas Malyshev's Blog: ZF Oauth Provider]]></title>
      <guid>http://www.phpdeveloper.org/news/16783</guid>
      <link>http://www.phpdeveloper.org/news/16783</link>
      <description><![CDATA[<p>
In a new post <i>Stas Malyshev</i> has <a href="http://php100.wordpress.com/2011/08/28/zf-oauth-provider/">shared some code for an OAuth provider</a> he's written up to work specifically with <a href="http://framework.zend.com">Zend Framework</a> applications. 
</p>
<blockquote>
Zend Framework has pretty good <a href="http://en.wikipedia.org/wiki/OAuth">OAuth</a> <a href="http://framework.zend.com/manual/en/zend.oauth.introduction.html">consumer implementation</a>. However, it has <a href="http://stackoverflow.com/questions/4061435/zend-framework-oauth-provider">no support</a> for implementing OAuth provider, and it turns out that there aren't many <a href="http://stackoverflow.com/questions/6086454/pure-php-oauth-provider">other libraries</a> for it. Most examples out there base on <a href="http://php.net/oauth">PECL oauth extension</a>, which works just fine, with one caveat - you have to have this PECL extension installed, while ZF implementation does not require that. So I went ahead and wrote <a href="https://github.com/smalyshev/Zend_OAuth_Provider">some code that allows to easily add OAuth provider to your ZF-based or ZF-using application</a>. That should make writing OAuth provider easier.
</blockquote>
<p>
His code just fleshes out the server portion of the provider, not all of the token generation and key handling it'll need on the backend - that'll still be the job of your scripts. You can find the library over on github in his <a href="https://github.com/smalyshev/Zend_OAuth_Provider">Zend_OAuth_Provider</a> repository.
</p>]]></description>
      <pubDate>Mon, 29 Aug 2011 10:41:18 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: Getting an OAuth Access Token from the Command Line]]></title>
      <guid>http://www.phpdeveloper.org/news/16448</guid>
      <link>http://www.phpdeveloper.org/news/16448</link>
      <description><![CDATA[<p>
<i>Tim Lytle</i> has written up a <a href="http://devzone.zend.com/article/15363-Getting-an-OAuth-Access-Token-from-the-Command-Line">new tutorial</a> for the Zend Developer Zone talking about OAuth and making one of the more difficult parts - getting an access token - a bit simpler using a command-line application.
</p>
<blockquote>
OAuth is great - there's no need to save users' passwords, it's - in theory - a consistent way to interact with other services, and it's hopefully something that your users are familiar and comfortable using. But if you're not just interacting with your users' accounts - for example, your application uses a single account on a service to broadcast messages, or analyze data - getting or renewing the access token can be painful.
</blockquote>
<p>
He illustrates the problem with an example connecting to Twitter and even <a href="https://gist.github.com/407858">points out a script</a> that makes bridging this gap simpler. Unfortunately, it's not exactly what he needed, so he reworked the idea with a call to the Twitter API using a Zend_Oauth_Consumer and a custom callback. The script is then set up with some command line options for inputting the key and secret information. Also included is functionality letting you define a configuration file. You can see the final result <a href="https://gist.github.com/1014769">here on github</a>.
</p>]]></description>
      <pubDate>Thu, 09 Jun 2011 11:04:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: PHP OAuth Provider: Request Tokens]]></title>
      <guid>http://www.phpdeveloper.org/news/16365</guid>
      <link>http://www.phpdeveloper.org/news/16365</link>
      <description><![CDATA[<p>
In the next of her series looking at OAuth in PHP, <i>Lorna Mitchell</i> has posted <a href="http://www.lornajane.net/posts/2011/PHP-OAuth-Provider-Request-Tokens">a look at request tokens</a> and how to hand them out via your application.
</p>
<blockquote>
The consumer requests a request token (see my <a href="http://www.lornajane.net/posts/2010/Authenticating-with-OAuth-from-PHP">earlier post about consuming OAuth</a>), and as a provider, we need to handle that request. In my example, I chose to pass the variables as GET parameters, but you could adapt this to handle POST variables or information contained in HTTP headers.
</blockquote>
<p>
She includes the code (using the functionality of the <a href="http://pecl.php.net/oauth">pecl_oauth extension</a>) to provide a token and the three functions you'll need to define to get things working - the consumerHandler, the tokenHandler and timestampNonceHandler. She also includes a sample database table structure for storing the OAuth information for a user.
</p>]]></description>
      <pubDate>Fri, 20 May 2011 08:39:17 -0500</pubDate>
    </item>
  </channel>
</rss>
