MCPcopy Create free account
hub / github.com/N4si/microservices-python-app / validate

Function validate

src/auth-service/server.py:53–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51
52@server.route('/validate', methods=['POST'])
53def validate():
54 encoded_jwt = request.headers['Authorization']
55
56 if not encoded_jwt:
57 return 'Unauthorized', 401, {'WWW-Authenticate': 'Basic realm="Login required!"'}
58
59 encoded_jwt = encoded_jwt.split(' ')[1]
60 try:
61 decoded_jwt = jwt.decode(encoded_jwt, os.environ['JWT_SECRET'], algorithms=["HS256"])
62 except:
63 return 'Unauthorized', 401, {'WWW-Authenticate': 'Basic realm="Login required!"'}
64
65 return decoded_jwt, 200
66
67if __name__ == '__main__':
68 server.run(host='0.0.0.0', port=5000)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected