Coder Social home page Coder Social logo

tfa_oauth2_server's Introduction

TFA OAuth2 Server

A Drupal module to integrate TFA with [OAuth2 Server] (https://www.drupal.org/project/oauth2_server).

This interrupts the Password Credentials ('password') grant type for users who have enabled TFA.

Currently, this requires the latest dev version of OAuth2 Server

Or apply this patch: https://www.drupal.org/files/issues/oauth2_server-token_hook-2571265-2.patch

Flow

The client requests a token using password credentials, as normal:

POST /oauth2/token
Accept: application/json
Authorization: Basic <base64-encoded client credentials>
Content-Type: application/x-www-form-urlencoded

grant_type=password&username=alice&password=passw0rd

If the password is incorrect, then the normal OAuth 2.0 error is sent.

If the password is correct, and the user has TFA enabled, then a 403 response is sent:

401 Unauthorized
Content-Type: application/json
X-Drupal-TFA: required, schemes=totp

{"error":"invalid_grant", "error_description": "Two-factor authentication is required"}

The initial request should be repeated, with the current TOTP code included:

POST /oauth2/token
Accept: application/json
Authorization: Basic <base64-encoded client credentials>
Content-Type: application/x-www-form-urlencoded
X-Drupal-TFA: 123456

grant_type=password&username=alice&password=passw0rd

The TOTP code is validated, and an OAuth 2.0 access token is sent as normal if it succeeds.

tfa_oauth2_server's People

Contributors

pjcdawkins avatar

Watchers

 avatar  avatar

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.