Code Monkey home page Code Monkey logo

Comments (7)

hueniverse avatar hueniverse commented on June 2, 2024

Sweet! Do you have an example of how this is used on the server to validate incoming requests?

from hawk.

alexbilbie avatar alexbilbie commented on June 2, 2024

Server usage will be along the lines of:

$hawk = getallheaders()['Authentication']; // the authorisation header

// First parse the header to get the parts from the string
$hawk_parts = Hawk::parseHeader($hawk);

// Then with your own function, get the secret for the key from the database
$secret = getSecret($hawk_parts['id']);

// Now validate the request
$valid = Hawk::verifyHeader($hawk, array(
        'host'  =>  'api.example.com',
        'port'  =>  443,
        'path'  =>  '/user/123',
        'method'    =>  'GET'
    ), $secret); // return true if the request is valid, otherwise false

// Server response
if ( ! $valid)
{
        die('Invalid authentication');
}

else
{
        // API response
}

from hawk.

hueniverse avatar hueniverse commented on June 2, 2024

Looks great. Going to make some changes soon so hope you keep it up to date. I also plan to write some test cases and a test server for interop testing.

from hawk.

alexbilbie avatar alexbilbie commented on June 2, 2024

Great. If you want any help with anything or want someone else to help bash some ideas around then feel free to give me a shout - [email protected]

from hawk.

hueniverse avatar hueniverse commented on June 2, 2024

It would be great if you could implement 0.5.0 with payload hash support, URI bewit, and a new non-backwards compatible MAC calculation.

from hawk.

hueniverse avatar hueniverse commented on June 2, 2024

Note the changes from 0.6 to 0.9 are mainly just API changes, not protocol changes. The only exceptions are:

  • added support for dlg and app attributes used by Oz in 0.9.0
  • escaping of the ext string for '' (to '') and '\n' (to '\n')

from hawk.

lock avatar lock commented on June 2, 2024

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

from hawk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.