Skip to main content

Nexmo Verify support for Kinto

travis Coverage

kinto-nexmo-verify enables authentication in Kinto applications using *Nexmo Verify* Passwordless Authentication.

It provides:

  • An authentication policy class;

  • Integration with Kinto cache backend for token verifications;

  • Integration with Kinto for heartbeat view checks;

  • Endpoints to perform the Nexmo dance and grab a JWT authentication token.

  • Kinto documentation

  • Issue tracker

Installation

Install the Python package:

pip install kinto-nexmo-verify

Include the package in the project configuration:

kinto.includes = kinto_nexmo_verify

And configure authentication policy using pyramid_multiauth formalism:

multiauth.policies = nexmo
multiauth.policy.nexmo.use = kinto_nexmo_verify.authentication.PasswordlessAuthenticationPolicy

By default, it will rely on the cache configured in Kinto.

Configuration

Fill those settings with the values obtained during the application registration:

nexmo.api_key = 89513028159972bc
nexmo.api_secret = 9aced230585cc0aaea0a3467dd800
nexmo.webapp.authorized_domains = *
# nexmo.cache_ttl_seconds = 300
# nexmo.state.ttl_seconds = 3600

If necessary, override default values for authentication policy:

# multiauth.policy.nexmo.realm = Realm

Login flow

JWT authentication token

Use the JWT token with this header:

Authorization: Nexmo <jwt_token>
notes:

If the token is not valid, this will result in a 401 error response.

Obtain JWT token flow

To initiate a passwordless session, start by sending the mobile phone number to POST /v1/nexmo/verify

$ http POST http://localhost:8000/v1/nexmo/verify number=447700900000 -v

POST /v1/nexmo/verify HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 44
Content-Type: application/json
Host: localhost:8000
User-Agent: HTTPie/0.9.9

{
    "number": "447700900000"
}


HTTP/1.1 200 OK
Content-Length: 51
Content-Type: application/json; charset=UTF-8
Date: Thu, 21 Feb 2019 09:28:37 GMT
Server: waitress

{
    "request_id": "89513028159972bc",
    "number": "verify"
}

Then, once you receive the message from the number verify, you can read its code and verify it using a POST /v1/nexmo/verify/check

$ http POST http://localhost:8000/v1/nexmo/verify/check request_id=89513028159972bc code=5992 -v

POST /v1/nexmo/verify/check HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 50
Content-Type: application/json
Host: localhost:8000
User-Agent: HTTPie/0.9.9

{
    "code": "5992",
    "request_id": "89513028159972bc"
}


HTTP/1.1 202 Accepted
Content-Length: 232
Content-Type: application/json; charset=UTF-8
Date: Thu, 21 Feb 2019 09:28:37 GMT
Server: waitress

{
    "jwt_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.xOzQ0jczoCaK_6hHUaOfAh8XqU5HRVcIAl-OdXkZVMc",
    "payload": {"number": "447700900000"}
}

Changelog

This document describes changes between each past release.

1.0.0 (2020-01-20)

  • Initial service.

Contributors

Release files for kinto-nexmo-verify 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kinto-nexmo-verify 1.0.0
File Size Uploaded
kinto-nexmo-verify-1.0.0.tar.gz 15.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kinto-nexmo-verify 1.0.0
File Interpreter ABI Platform
kinto_nexmo_verify-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.5 kB

Release files / kinto-nexmo-verify-1.0.0.tar.gz

Download URL kinto-nexmo-verify-1.0.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
97fbc4eee6c2ef6af641fc32832b3910de8fcc3cc1ddb0464c5cb940a8650c0e
BLAKE2b-256 checksum
How to use checksums
c39729283caf632ebe76c717deeabbc6c5a5126c1172096b355f46284fe5fe50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/3.6.9

Release files / kinto_nexmo_verify-1.0.0-py3-none-any.whl

Download URL kinto_nexmo_verify-1.0.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fef88190d0961cc67b42a879b512955d9f99c6be4f56555d6b1a7b54a4a56b3
BLAKE2b-256 checksum
How to use checksums
feb36cff737c78b3e91680423d075b3e2341ccf17c2c9c03ba04cc035d947f00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page