Giter Club home page Giter Club logo

basic-auth-service's Introduction

HTTP Basic authorization backend service

This service provides a REST API to manage basic-authorization credentials, and an endpoint for validating credentials provided in a request.

REST API

The REST API for managing credentials is availabile at the /api endpoint.

See the API docs for details on API calls.

API credentials

The REST API requires basic-authorization for access.

Credentials for API access can be managed with the manage-credentials script. This allows adding, removing and listing users. As an example:

$ ./manage-credentials add myuser --description 'a user'
+----------+------------+-------------+
| Username | Password   | Description |
+----------+------------+-------------+
| myuser   | uXaQtXJV6q | a user      |
+----------+------------+-------------+

$ ./manage-credentials list
+----------+-------------+
| Username | Description |
+----------+-------------+
| myuser   | a user      |
| youruser |             |
+----------+-------------+

$ ./manage-credentials remove myuser

Credentials validation

The validation endpoint is presented at /auth-check and returns an empty response with the following HTTP codes:

  • 200 for valid credentials
  • 401 for invalid credentials

This endpoint can be used to integrate the application with web servers; the following snippet shows an example for the Nginx web server:

upstream auth_backend {
    server localhost:8080;
}

server {

    # ... other server config

    # this location is protected by basic-auth 
    location /secret {
        auth_request /auth;
    }

    location = /auth {
        proxy_pass http://auth_backend/auth-check/;
    }

basic-auth-service's People

Contributors

albertodonato avatar frankban avatar jcsackett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

basic-auth-service's Issues

MIME issue with dev/api-client

I know it's just a test script, but it's nicer than messing with curl options.

Currently I'm getting this mime-related error when using it against staging:

$ dev/api-client --debug --creds foo:bar --url https://auth.extended.security.staging.ubuntu.com/api credentials add user=andreas
POST https://auth.extended.security.staging.ubuntu.com/api/credentials - {'user': 'andreas'}
400 Bad Request - {'message': 'Invalid request MIME type', 'code': 'Bad Request'}

This equivalent curl request worked:

$ curl -H 'Content-Type: application/json;profile=basic-auth.api;version=1.0' -X POST https://foo:[email protected]/api/credentials -d '{"user": "andreas"}'
{"token": "secret1:secret2", "user": "andreas"}

Sanitize user when creating credentials

We should probably prevent funny characters in the the user string when creating a set of credentials, since that ends up directly in the URL for some API calls:

$ dev/api-client --creds api-user:eX8uspKWUS5UYY5t8lYp credentials add user=../andreas
201 Created - {'token': 'mf2z9BtCa7U8IAIETRAK:72bO4kxi1Knezc4ZWLVY', 'user': '../andreas'}
basic-auth=> select * from credentials;
 id |    user    |       username       |       password       
----+------------+----------------------+----------------------
  1 | ../andreas | mf2z9BtCa7U8IAIETRAK | 72bO4kxi1Knezc4ZWLVY
(1 row)

Server log when trying to delete this user:
127.0.0.1 - - [22/May/2017:20:51:50 +0000] "DELETE /api/credentials/../andreas HTTP/1.1" 404 172 "-" "python-requests/2.9.1"

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.