-
Notifications
You must be signed in to change notification settings - Fork 23
Using Basic Auth username & password for posting RPMs
marshyski edited this page Oct 7, 2014
·
3 revisions
Example usage:
curl -u timski:FastForward4149 -F [email protected] http://localhost/api/upload
Additions to requirements.txt:
Flask-HTTPAuth==2.2.1
Additions to init.py:
from flask import Flask, request, jsonify, make_response
from flask.ext.httpauth import HTTPBasicAuth
# Under app =
auth = HTTPBasicAuth()
# Under app.config
@auth.get_password
def get_password(username):
if username == 'timski':
return 'FastForward4149'
return None
@auth.error_handler
def unauthorized():
return make_response(jsonify(message='Unauthorized Access', status=403), 403)
#Under app.route /api/upload
@auth.login_required