1
- 'use strict'
1
+ import * as fs from "fs" ;
2
+ import { Router } from "express" ;
3
+ import * as passport from "passport" ;
4
+ import { Strategy as SamlStrategy } from "passport-saml" ;
2
5
3
- const Router = require ( 'express' ) . Router
4
- const passport = require ( 'passport' )
5
- const SamlStrategy = require ( 'passport-saml' ) . Strategy
6
- const config = require ( '../../config' )
7
- const models = require ( '../../models' )
8
- const logger = require ( '../../logger' )
9
- const { urlencodedParser } = require ( '../../utils' )
10
- const fs = require ( 'fs' )
11
- const intersection = function ( array1 , array2 ) { return array1 . filter ( ( n ) => array2 . includes ( n ) ) }
6
+ import * as config from "../../config" ;
7
+ import * as models from "../../models" ;
8
+ import * as logger from "../../logger" ;
9
+ import { urlencodedParser } from "../../utils" ;
12
10
13
- const samlAuth = module . exports = Router ( )
11
+ const intersection = function ( array1 , array2 ) {
12
+ return array1 . filter ( ( n ) => array2 . includes ( n ) )
13
+ }
14
+
15
+ const samlAuth = Router ( )
16
+ export = samlAuth
14
17
15
18
passport . use ( new SamlStrategy ( {
16
19
callbackUrl : config . serverURL + '/auth/saml/callback' ,
@@ -62,11 +65,15 @@ passport.use(new SamlStrategy({
62
65
}
63
66
if ( needSave ) {
64
67
user . save ( ) . then ( function ( ) {
65
- if ( config . debug ) { logger . debug ( 'user login: ' + user . id ) }
68
+ if ( config . debug ) {
69
+ logger . debug ( 'user login: ' + user . id )
70
+ }
66
71
return done ( null , user )
67
72
} )
68
73
} else {
69
- if ( config . debug ) { logger . debug ( 'user login: ' + user . id ) }
74
+ if ( config . debug ) {
75
+ logger . debug ( 'user login: ' + user . id )
76
+ }
70
77
return done ( null , user )
71
78
}
72
79
}
@@ -92,5 +99,5 @@ samlAuth.post('/auth/saml/callback', urlencodedParser,
92
99
93
100
samlAuth . get ( '/auth/saml/metadata' , function ( req , res ) {
94
101
res . type ( 'application/xml' )
95
- res . send ( passport . _strategy ( 'saml' ) . generateServiceProviderMetadata ( ) )
102
+ res . send ( ( passport as any ) . _strategy ( 'saml' ) . generateServiceProviderMetadata ( ) )
96
103
} )
0 commit comments