File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -130,4 +130,6 @@ EXPOSE_API=true
130
130
# PUBLIC_APP_DATA_SHARING=1
131
131
# PUBLIC_APP_DISCLAIMER=1
132
132
133
- ENABLE_ASSISTANTS = false # set to true to enable assistants feature
133
+ ENABLE_ASSISTANTS = false # set to true to enable assistants feature
134
+
135
+ ALTERNATIVE_REDIRECT_URLS = `[]` # valide alternative redirect URL for OAuth
Original file line number Diff line number Diff line change @@ -243,3 +243,7 @@ PUBLIC_PLAUSIBLE_SCRIPT_URL="/js/script.js"
243
243
244
244
ENABLE_ASSISTANTS=true
245
245
EXPOSE_API=true
246
+
247
+ ALTERNATIVE_REDIRECT_URLS=`[
248
+ huggingchat://login/callback
249
+ ]`
Original file line number Diff line number Diff line change 1
1
import { redirect } from "@sveltejs/kit" ;
2
2
import { getOIDCAuthorizationUrl } from "$lib/server/auth" ;
3
3
import { base } from "$app/paths" ;
4
+ import { ALTERNATIVE_REDIRECT_URLS } from "$env/static/private" ;
4
5
5
6
export const actions = {
6
7
async default ( { url, locals, request } ) {
7
- // TODO: Handle errors if provider is not responding
8
8
const referer = request . headers . get ( "referer" ) ;
9
+ let redirectURI = `${ ( referer ? new URL ( referer ) : url ) . origin } ${ base } /login/callback` ;
10
+
11
+ // TODO: Handle errors if provider is not responding
12
+
13
+ if ( url . searchParams . has ( "callback" ) ) {
14
+ const callback = url . searchParams . get ( "callback" ) || redirectURI ;
15
+ if ( ALTERNATIVE_REDIRECT_URLS . includes ( callback ) ) {
16
+ redirectURI = callback ;
17
+ }
18
+ }
19
+
9
20
const authorizationUrl = await getOIDCAuthorizationUrl (
10
- { redirectURI : ` ${ ( referer ? new URL ( referer ) : url ) . origin } ${ base } /login/callback` } ,
21
+ { redirectURI } ,
11
22
{ sessionId : locals . sessionId }
12
23
) ;
13
24
You can’t perform that action at this time.
0 commit comments