Skip to content
/ kvmd Public

Commit 815ffc5

Browse files
committed
WIP: OAuth: import changes from demo instance
1 parent 2fa2a4d commit 815ffc5

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

kvmd/apps/kvmd/api/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def __oauth(self, request: Request) -> None:
167167
if not self.__auth_manager.oauth_manager.valid_provider(provider):
168168
raise HTTPNotFound(reason="Unknown provider %s" % provider)
169169

170-
redirect_url = request.url.with_path(f"/api/auth/oauth/callback/{provider}").with_scheme('https')
170+
redirect_url = request.url.with_path(f"/api/auth/oauth/callback/{provider}/").with_scheme('https')
171171
oauth_cookie = request.cookies.get(_COOKIE_OAUTH_SESSION, "")
172172

173173
is_valid_session = await self.__auth_manager.oauth_manager.is_valid_session(provider, oauth_cookie)

kvmd/apps/kvmd/auth.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@
4242

4343

4444
# =====
45-
class AuthManager: # pylint: disable=too-many-instance-attributes
46-
def __init__( # pylint: disable=too-many-arguments
47-
48-
4945
@dataclasses.dataclass(frozen=True)
5046
class _Session:
5147
user: str

web/share/js/login/main.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,22 @@ export function main() {
5454
}
5555

5656
function __loadProviders () {
57-
let http = tools.makeRequest("GET", "/api/auth/oauth/providers", function() {
58-
if (http.readyState === 4) {
59-
if (http.status === 200) {
60-
let oauthInfo = JSON.parse(http.responseText).result;
61-
if (!oauthInfo.enabled) {
62-
return;
63-
}
64-
let buttons = `<tr>
65-
<td colspan="2">
66-
<hr>
67-
</td>
68-
</tr>
69-
<tr><td>&nbsp;</tr></td>`
70-
for (const [short_name, long_name] of Object.entries(oauthInfo.providers)) {
71-
buttons += __makeProvider(short_name, long_name);
72-
}
73-
$("oauth-tbody").innerHTML = buttons
57+
tools.httpRequest("GET", "/api/auth/oauth/providers", null, function(http) {
58+
if (http.status === 200) {
59+
let oauthInfo = JSON.parse(http.responseText).result;
60+
if (!oauthInfo.enabled) {
61+
return;
62+
}
63+
let buttons = `<tr>
64+
<td colspan="2">
65+
<hr>
66+
</td>
67+
</tr>
68+
<tr><td>&nbsp;</tr></td>`
69+
for (const [short_name, long_name] of Object.entries(oauthInfo.providers)) {
70+
buttons += __makeProvider(short_name, long_name);
7471
}
72+
$("oauth-tbody").innerHTML = buttons
7573
}
7674
})
7775
}

0 commit comments

Comments
 (0)