Skip to content

Commit 2a7ded8

Browse files
authored
Merge pull request #317 from DuendeSoftware/wca/bff-silent-login
Updates silent login and DPoP event configuration
2 parents ec33108 + 84d8606 commit 2a7ded8

4 files changed

Lines changed: 18 additions & 13 deletions

File tree

BFF/v4/DPoP/DPoP.Api/DPoP/ConfigureJwtBearerOptions.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@ public void PostConfigure(string name, JwtBearerOptions options)
1919
{
2020
if (_configScheme == name)
2121
{
22-
if (options.EventsType != null && !typeof(DPoPJwtBearerEvents).IsAssignableFrom(options.EventsType))
22+
var dpopEventsType = typeof(DPoPJwtBearerEvents);
23+
if (options.EventsType != null && !dpopEventsType.IsAssignableFrom(options.EventsType))
2324
{
2425
throw new Exception("EventsType on JwtBearerOptions must derive from DPoPJwtBearerEvents to work with the DPoP support.");
2526
}
26-
if (options.Events != null && !typeof(DPoPJwtBearerEvents).IsAssignableFrom(options.Events.GetType()))
27-
{
28-
throw new Exception("Events on JwtBearerOptions must derive from DPoPJwtBearerEvents to work with the DPoP support.");
29-
}
3027

31-
if (options.Events == null && options.EventsType == null)
28+
if (!dpopEventsType.IsInstanceOfType(options.Events))
3229
{
33-
options.EventsType = typeof(DPoPJwtBearerEvents);
30+
if (typeof(JwtBearerEvents) == options.Events.GetType())
31+
{
32+
// Default scenario where the events type wasn't overridden?
33+
options.EventsType = dpopEventsType;
34+
}
35+
else
36+
{
37+
throw new Exception("Events on JwtBearerOptions must derive from DPoPJwtBearerEvents to work with the DPoP support.");
38+
}
3439
}
3540
}
3641
}

BFF/v4/DPoP/DPoP.Bff/wwwroot/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const loginUrl = "/bff/login";
2-
const silentLoginUrl = "/bff/silent-login";
2+
const silentLoginUrl = "/bff/login?prompt=none";
33
const userUrl = "/bff/user";
44
const localApiUrl = "/local";
55
const remoteApiUrl = "/api";
@@ -224,7 +224,7 @@ function silentLogin(iframeSelector) {
224224
// we can either just treat this like a "not logged in"
225225
resolve(false);
226226
// or we can trigger an error, so someone can look into the reason why
227-
// reject(new Error("timed_out"));
227+
// reject(new Error("timed_out"));
228228
}, timeout);
229229

230230
// send the iframe to the silent login endpoint to kick off the workflow

BFF/v4/OpenApi/OpenApi.Bff/wwwroot/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const loginUrl = "/bff/login";
2-
const silentLoginUrl = "/bff/silent-login";
2+
const silentLoginUrl = "/bff/login?prompt=none";
33
const userUrl = "/bff/user";
44
const apiUrl = "/api1/weatherforecastFahrenheit";
55
let logoutUrl = "/bff/logout";
@@ -148,7 +148,7 @@ function silentLogin(iframeSelector) {
148148
// we can either just treat this like a "not logged in"
149149
resolve(false);
150150
// or we can trigger an error, so someone can look into the reason why
151-
// reject(new Error("timed_out"));
151+
// reject(new Error("timed_out"));
152152
}, timeout);
153153

154154
// send the iframe to the silent login endpoint to kick off the workflow

BFF/v4/TokenExchange/TokenExchange.Bff/wwwroot/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const loginUrl = "/bff/login";
2-
const silentLoginUrl = "/bff/silent-login";
2+
const silentLoginUrl = "/bff/login?prompt=none";
33
const userUrl = "/bff/user";
44
const localApiUrl = "/local";
55
const remoteApiUrl = "/api";
@@ -165,7 +165,7 @@ function silentLogin(iframeSelector) {
165165
// we can either just treat this like a "not logged in"
166166
resolve(false);
167167
// or we can trigger an error, so someone can look into the reason why
168-
// reject(new Error("timed_out"));
168+
// reject(new Error("timed_out"));
169169
}, timeout);
170170

171171
// send the iframe to the silent login endpoint to kick off the workflow

0 commit comments

Comments
 (0)