def scitokens(): if not stashcache: return Response("Can't get scitokens config: stashcache module unavailable", status=503) cache_fqdn = request.args.get("cache_fqdn") origin_fqdn = request.args.get("origin_fqdn") if not cache_fqdn and not origin_fqdn: return Response("FQDN of cache or origin server required in the 'cache_fqdn' or 'origin_fqdn' argument", status=400) try: if cache_fqdn: cache_scitokens = stashcache.generate_cache_scitokens(global_data.get_vos_data(), global_data.get_topology().get_resource_group_list(), fqdn=cache_fqdn, suppress_errors=False) return Response(cache_scitokens, mimetype="text/plain") elif origin_fqdn: origin_scitokens = stashcache.generate_origin_scitokens(global_data.get_vos_data(), global_data.get_topology().get_resource_group_list(), fqdn=origin_fqdn, suppress_errors=False) return Response(origin_scitokens, mimetype="text/plain") except stashcache.NotRegistered as e: return Response("# No resource registered for {}\n" "# Please check your query or contact [email protected]\n" .format(str(e)), mimetype="text/plain", status=404) except stashcache.DataError as e: app.logger.error("{}: {}".format(request.full_path, str(e))) return Response("# Error generating scitokens config for this FQDN: {}\n".format(str(e)) + "# Please check configuration in OSG topology or contact [email protected]\n", mimetype="text/plain", status=400) except Exception: app.log_exception(sys.exc_info()) return Response("Server error getting scitokens config, please contact [email protected]", status=503)
def _get_cache_scitoken_file(): fqdn = request.args.get('fqdn') get_scitoken_function = lambda fqdn: stashcache.generate_cache_scitokens( global_data.get_vos_data(), global_data.get_topology().get_resource_group_list(), fqdn=fqdn, suppress_errors=False) return _get_scitoken_file(fqdn, get_scitoken_function)