Skip to content

Commit 4d51d08

Browse files
committed
test
1 parent f9bb944 commit 4d51d08

3 files changed

Lines changed: 35 additions & 5 deletions

File tree

OpenFlow/src/LoginProvider.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class samlauthstrategyoptions {
6767
}
6868
export class LoginProvider {
6969
private static _logger: winston.Logger;
70-
private static _providers: any = {};
70+
public static _providers: any = {};
7171
private static login_providers: Provider[] = [];
7272

7373
public static redirect(res: any, originalUrl: string) {
@@ -153,6 +153,20 @@ export class LoginProvider {
153153
});
154154

155155
app.get("/Signout", (req: any, res: any, next: any): void => {
156+
var providerid: string = req.cookies.provider;
157+
var provider: passport.Strategy;
158+
if (providerid != null && providerid != undefined && providerid != "") {
159+
provider = LoginProvider._providers[providerid];
160+
}
161+
if (provider != null && provider != undefined) {
162+
(provider as any).logout(req, function (err, requestUrl) {
163+
// LOCAL logout
164+
req.logout();
165+
// redirect to the IdP with the encrypted SAML logout request
166+
res.redirect(requestUrl);
167+
});
168+
return;
169+
}
156170
req.logout();
157171
var originalUrl: any = req.cookies.originalUrl;
158172
if (!Util.IsNullEmpty(originalUrl)) {
@@ -510,6 +524,7 @@ export class LoginProvider {
510524
passport.authenticate(key, { failureRedirect: "/" + key, failureFlash: true }),
511525
function (req: any, res: any): void {
512526
var originalUrl: any = req.cookies.originalUrl;
527+
res.cookie("provider", key, { maxAge: 900000, httpOnly: true });
513528
if (!Util.IsNullEmpty(originalUrl)) {
514529
res.cookie("originalUrl", "", { expires: new Date(0) });
515530
LoginProvider.redirect(res, originalUrl);

OpenFlow/src/SamlProvider.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as samlp from "samlp";
66
import { Config } from "./Config";
77
import { TokenUser } from "./TokenUser";
88
import { Audit } from "./Audit";
9+
import { LoginProvider } from "./LoginProvider";
910

1011
export class SamlProvider {
1112
private static _logger: winston.Logger;
@@ -62,7 +63,7 @@ export class SamlProvider {
6263
var cert: string = Buffer.from(Config.signing_crt, "base64").toString("ascii");
6364
var key: string = Buffer.from(Config.singing_key, "base64").toString("ascii");
6465

65-
var samlpoptions: any = {
66+
var samlpoptions: any = {
6667
issuer: Config.saml_issuer,
6768
cert: cert,
6869
key: key,
@@ -83,7 +84,7 @@ export class SamlProvider {
8384
return req.user;
8485
},
8586
profileMapper: SamlProvider.profileMapper,
86-
lifetimeInSeconds: (3600*24)
87+
lifetimeInSeconds: (3600 * 24)
8788
};
8889

8990
app.get("/issue/", (req: any, res: any, next: any): void => {
@@ -130,14 +131,28 @@ export class SamlProvider {
130131
// }));
131132

132133
// TODO: FIX !!!!
133-
app.get('/logout', (req: any, res: any, next: any): void => {
134+
app.get('/logout', async (req: any, res: any, next: any) => {
134135
var referer: string = req.headers.referer;
135136
req.logout();
136137
if (referer !== null && referer !== undefined && referer !== "") {
138+
// var providers = await LoginProvider.getProviders();
137139
res.redirect(referer);
140+
// var html = "<html><head></head><body>";
141+
// providers.forEach(provider => {
142+
// if (provider.provider === "saml") {
143+
// html += "<iframe src='https://www.w3schools.com'></iframe>"
144+
// }
145+
// });
146+
147+
148+
149+
// // https://sso.slagelse.dk/adfs/ls/?wa=wsignout1.0
150+
151+
// res.send(html)
138152
} else {
139153
res.redirect("/");
140154
}
155+
141156
// samlp.logout({
142157
// issuer: Config.saml_issuer,
143158
// protocolBinding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.361
1+
0.0.362

0 commit comments

Comments
 (0)