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" ;
25
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" ;
1210
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
1417
1518passport . use ( new SamlStrategy ( {
1619 callbackUrl : config . serverURL + '/auth/saml/callback' ,
@@ -62,11 +65,15 @@ passport.use(new SamlStrategy({
6265 }
6366 if ( needSave ) {
6467 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+ }
6671 return done ( null , user )
6772 } )
6873 } else {
69- if ( config . debug ) { logger . debug ( 'user login: ' + user . id ) }
74+ if ( config . debug ) {
75+ logger . debug ( 'user login: ' + user . id )
76+ }
7077 return done ( null , user )
7178 }
7279 }
@@ -92,5 +99,5 @@ samlAuth.post('/auth/saml/callback', urlencodedParser,
9299
93100samlAuth . get ( '/auth/saml/metadata' , function ( req , res ) {
94101 res . type ( 'application/xml' )
95- res . send ( passport . _strategy ( 'saml' ) . generateServiceProviderMetadata ( ) )
102+ res . send ( ( passport as any ) . _strategy ( 'saml' ) . generateServiceProviderMetadata ( ) )
96103} )
0 commit comments