OAuth

PeeringDB now offers OAuth2 authentication for third-party applications to allow users to authenticate against PeeringDB.

Implementation details are at https://github.com/peeringdb/peeringdb/issues/131. For an example, see https://github.com/inex/IXP-Manager/issues/322.

What is OAuth?

There is a good write up at https://aaronparecki.com/oauth-2-simplified/.

Register an application

First you need to register your application at https://peeringdb.com/oauth2/applications/.

URLs

PDB_ENDPOINT = "https://auth.peeringdb.com/"

PDB_OAUTH_ACCESS_TOKEN_URL = '{}oauth2/token/'.format(PDB_ENDPOINT)
PDB_OAUTH_AUTHORIZE_URL = '{}oauth2/authorize/'.format(PDB_ENDPOINT)
PDB_OAUTH_PROFILE_URL = '{}profile/v1'.format(PDB_ENDPOINT)

Fields

The fields are based largely on OpenID Connect.

Scopes currently are defined as

The perms field is a bitmask for CRUD as the 4 least significant bits. See following:

0b0000 1 1 1 1
       | | | +-- Delete
       | | +---- Update
       | +------ Read
       + ------- Create

Example for my user:

{
  "id": 3,
  "name": "Matt Griswold",
  "given_name": "Matt",
  "family_name": "Griswold",
  "email": "grizz@20c.com",
  "verified_user": true,
  "verified_email": true,
  "networks": [
    {
      "perms": 15,
      "asn": 63311,
      "name": "20C",
      "id": 20
    }, 
    {
      "perms": 15,
      "asn": 33713,
      "name": "United IX",
      "id": 7889
    }
  ]
}