From bd78f79d61cec6f219915951eec8771c421d7138 Mon Sep 17 00:00:00 2001
From: LEGO Technix <109212476+lego-technix@users.noreply.github.com>
Date: Tue, 8 Oct 2024 12:08:37 +0200
Subject: [PATCH 1/5] feat(api): add OIDC Providers slug to JSON API
---
.../serializers/jsonapi/oidc-identity-providers.serializer.js | 3 ++-
.../acceptance/application/oidc-provider.admin.route.test.js | 1 +
.../acceptance/application/oidc-provider.route.test.js | 1 +
.../unit/application/oidc-provider.admin.controller.test.js | 2 ++
.../unit/application/oidc-provider.controller.test.js | 1 +
.../jsonapi/oidc-identity-providers.serializer.test.js | 1 +
6 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/api/src/identity-access-management/infrastructure/serializers/jsonapi/oidc-identity-providers.serializer.js b/api/src/identity-access-management/infrastructure/serializers/jsonapi/oidc-identity-providers.serializer.js
index e451c0f425a..b680185b33a 100644
--- a/api/src/identity-access-management/infrastructure/serializers/jsonapi/oidc-identity-providers.serializer.js
+++ b/api/src/identity-access-management/infrastructure/serializers/jsonapi/oidc-identity-providers.serializer.js
@@ -9,11 +9,12 @@ const serialize = function (oidcIdentityProviders) {
id: oidcIdentityProvider.slug,
code: oidcIdentityProvider.code,
organizationName: oidcIdentityProvider.organizationName,
+ slug: oidcIdentityProvider.slug,
shouldCloseSession: oidcIdentityProvider.shouldCloseSession,
source: oidcIdentityProvider.source,
};
},
- attributes: ['code', 'organizationName', 'shouldCloseSession', 'source'],
+ attributes: ['code', 'organizationName', 'slug', 'shouldCloseSession', 'source'],
}).serialize(oidcIdentityProviders);
};
diff --git a/api/tests/identity-access-management/acceptance/application/oidc-provider.admin.route.test.js b/api/tests/identity-access-management/acceptance/application/oidc-provider.admin.route.test.js
index 804f653fc9c..2cf527380e4 100644
--- a/api/tests/identity-access-management/acceptance/application/oidc-provider.admin.route.test.js
+++ b/api/tests/identity-access-management/acceptance/application/oidc-provider.admin.route.test.js
@@ -77,6 +77,7 @@ describe('Acceptance | Identity Access Management | Route | Admin | oidc-provide
attributes: {
code: 'OIDC_EXAMPLE_NET',
'organization-name': 'OIDC Example',
+ slug: 'oidc-example-net',
'should-close-session': true,
source: 'oidcexamplenet',
},
diff --git a/api/tests/identity-access-management/acceptance/application/oidc-provider.route.test.js b/api/tests/identity-access-management/acceptance/application/oidc-provider.route.test.js
index 1ea2393c9c2..d3131f969f0 100644
--- a/api/tests/identity-access-management/acceptance/application/oidc-provider.route.test.js
+++ b/api/tests/identity-access-management/acceptance/application/oidc-provider.route.test.js
@@ -43,6 +43,7 @@ describe('Acceptance | Identity Access Management | Application | Route | oidc-p
attributes: {
code: 'OIDC_EXAMPLE_NET',
'organization-name': 'OIDC Example',
+ slug: 'oidc-example-net',
'should-close-session': true,
source: 'oidcexamplenet',
},
diff --git a/api/tests/identity-access-management/unit/application/oidc-provider.admin.controller.test.js b/api/tests/identity-access-management/unit/application/oidc-provider.admin.controller.test.js
index 9badef4e234..44514589e66 100644
--- a/api/tests/identity-access-management/unit/application/oidc-provider.admin.controller.test.js
+++ b/api/tests/identity-access-management/unit/application/oidc-provider.admin.controller.test.js
@@ -132,6 +132,7 @@ describe('Unit | Identity Access Management | Application | Controller | Admin |
attributes: {
code: 'LIMONADE_OIDC_PROVIDER',
'organization-name': 'Limonade OIDC Provider',
+ slug: 'limonade-oidc-provider',
'should-close-session': false,
source: 'limonade_oidc_provider',
},
@@ -142,6 +143,7 @@ describe('Unit | Identity Access Management | Application | Controller | Admin |
attributes: {
code: 'KOMBUCHA_OIDC_PROVIDER',
'organization-name': 'Kombucha OIDC Provider',
+ slug: 'kombucha-oidc-provider',
'should-close-session': true,
source: 'kombucha_oidc_provider',
},
diff --git a/api/tests/identity-access-management/unit/application/oidc-provider.controller.test.js b/api/tests/identity-access-management/unit/application/oidc-provider.controller.test.js
index 0a7322611f5..14a0ad22d00 100644
--- a/api/tests/identity-access-management/unit/application/oidc-provider.controller.test.js
+++ b/api/tests/identity-access-management/unit/application/oidc-provider.controller.test.js
@@ -262,6 +262,7 @@ describe('Unit | Identity Access Management | Application | Controller | oidc-pr
code: 'SOME_OIDC_PROVIDER',
source: 'some_oidc_provider',
'organization-name': 'Some OIDC Provider',
+ slug: 'some-oidc-provider',
'should-close-session': false,
},
});
diff --git a/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/oidc-identity-providers.serializer.test.js b/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/oidc-identity-providers.serializer.test.js
index 3a9666839ae..3f4fb1c1b4a 100644
--- a/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/oidc-identity-providers.serializer.test.js
+++ b/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/oidc-identity-providers.serializer.test.js
@@ -20,6 +20,7 @@ describe('Unit | Identity Access Management | Infrastructure | Serializer | JSON
attributes: {
code: 'OIDC_PARTNER',
'organization-name': 'Partenaire OIDC',
+ slug: 'oidc-partner',
'should-close-session': true,
source: 'oidc-external',
},
From bf2bf84d249da64b63f9d499c51745d8df8fcad5 Mon Sep 17 00:00:00 2001
From: LEGO Technix <109212476+lego-technix@users.noreply.github.com>
Date: Tue, 8 Oct 2024 12:09:35 +0200
Subject: [PATCH 2/5] feat(mon-pix): make available OIDC Providers slug from
JSON API
---
mon-pix/app/models/oidc-identity-provider.js | 1 +
mon-pix/mirage/routes/authentication/oidc/index.js | 1 +
.../components/authentication/login-or-register-oidc-test.js | 1 +
3 files changed, 3 insertions(+)
diff --git a/mon-pix/app/models/oidc-identity-provider.js b/mon-pix/app/models/oidc-identity-provider.js
index 92e52a85abb..c8101fc410a 100644
--- a/mon-pix/app/models/oidc-identity-provider.js
+++ b/mon-pix/app/models/oidc-identity-provider.js
@@ -3,6 +3,7 @@ import Model, { attr } from '@ember-data/model';
export default class OidcIdentityProvider extends Model {
@attr() code;
@attr() organizationName;
+ @attr() slug;
@attr() shouldCloseSession;
@attr() source;
}
diff --git a/mon-pix/mirage/routes/authentication/oidc/index.js b/mon-pix/mirage/routes/authentication/oidc/index.js
index d1e452ce0a5..21ec09a973a 100644
--- a/mon-pix/mirage/routes/authentication/oidc/index.js
+++ b/mon-pix/mirage/routes/authentication/oidc/index.js
@@ -41,6 +41,7 @@ export default function (config) {
attributes: {
code: 'OIDC_PARTNER',
'organization-name': 'Partenaire OIDC',
+ slug: 'partenaire-oidc',
'should-close-session': false,
source: 'oidc-externe',
},
diff --git a/mon-pix/tests/integration/components/authentication/login-or-register-oidc-test.js b/mon-pix/tests/integration/components/authentication/login-or-register-oidc-test.js
index 53ab4b8c710..150586316df 100644
--- a/mon-pix/tests/integration/components/authentication/login-or-register-oidc-test.js
+++ b/mon-pix/tests/integration/components/authentication/login-or-register-oidc-test.js
@@ -16,6 +16,7 @@ module('Integration | Component | authentication | login-or-register-oidc', func
id: 'oidc-partner',
code: 'OIDC_PARTNER',
organizationName: 'Partenaire OIDC',
+ slug: 'partenaire-oidc',
shouldCloseSession: false,
source: 'oidc-externe',
};
From d0725ad27069e07a0ec281bc920a40e5c4a7af9e Mon Sep 17 00:00:00 2001
From: LEGO Technix <109212476+lego-technix@users.noreply.github.com>
Date: Wed, 9 Oct 2024 18:50:19 +0200
Subject: [PATCH 3/5] feat(mon-pix): add featured identity provider and other
identity providers in oidcIdentityProviders service
---
.../app/services/oidc-identity-providers.js | 26 +++
.../services/oidc-identity-providers-test.js | 166 +++++++++++++++++-
2 files changed, 190 insertions(+), 2 deletions(-)
diff --git a/mon-pix/app/services/oidc-identity-providers.js b/mon-pix/app/services/oidc-identity-providers.js
index 558720e789a..3ac8ed4a938 100644
--- a/mon-pix/app/services/oidc-identity-providers.js
+++ b/mon-pix/app/services/oidc-identity-providers.js
@@ -1,8 +1,14 @@
import Service, { inject as service } from '@ember/service';
import isEmpty from 'lodash/isEmpty';
+// TODO: Manage this through the API
+const FR_FEATURED_IDENTITY_PROVIDER_CODE = 'POLE_EMPLOI';
+const ORG_FEATURED_IDENTITY_PROVIDER_CODE = 'FWB';
+const FEATURED_IDENTITY_PROVIDER_CODES = [FR_FEATURED_IDENTITY_PROVIDER_CODE, ORG_FEATURED_IDENTITY_PROVIDER_CODE];
+
export default class OidcIdentityProviders extends Service {
@service store;
+ @service currentDomain;
get list() {
return this.store.peekAll('oidc-identity-provider');
@@ -15,6 +21,26 @@ export default class OidcIdentityProviders extends Service {
.map((provider) => provider.organizationName);
}
+ // TODO: Manage this through the API
+ get featuredIdentityProvider() {
+ return this.list.find((identityProvider) => {
+ const featuredIdentityProviderCode = this.currentDomain.isFranceDomain
+ ? FR_FEATURED_IDENTITY_PROVIDER_CODE
+ : ORG_FEATURED_IDENTITY_PROVIDER_CODE;
+
+ return identityProvider.code === featuredIdentityProviderCode;
+ });
+ }
+
+ // TODO: Manage this through the API
+ get hasOtherIdentityProviders() {
+ if (!this.currentDomain.isFranceDomain) {
+ return false;
+ }
+
+ return this.list.some((identityProvider) => !FEATURED_IDENTITY_PROVIDER_CODES.includes(identityProvider.code));
+ }
+
isFwbActivated() {
const identityProviderSlug = 'fwb';
const oidcIdentityProviders = this.list.filter((provider) => provider.id === identityProviderSlug);
diff --git a/mon-pix/tests/unit/services/oidc-identity-providers-test.js b/mon-pix/tests/unit/services/oidc-identity-providers-test.js
index bb078f7c666..622199cd89b 100644
--- a/mon-pix/tests/unit/services/oidc-identity-providers-test.js
+++ b/mon-pix/tests/unit/services/oidc-identity-providers-test.js
@@ -1,7 +1,7 @@
import Object from '@ember/object';
import Service from '@ember/service';
import { setupTest } from 'ember-qunit';
-import { module, test } from 'qunit';
+import { assert, module, test } from 'qunit';
import sinon from 'sinon';
module('Unit | Service | oidc-identity-providers', function (hooks) {
@@ -14,6 +14,7 @@ module('Unit | Service | oidc-identity-providers', function (hooks) {
id: 'oidc-partner',
code: 'OIDC_PARTNER',
organizationName: 'Partenaire OIDC',
+ slug: 'partenaire-oidc',
shouldCloseSession: false,
source: 'oidc-externe',
};
@@ -29,7 +30,6 @@ module('Unit | Service | oidc-identity-providers', function (hooks) {
await oidcIdentityProvidersService.load();
// then
-
assert.strictEqual(oidcIdentityProvidersService['oidc-partner'].code, oidcPartner.code);
assert.strictEqual(oidcIdentityProvidersService['oidc-partner'].organizationName, oidcPartner.organizationName);
assert.strictEqual(
@@ -78,6 +78,168 @@ module('Unit | Service | oidc-identity-providers', function (hooks) {
});
});
+ module('featuredIdentityProvider', function () {
+ module('when there is some identity providers containing a featured one', function () {
+ test('returns the featured identity provider', async function () {
+ // given
+ const currentDomainService = this.owner.lookup('service:currentDomain');
+ sinon.stub(currentDomainService, 'isFranceDomain').value(false);
+
+ const oidcPartner = {
+ id: 'fwb',
+ code: 'FWB',
+ organizationName: 'FWB',
+ slug: 'fwb',
+ shouldCloseSession: false,
+ source: 'fwb',
+ };
+ const oidcPartnerObject = Object.create(oidcPartner);
+ const storeStub = Service.create({
+ peekAll: sinon.stub().returns([oidcPartnerObject]),
+ });
+ const oidcIdentityProvidersService = this.owner.lookup('service:oidcIdentityProviders');
+ oidcIdentityProvidersService.set('store', storeStub);
+
+ // when
+ const featuredIdentityProvider = await oidcIdentityProvidersService.featuredIdentityProvider;
+
+ // then
+ assert.strictEqual(featuredIdentityProvider.id, oidcPartner.id);
+ assert.strictEqual(featuredIdentityProvider.code, oidcPartner.code);
+ assert.strictEqual(featuredIdentityProvider.organizationName, oidcPartner.organizationName);
+ assert.strictEqual(featuredIdentityProvider.slug, oidcPartner.slug);
+ assert.strictEqual(featuredIdentityProvider.shouldCloseSession, oidcPartner.shouldCloseSession);
+ assert.strictEqual(featuredIdentityProvider.source, oidcPartner.source);
+ });
+ });
+
+ module('when there is some identity providers but no featured one', function () {
+ test('returns undefined', async function () {
+ // given
+ const oidcPartner = {
+ id: 'oidc-partner',
+ code: 'OIDC_PARTNER',
+ organizationName: 'Partenaire OIDC',
+ slug: 'partenaire-oidc',
+ shouldCloseSession: false,
+ source: 'oidc-externe',
+ };
+ const oidcPartnerObject = Object.create(oidcPartner);
+ const storeStub = Service.create({
+ peekAll: sinon.stub().returns([oidcPartnerObject]),
+ });
+ const oidcIdentityProvidersService = this.owner.lookup('service:oidcIdentityProviders');
+ oidcIdentityProvidersService.set('store', storeStub);
+
+ // when
+ const featuredIdentityProvider = await oidcIdentityProvidersService.featuredIdentityProvider;
+
+ // then
+ assert.strictEqual(featuredIdentityProvider, undefined);
+ });
+ });
+
+ module('when there isn’t any identity providers', function () {
+ test('returns undefined', async function () {
+ // given
+ const storeStub = Service.create({
+ peekAll: sinon.stub().returns([]),
+ });
+ const oidcIdentityProvidersService = this.owner.lookup('service:oidcIdentityProviders');
+ oidcIdentityProvidersService.set('store', storeStub);
+
+ // when
+ const featuredIdentityProvider = await oidcIdentityProvidersService.featuredIdentityProvider;
+
+ // then
+ assert.strictEqual(featuredIdentityProvider, undefined);
+ });
+ });
+ });
+
+ module('hasOtherIdentityProviders', function () {
+ module('when in France domain', function (hooks) {
+ hooks.beforeEach(function () {
+ const currentDomainService = this.owner.lookup('service:currentDomain');
+ sinon.stub(currentDomainService, 'isFranceDomain').value(true);
+ });
+
+ module('when there is some other identity providers', function () {
+ test('returns true', async function () {
+ // given
+ const oidcPartner = {
+ id: 'oidc-partner',
+ code: 'OIDC_PARTNER',
+ organizationName: 'Partenaire OIDC',
+ slug: 'partenaire-oidc',
+ shouldCloseSession: false,
+ source: 'oidc-externe',
+ };
+ const oidcPartnerObject = Object.create(oidcPartner);
+ const storeStub = Service.create({
+ peekAll: sinon.stub().returns([oidcPartnerObject]),
+ });
+ const oidcIdentityProvidersService = this.owner.lookup('service:oidcIdentityProviders');
+ oidcIdentityProvidersService.set('store', storeStub);
+
+ // when
+ const hasOtherIdentityProviders = await oidcIdentityProvidersService.hasOtherIdentityProviders;
+
+ // then
+ assert.strictEqual(hasOtherIdentityProviders, true);
+ });
+ });
+
+ module('when there isn’t any other identity providers', function () {
+ test('returns false', async function () {
+ // given
+ const storeStub = Service.create({
+ peekAll: sinon.stub().returns([]),
+ });
+ const oidcIdentityProvidersService = this.owner.lookup('service:oidcIdentityProviders');
+ oidcIdentityProvidersService.set('store', storeStub);
+
+ // when
+ const hasOtherIdentityProviders = await oidcIdentityProvidersService.hasOtherIdentityProviders;
+
+ // then
+ assert.strictEqual(hasOtherIdentityProviders, false);
+ });
+ });
+ });
+
+ module('when not in France domain', function (hooks) {
+ hooks.beforeEach(function () {
+ const currentDomainService = this.owner.lookup('service:currentDomain');
+ sinon.stub(currentDomainService, 'isFranceDomain').value(false);
+ });
+
+ test('returns false', async function () {
+ // given
+ const oidcPartner = {
+ id: 'oidc-partner',
+ code: 'OIDC_PARTNER',
+ organizationName: 'Partenaire OIDC',
+ slug: 'partenaire-oidc',
+ shouldCloseSession: false,
+ source: 'oidc-externe',
+ };
+ const oidcPartnerObject = Object.create(oidcPartner);
+ const storeStub = Service.create({
+ peekAll: sinon.stub().returns([oidcPartnerObject]),
+ });
+ const oidcIdentityProvidersService = this.owner.lookup('service:oidcIdentityProviders');
+ oidcIdentityProvidersService.set('store', storeStub);
+
+ // when
+ const hasOtherIdentityProviders = await oidcIdentityProvidersService.hasOtherIdentityProviders;
+
+ // then
+ assert.strictEqual(hasOtherIdentityProviders, false);
+ });
+ });
+ });
+
module('isFwbActivated', function () {
test('returns true when identity provider is activated', function (assert) {
// given
From c891277339d705c935db1f5739f0210463599745 Mon Sep 17 00:00:00 2001
From: LEGO Technix <109212476+lego-technix@users.noreply.github.com>
Date: Wed, 9 Oct 2024 18:52:34 +0200
Subject: [PATCH 4/5] feat(mon-pix): add new component
authentication/other-authentication-providers
---
.../other-authentication-providers.gjs | 57 +++++++
.../other-authentication-providers.scss | 36 +++++
mon-pix/app/styles/app.scss | 1 +
.../images/logo/pole-emploi-connect-logo.svg | 12 ++
.../other-authentication-providers-test.gjs | 149 ++++++++++++++++++
mon-pix/translations/en.json | 6 +
mon-pix/translations/es.json | 6 +
mon-pix/translations/fr.json | 6 +
mon-pix/translations/nl.json | 6 +
9 files changed, 279 insertions(+)
create mode 100644 mon-pix/app/components/authentication/other-authentication-providers.gjs
create mode 100644 mon-pix/app/components/authentication/other-authentication-providers.scss
create mode 100644 mon-pix/public/images/logo/pole-emploi-connect-logo.svg
create mode 100644 mon-pix/tests/integration/components/authentication/other-authentication-providers-test.gjs
diff --git a/mon-pix/app/components/authentication/other-authentication-providers.gjs b/mon-pix/app/components/authentication/other-authentication-providers.gjs
new file mode 100644
index 00000000000..0083f875a71
--- /dev/null
+++ b/mon-pix/app/components/authentication/other-authentication-providers.gjs
@@ -0,0 +1,57 @@
+import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link';
+import { service } from '@ember/service';
+import Component from '@glimmer/component';
+import { t } from 'ember-intl';
+
+export default class OtherAuthenticationProviders extends Component {
+ @service oidcIdentityProviders;
+ @service router;
+
+
+
+ {{#if @isForSignup}}
+ {{t "components.authentication.other-authentication-providers.signup-heading"}}
+ {{else}}
+ {{t "components.authentication.other-authentication-providers.login-heading"}}
+ {{/if}}
+
+
+ {{#if this.oidcIdentityProviders.featuredIdentityProvider}}
+