File tree Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -87,3 +87,10 @@ export async function saveFederation(
87
87
export async function getAllIdentityProviders ( ) : Promise < any > {
88
88
return get ( '/federation/mappings' ) ;
89
89
}
90
+
91
+ /**
92
+ * Returns a list of IdP URLs based on the environment.
93
+ */
94
+ export async function getIdpUrls ( ) : Promise < string [ ] > {
95
+ return get ( '/federation/idp-list' ) ;
96
+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
23
23
toast ,
24
24
} from '~project-sesame/client/helpers/index' ;
25
25
import { SesameIdP } from '~project-sesame/client/helpers/identity' ;
26
+ import { getIdpUrls } from '../helpers/federated' ;
26
27
27
28
postForm (
28
29
async ( ) => {
@@ -37,11 +38,8 @@ postForm(
37
38
if ( 'IdentityCredential' in window ) {
38
39
$ ( '#unsupported' ) . classList . add ( 'hidden' ) ;
39
40
try {
40
- const idp = new SesameIdP ( [
41
- 'https://sesame-identity-provider.appspot.com' ,
42
- 'https://accounts.google.com' ,
43
- 'https://sesame-identity-provider.local'
44
- ] ) ;
41
+ const idpURLs = await getIdpUrls ( ) ;
42
+ const idp = new SesameIdP ( idpURLs ) ;
45
43
const nonce = await idp . initialize ( ) ;
46
44
await idp . signIn ( { mode : 'passive' , mediation : 'required' , nonce} ) ;
47
45
await redirect ( '/home' ) ;
Original file line number Diff line number Diff line change @@ -290,4 +290,25 @@ router.post(
290
290
}
291
291
) ;
292
292
293
+ /**
294
+ * Returns a list of IdP URLs based on the environment.
295
+ */
296
+ router . get (
297
+ '/idp-list' ,
298
+ apiAclCheck ( ApiType . NoAuth ) ,
299
+ ( req : Request , res : Response ) => {
300
+ const idpUrls = [
301
+ 'https://sesame-identity-provider.appspot.com' ,
302
+ 'https://accounts.google.com' ,
303
+ ] ;
304
+
305
+ if ( config . is_localhost ) {
306
+ // TODO: Ideally, let's wrap it in one place to reuse elsewhere
307
+ idpUrls . push ( "https://sesame-identity-provider.local" ) ;
308
+ }
309
+
310
+ return res . json ( idpUrls ) ;
311
+ }
312
+ ) ;
313
+
293
314
export { router as federation } ;
You can’t perform that action at this time.
0 commit comments