Skip to content

Commit 5dc9e1d

Browse files
committed
feat: remember credentials by default
1 parent 9dd2e50 commit 5dc9e1d

5 files changed

Lines changed: 27 additions & 23 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Or [manually](#full-options), with discovery disabled.
5555
| `jwksUri` | only if `discovery: false` | – | Provider JWKS URI |
5656
| `familyNameField` | no | `"family_name"` | Userinfo claim for last name |
5757
| `givenNameField` | no | `"given_name"` | Userinfo claim for first name |
58-
| `rememberMe` | no | `false` | Store JWT in localStorage (`true`) or cookie (`false`) |
58+
| `rememberMe` | no | `true` | Store JWT in localStorage (`true`) or cookie (`false`) |
5959

6060
### Optional routing
6161

‎cypress/e2e/login.cy.js‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,15 @@ describe("SSO plugin", () => {
2121
.should("eq", "true");
2222

2323
// Confirm the session belongs to the OIDC-provisioned user
24-
cy.getCookie("jwtToken")
25-
.should("exist")
26-
.then((cookie) => {
27-
cy.request({
24+
cy.jwtToken().then((token) =>
25+
cy
26+
.request({
2827
url: "/admin/users/me",
29-
headers: {
30-
Authorization: `Bearer ${decodeURIComponent(cookie.value)}`,
31-
},
28+
headers: { Authorization: `Bearer ${token}` },
3229
})
33-
.its("body.data.email")
34-
.should("eq", "john.doe@example.org");
35-
});
30+
.its("body.data.email")
31+
.should("eq", "john.doe@example.org"),
32+
);
3633
});
3734
});
3835

@@ -43,21 +40,19 @@ describe("SSO plugin", () => {
4340
});
4441

4542
it("assigns the Editor role to jane.editor@example.org via the editors group", () => {
46-
cy.getCookie("jwtToken")
47-
.should("exist")
48-
.then((cookie) => {
49-
cy.request({
43+
cy.jwtToken().then((token) =>
44+
cy
45+
.request({
5046
url: "/admin/users/me",
51-
headers: {
52-
Authorization: `Bearer ${decodeURIComponent(cookie.value)}`,
53-
},
54-
}).then((res) => {
47+
headers: { Authorization: `Bearer ${token}` },
48+
})
49+
.then((res) => {
5550
expect(res.body.data.email).to.eq("jane.editor@example.org");
5651
expect(res.body.data.roles.map((r) => r.code)).to.include(
5752
"strapi-editor",
5853
);
59-
});
60-
});
54+
}),
55+
);
6156
});
6257
});
6358

‎cypress/support/commands.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,12 @@ Cypress.Commands.add("loginAs", (username, password) => {
4646

4747
// Convenience wrapper, logs in as the default super-admin test user.
4848
Cypress.Commands.add("login", () => cy.loginAs("john", "password"));
49+
50+
Cypress.Commands.add("jwtToken", () =>
51+
cy
52+
.window()
53+
.its("localStorage")
54+
.invoke("getItem", "jwtToken")
55+
.should("exist")
56+
.then(JSON.parse),
57+
);

‎playground/config/plugins.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default ({ env }: Core.Config.Shared.ConfigParams) => ({
1010
oidc: {
1111
enabled: true,
1212
config: {
13-
rememberMe: false,
13+
rememberMe: true,
1414
discovery: env.bool("OIDC_DISCOVERY", true),
1515
issuer: env("OIDC_ISSUER"),
1616
redirectUri: env("OIDC_REDIRECT_URI"),

‎server/src/config/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
export default {
88
default: {
99
discovery: true,
10-
rememberMe: false,
10+
rememberMe: true,
1111
scopes: "openid profile email groups",
1212
familyNameField: "family_name",
1313
givenNameField: "given_name",

0 commit comments

Comments
 (0)