Skip to content

Commit fa05327

Browse files
committed
feat: simplified API routes
Removed the /oidc prefix whose only purpose was to differentiate between providers we don't support anymore
1 parent 0ed33c8 commit fa05327

10 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = ({env}) => ({
5151
REMEMBER_ME: false,
5252

5353
// OpenID Connect
54-
OIDC_REDIRECT_URI: 'http://localhost:1337/strapi-plugin-sso/oidc/callback', // URI after successful login
54+
OIDC_REDIRECT_URI: 'http://localhost:1337/api/strapi-plugin-sso/callback', // URI after successful login
5555
OIDC_CLIENT_ID: '[Client ID from OpenID Provider]',
5656
OIDC_CLIENT_SECRET: '[Client Secret from OpenID Provider]',
5757

‎compose.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
- OIDC_AUTHORIZATION_ENDPOINT=https://${AUTH_DOMAIN}/api/oidc/authorization
77
- OIDC_TOKEN_ENDPOINT=https://${AUTH_DOMAIN}/api/oidc/token
88
- OIDC_USER_INFO_ENDPOINT=https://${AUTH_DOMAIN}/api/oidc/userinfo
9-
- OIDC_REDIRECT_URI=https://${CMS_DOMAIN}/api/strapi-plugin-sso/oidc/callback
9+
- OIDC_REDIRECT_URI=https://${CMS_DOMAIN}/api/strapi-plugin-sso/callback
1010
# TODO Should we load the client ID + secret from secrets instead?
1111
- OIDC_CLIENT_ID=onbU2exrz2I0RCJRrXsCQj49dgLFHLppCekGGdKmBaQ_7MWpAKcnylw6kO-7lUhsUtzmGJM8
1212
- OIDC_CLIENT_SECRET=yebsr4POK_hXenANvvo4DAHBGPIP_3a0

‎config/authelia/configuration.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ identity_providers:
1313
client_name: 'Strapi'
1414
client_secret: '{{ secret "/run/secrets/oidc_strapi_digest" }}'
1515
redirect_uris:
16-
- https://{{ mustEnv "CMS_DOMAIN" }}/api/strapi-plugin-sso/oidc/callback
16+
- https://{{ mustEnv "CMS_DOMAIN" }}/api/strapi-plugin-sso/callback
1717
scopes:
1818
- 'email'
1919
- 'groups'

‎cypress/e2e/login.cy.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe("SSO plugin", () => {
8484

8585
describe("error rendering", () => {
8686
it("shows the error page when callback is missing the auth code", () => {
87-
cy.visit(`${CMS}/api/${PLUGIN_ID}/oidc/callback`, {
87+
cy.visit(`${CMS}/api/${PLUGIN_ID}/callback`, {
8888
failOnStatusCode: false,
8989
});
9090
cy.contains("Authentication failed").should("be.visible");

‎cypress/support/commands.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Cypress.Commands.add("loginAs", (username, password) => {
1919
AUTHELIA_STACK.idp,
2020
{ args: { cms: AUTHELIA_STACK.cms, username, password } },
2121
({ cms, username, password }) => {
22-
cy.visit(`${cms}/api/strapi-plugin-sso/oidc`);
22+
cy.visit(`${cms}/api/strapi-plugin-sso/sign-in`);
2323
cy.get("#username-textfield").type(username);
2424
cy.get("#password-textfield").type(password);
2525
cy.get("#sign-in-button").click();

‎docs/en/oidc/setup.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Depending on your OIDC Provider the setup may vary.
1212

1313
| Key | required | default |
1414
| ---------------------------------------- | -------- | ----------------------------------------------------- |
15-
| OIDC_REDIRECT_URI | - | http://localhost:1337/strapi-plugin-sso/oidc/callback |
15+
| OIDC_REDIRECT_URI | - | http://localhost:1337/api/strapi-plugin-sso/callback |
1616
| OIDC_CLIENT_ID | ✅ | - |
1717
| OIDC_CLIENT_SECRET | ✅ | - |
1818
| OIDC_SCOPES | - | openid profile email |
@@ -32,7 +32,7 @@ module.exports = ({ env }) => ({
3232
config: {
3333
// OpenID Connect
3434
OIDC_REDIRECT_URI:
35-
"http://localhost:1337/strapi-plugin-sso/oidc/callback", // URI after successful login
35+
"http://localhost:1337/api/strapi-plugin-sso/callback", // URI after successful login
3636
OIDC_CLIENT_ID: "[Client ID from OpenID Provider]",
3737
OIDC_CLIENT_SECRET: "[Client Secret from OpenID Provider]",
3838

@@ -53,7 +53,7 @@ module.exports = ({ env }) => ({
5353
## 3. Sign in with your OIDC account
5454

5555
```
56-
http://localhost:1337/strapi-plugin-sso/oidc
56+
http://localhost:1337/api/strapi-plugin-sso
5757
```
5858

5959
If you can see the authentication screen of your OIDC Provider and then log in to the administration screen, you are done!

‎playground/.env‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ OIDC_TOKEN_ENDPOINT=https://auth.example.com/token
99
OIDC_USER_INFO_ENDPOINT=https://auth.example.com/userinfo
1010
OIDC_CLIENT_ID=test-client-id
1111
OIDC_CLIENT_SECRET=test-secret
12-
OIDC_REDIRECT_URI=http://localhost:1337/oidc/callback
12+
OIDC_REDIRECT_URI=http://localhost:1337/api/strapi-plugin-sso/callback
1313
OIDC_SCOPES=openid profile email

‎server/src/config/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
default: {
55
REMEMBER_ME: false,
66

7-
OIDC_REDIRECT_URI: "http://localhost:1337/strapi-plugin-sso/oidc/callback",
7+
OIDC_REDIRECT_URI: "http://localhost:1337/api/strapi-plugin-sso/callback",
88
OIDC_CLIENT_ID: "",
99
OIDC_CLIENT_SECRET: "",
1010
OIDC_SCOPES: "openid profile email",

‎server/src/routes/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ export default {
1616
},
1717
{
1818
method: "GET",
19-
path: "/oidc",
19+
path: "/sign-in",
2020
handler: "oidc.oidcSignIn",
2121
config: {
2222
auth: false,
2323
},
2424
},
2525
{
2626
method: "GET",
27-
path: "/oidc/callback",
27+
path: "/callback",
2828
handler: "oidc.oidcSignInCallback",
2929
config: {
3030
auth: false,

‎server/src/tests/oidc.test.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ afterAll(async () => {
2121
describe("OIDC sign in", () => {
2222
it("should redirect with 302 and set session values", async () => {
2323
const res = await request(strapi.server.httpServer).get(
24-
"/api/strapi-plugin-sso/oidc",
24+
"/api/strapi-plugin-sso/sign-in",
2525
);
2626

2727
expect(res.status).toBe(302);
@@ -45,7 +45,7 @@ describe("OIDC sign in", () => {
4545

4646
// Start the authentication flow (keeps the session cookie)
4747
const authStart = await agent
48-
.get("/api/strapi-plugin-sso/oidc")
48+
.get("/api/strapi-plugin-sso/sign-in")
4949
.expect(302);
5050
const redirectUrl = new URL(authStart.headers.location);
5151
const state = redirectUrl.searchParams.get("state");
@@ -66,7 +66,7 @@ describe("OIDC sign in", () => {
6666

6767
// Hit the callback
6868
const res = await agent.get(
69-
`/api/strapi-plugin-sso/oidc/callback?code=FAKE_CODE&state=${state}`,
69+
`/api/strapi-plugin-sso/callback?code=FAKE_CODE&state=${state}`,
7070
);
7171

7272
// Sanity checks

0 commit comments

Comments
 (0)