Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle CORS for GetValidated3pidServlet #342

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/PR342.bugfix
@@ -0,0 +1 @@
Handle CORS for GetValidated3pidServlet. Endpoint /3pid/getValidated3pid returns valid CORS headers.
PiotrKozimor marked this conversation as resolved.
Show resolved Hide resolved
PiotrKozimor marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 6 additions & 1 deletion sydent/http/servlets/getvalidated3pidservlet.py
Expand Up @@ -17,7 +17,7 @@

from twisted.web.resource import Resource

from sydent.http.servlets import jsonwrap, get_args
from sydent.http.servlets import jsonwrap, get_args, send_cors
from sydent.http.auth import authV2
from sydent.db.valsession import ThreePidValSessionStore
from sydent.util.stringutils import is_valid_client_secret
Expand All @@ -38,6 +38,7 @@ def __init__(self, syd, require_auth=False):

@jsonwrap
def render_GET(self, request):
send_cors(request)
if self.require_auth:
authV2(self.sydent, request)

Expand Down Expand Up @@ -79,3 +80,7 @@ def render_GET(self, request):
}

return {"medium": s.medium, "address": s.address, "validated_at": s.mtime}

def render_OPTIONS(self, request):
send_cors(request)
return b""