auth-api

command
v0.0.0-...-4da4903 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2018 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

auth-api

This part of the exercise is responsible for authentication. It is written in Go and tested with Go1.9.

It provides a single useful API endpoint POST /login that takes a simple JSON object and returns an access token in case of successful authentication.

The JSON object structure is following:

{
    "username": "admin",
    "password": "admin",
}

Prerequisites

Users API must be running, because auth-api fetches user data from it (yes, it is a little bit contrived, but anyways it's OVERENGINEERING!)

Configuration

The service scans environment for variables:

  • AUTH_API_PORT - the port the service takes.
  • USERS_API_ADDRESS - base URL of Users API.
  • JWT_SECRET - secret value for JWT generator. Must be shared amongst all components.

Following users are hardcoded for you:

Username Password
admin admin
johnd foo
janed ddd

Building and running

  1. Update the dependencies with glide
glide up
  1. Compile a binary and then run it
go build
AUTH_API_PORT=8000 USERS_API_ADDRESS=http://users-api:8082 JWT_SECRET=foo ./auth-api

Usage

 curl -X POST  127.0.0.1:8000/login -d '{"username": "admin","password": "admin"}'

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL