Skip to content

ericso/scrying-me

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 

Repository files navigation

API Server

GET   /api/v0/token  send username/password, get auth token
POST  /api/v0/users  Creates a new user with username/password
GET   /api/v0/users/<username>  Retrieves the user with username <username>
GET   /api/v0/resource  Retrieves example resource, requires authentication

Authorization flow:
1. Create a user by posting to /api/v0/users with username and password in JSON format
2. Get a token by sending username/password using HTTP Basic authorization to /api/v0/token
3. Cache token on client and send token in username field (Basic auth) on GET requests to resource
4. Token default expiration is 10 minutes; when request fails due to auth, get another token

# Examples
# Register a user
$ curl -i -X POST -H "Content-Type: application/json" -d '{"username":"test_user","password":"test_password"}' http://127.0.0.1:5000/api/v0/users

# Get a resource with username/password
$ curl -u test_user:test_password -i -X GET http://127.0.0.1:5000/api/v0/resource

# Get an auth token
$ curl -u test_user:test_password -i -X GET http://127.0.0.1:5000/api/v0/token

# Get resource using retrieved token, token value is sent in username field, password is unused so can be anything
$ curl -u token_value:unused -i -X GET http://127.0.0.1:5000/api/v0/resources

Run the tests:
$ nosetests

to run a single test controller:
nosetests app.tests.test_filename:TestControllerClassName

to run a single test method:
nosetests app_name.tests.test_filename:TestControllerClassName.test_method_name
(e.g.: nosetests api.tests.test_users:UsersTest.test_update_user_password)

TODO:
Write tests for User model
 - unique usernames

Write tests for Views
 - return CORS headers on each response to API

users api routes
 - get user by username should use same get route as ID, it should check if integer or string
 - create user should return username successfully created
 - change /token route to /authenticate

Add foreign key to tie Trips to Users
Add tests
Write database migration scripts

About

An app for keeping track of your vacations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published