Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
477c4f5b
Unverified
Commit
477c4f5b
authored
5 years ago
by
Patrick Cloke
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Clean-up some auth/login REST code (#7115)
parent
c165c123
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/7115.misc
+1
-0
1 addition, 0 deletions
changelog.d/7115.misc
synapse/rest/client/v1/login.py
+0
-8
0 additions, 8 deletions
synapse/rest/client/v1/login.py
synapse/rest/client/v2_alpha/auth.py
+20
-33
20 additions, 33 deletions
synapse/rest/client/v2_alpha/auth.py
with
21 additions
and
41 deletions
changelog.d/7115.misc
0 → 100644
+
1
−
0
View file @
477c4f5b
De-duplicate / remove unused REST code for login and auth.
This diff is collapsed.
Click to expand it.
synapse/rest/client/v1/login.py
+
0
−
8
View file @
477c4f5b
...
...
@@ -28,7 +28,6 @@ from synapse.http.servlet import (
parse_json_object_from_request
,
parse_string
,
)
from
synapse.push.mailer
import
load_jinja2_templates
from
synapse.rest.client.v2_alpha._base
import
client_patterns
from
synapse.rest.well_known
import
WellKnownBuilder
from
synapse.types
import
UserID
,
map_username_to_mxid_localpart
...
...
@@ -548,13 +547,6 @@ class SSOAuthHandler(object):
self
.
_registration_handler
=
hs
.
get_registration_handler
()
self
.
_macaroon_gen
=
hs
.
get_macaroon_generator
()
# Load the redirect page HTML template
self
.
_template
=
load_jinja2_templates
(
hs
.
config
.
sso_redirect_confirm_template_dir
,
[
"
sso_redirect_confirm.html
"
],
)[
0
]
self
.
_server_name
=
hs
.
config
.
server_name
# cast to tuple for use with str.startswith
self
.
_whitelisted_sso_clients
=
tuple
(
hs
.
config
.
sso_client_whitelist
)
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/client/v2_alpha/auth.py
+
20
−
33
View file @
477c4f5b
...
...
@@ -142,14 +142,6 @@ class AuthRestServlet(RestServlet):
%
(
CLIENT_API_PREFIX
,
LoginType
.
RECAPTCHA
),
"
sitekey
"
:
self
.
hs
.
config
.
recaptcha_public_key
,
}
html_bytes
=
html
.
encode
(
"
utf8
"
)
request
.
setResponseCode
(
200
)
request
.
setHeader
(
b
"
Content-Type
"
,
b
"
text/html; charset=utf-8
"
)
request
.
setHeader
(
b
"
Content-Length
"
,
b
"
%d
"
%
(
len
(
html_bytes
),))
request
.
write
(
html_bytes
)
finish_request
(
request
)
return
None
elif
stagetype
==
LoginType
.
TERMS
:
html
=
TERMS_TEMPLATE
%
{
"
session
"
:
session
,
...
...
@@ -158,17 +150,19 @@ class AuthRestServlet(RestServlet):
"
myurl
"
:
"
%s/r0/auth/%s/fallback/web
"
%
(
CLIENT_API_PREFIX
,
LoginType
.
TERMS
),
}
html_bytes
=
html
.
encode
(
"
utf8
"
)
request
.
setResponseCode
(
200
)
request
.
setHeader
(
b
"
Content-Type
"
,
b
"
text/html; charset=utf-8
"
)
request
.
setHeader
(
b
"
Content-Length
"
,
b
"
%d
"
%
(
len
(
html_bytes
),))
request
.
write
(
html_bytes
)
finish_request
(
request
)
return
None
else
:
raise
SynapseError
(
404
,
"
Unknown auth stage type
"
)
# Render the HTML and return.
html_bytes
=
html
.
encode
(
"
utf8
"
)
request
.
setResponseCode
(
200
)
request
.
setHeader
(
b
"
Content-Type
"
,
b
"
text/html; charset=utf-8
"
)
request
.
setHeader
(
b
"
Content-Length
"
,
b
"
%d
"
%
(
len
(
html_bytes
),))
request
.
write
(
html_bytes
)
finish_request
(
request
)
return
None
async
def
on_POST
(
self
,
request
,
stagetype
):
session
=
parse_string
(
request
,
"
session
"
)
...
...
@@ -196,15 +190,6 @@ class AuthRestServlet(RestServlet):
%
(
CLIENT_API_PREFIX
,
LoginType
.
RECAPTCHA
),
"
sitekey
"
:
self
.
hs
.
config
.
recaptcha_public_key
,
}
html_bytes
=
html
.
encode
(
"
utf8
"
)
request
.
setResponseCode
(
200
)
request
.
setHeader
(
b
"
Content-Type
"
,
b
"
text/html; charset=utf-8
"
)
request
.
setHeader
(
b
"
Content-Length
"
,
b
"
%d
"
%
(
len
(
html_bytes
),))
request
.
write
(
html_bytes
)
finish_request
(
request
)
return
None
elif
stagetype
==
LoginType
.
TERMS
:
authdict
=
{
"
session
"
:
session
}
...
...
@@ -225,17 +210,19 @@ class AuthRestServlet(RestServlet):
"
myurl
"
:
"
%s/r0/auth/%s/fallback/web
"
%
(
CLIENT_API_PREFIX
,
LoginType
.
TERMS
),
}
html_bytes
=
html
.
encode
(
"
utf8
"
)
request
.
setResponseCode
(
200
)
request
.
setHeader
(
b
"
Content-Type
"
,
b
"
text/html; charset=utf-8
"
)
request
.
setHeader
(
b
"
Content-Length
"
,
b
"
%d
"
%
(
len
(
html_bytes
),))
request
.
write
(
html_bytes
)
finish_request
(
request
)
return
None
else
:
raise
SynapseError
(
404
,
"
Unknown auth stage type
"
)
# Render the HTML and return.
html_bytes
=
html
.
encode
(
"
utf8
"
)
request
.
setResponseCode
(
200
)
request
.
setHeader
(
b
"
Content-Type
"
,
b
"
text/html; charset=utf-8
"
)
request
.
setHeader
(
b
"
Content-Length
"
,
b
"
%d
"
%
(
len
(
html_bytes
),))
request
.
write
(
html_bytes
)
finish_request
(
request
)
return
None
def
on_OPTIONS
(
self
,
_
):
return
200
,
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment