Skip to content

Commit

Permalink
[FEATURE] Renommer les customProperties en additionalRequiredProperti…
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Apr 19, 2024
2 parents 9d97f59 + d522236 commit 84e49bd
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 70 deletions.
2 changes: 1 addition & 1 deletion api/OIDC_PROVIDERS.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"openidClientExtraMetadata": {
"token_endpoint_auth_method": "client_secret_post"
},
"customProperties": {
"additionalRequiredProperties": {
"logoutUrl": "https://seeds.example.net/logout",
"afterLogoutUrl": "http://app.dev.pix.org"
}
Expand Down
4 changes: 2 additions & 2 deletions api/db/database-builder/factory/build-oidc-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function buildOidcProvider({
claimsToStore,
clientId,
clientSecret,
customProperties,
additionalRequiredProperties,
enabled,
enabledForPixAdmin,
extraAuthorizationUrlParameters,
Expand All @@ -31,7 +31,7 @@ export async function buildOidcProvider({
accessTokenLifespan,
claimsToStore,
clientId,
customProperties,
additionalRequiredProperties,
enabled,
enabledForPixAdmin,
encryptedClientSecret,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const TABLE_NAME = 'oidc-providers';
const COLUMN_NEW_NAME = 'additionalRequiredProperties';
const COLUMN_OLD_NAME = 'customProperties';

const up = async function (knex) {
await knex.schema.table(TABLE_NAME, function (table) {
table.jsonb(COLUMN_NEW_NAME);
table.dropColumn(COLUMN_OLD_NAME);
});
};

const down = async function (knex) {
await knex.schema.table(TABLE_NAME, function (table) {
table.jsonb(COLUMN_OLD_NAME);
table.dropColumn(COLUMN_NEW_NAME);
});
};

export { down, up };
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const OIDC_PROVIDERS_POLE_EMPLOI = {

openidClientExtraMetadata: { token_endpoint_auth_method: 'client_secret_post' },

customProperties: {
additionalRequiredProperties: {
logoutUrl: process.env.POLE_EMPLOI_OIDC_LOGOUT_URL,
afterLogoutUrl: process.env.POLE_EMPLOI_OIDC_AFTER_LOGOUT_URL,
},
Expand All @@ -51,7 +51,7 @@ const OIDC_PROVIDERS_FWB = {
redirectUri: process.env.FWB_REDIRECT_URI,
shouldCloseSession: true,

customProperties: {
additionalRequiredProperties: {
logoutUrl: process.env.FWB_OIDC_LOGOUT_URL,
},

Expand Down
6 changes: 3 additions & 3 deletions api/src/authentication/domain/usecases/add-oidc-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { DomainTransaction } from '../../../shared/domain/DomainTransaction.js';
/**
* @param {Object} params
* @param {string} params.accessTokenLifespan
* @param {Object} params.additionalRequiredProperties
* @param {string} params.claimsToStore
* @param {string} params.clientId
* @param {Object} params.customProperties
* @param {boolean} params.enabled
* @param {boolean} params.enabledForPixAdmin
* @param {string} params.encryptedClientSecret
Expand All @@ -29,9 +29,9 @@ import { DomainTransaction } from '../../../shared/domain/DomainTransaction.js';
*/
const addOidcProvider = async function ({
accessTokenLifespan,
additionalRequiredProperties,
claimsToStore,
clientId,
customProperties,
enabled,
enabledForPixAdmin,
encryptedClientSecret,
Expand All @@ -52,9 +52,9 @@ const addOidcProvider = async function ({
await oidcProviderRepository.create(
{
accessTokenLifespan,
additionalRequiredProperties,
claimsToStore,
clientId,
customProperties,
enabled,
enabledForPixAdmin,
encryptedClientSecret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,34 @@ import { DomainTransaction } from '../../../shared/domain/DomainTransaction.js';
const OIDC_PROVIDERS_TABLE_NAME = 'oidc-providers';

/**
* @param {Object} params
* @param {string} params.accessTokenLifespan
* @param {string} params.claimsToStore
* @param {string} params.clientId
* @param {Object} params.customProperties
* @param {boolean} params.enabled
* @param {boolean} params.enabledForPixAdmin
* @param {string} params.encryptedClientSecret
* @param {Object} params.extraAuthorizationUrlParameters
* @param {string} params.identityProvider
* @param {Object} params.openidClientExtraMetadata
* @param {string} params.openidConfigurationUrl
* @param {string} params.organizationName
* @param {string} params.postLogoutRedirectUri
* @param {string} params.redirectUri
* @param {string} params.scope
* @param {boolean} params.shouldCloseSession
* @param {string} params.slug
* @param {string} params.source
* @param {Object} oidcProviderProperties
* @param {string} oidcProviderProperties.accessTokenLifespan
* @param {Object} oidcProviderProperties.additionalRequiredProperties
* @param {string} oidcProviderProperties.claimsToStore
* @param {string} oidcProviderProperties.clientId
* @param {boolean} oidcProviderProperties.enabled
* @param {boolean} oidcProviderProperties.enabledForPixAdmin
* @param {string} oidcProviderProperties.encryptedClientSecret
* @param {Object} oidcProviderProperties.extraAuthorizationUrlParameters
* @param {string} oidcProviderProperties.identityProvider
* @param {Object} oidcProviderProperties.openidClientExtraMetadata
* @param {string} oidcProviderProperties.openidConfigurationUrl
* @param {string} oidcProviderProperties.organizationName
* @param {string} oidcProviderProperties.postLogoutRedirectUri
* @param {string} oidcProviderProperties.redirectUri
* @param {string} oidcProviderProperties.scope
* @param {boolean} oidcProviderProperties.shouldCloseSession
* @param {string} oidcProviderProperties.slug
* @param {string} oidcProviderProperties.source
* @param {Object} dependencies
* @param {DomainTransaction} dependencies.domainTransaction
* @returns {Promise<any[]>}
*/
const create = async function (
{
accessTokenLifespan,
claimsToStore,
clientId,
customProperties,
enabled,
enabledForPixAdmin,
encryptedClientSecret,
extraAuthorizationUrlParameters,
identityProvider,
openidClientExtraMetadata,
openidConfigurationUrl,
organizationName,
postLogoutRedirectUri,
redirectUri,
scope,
shouldCloseSession,
slug,
source,
},
oidcProviderProperties,
dependencies = { domainTransaction: DomainTransaction.emptyTransaction() },
) {
const knexConn = dependencies.domainTransaction.knexTransaction ?? knex;

const oidcProviderProperties = {
accessTokenLifespan,
claimsToStore,
clientId,
customProperties,
enabled,
enabledForPixAdmin,
encryptedClientSecret,
extraAuthorizationUrlParameters,
identityProvider,
openidClientExtraMetadata,
openidConfigurationUrl,
organizationName,
postLogoutRedirectUri,
redirectUri,
scope,
shouldCloseSession,
slug,
source,
};

return await knexConn(OIDC_PROVIDERS_TABLE_NAME).insert(oidcProviderProperties).returning('*');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe('Unit | Authentication | Domain | UseCases | add-oidc-provider', functi
};
const expectedOidcProviderProperties = {
accessTokenLifespan: '7d',
additionalRequiredProperties: undefined,
claimsToStore: undefined,
clientId: 'client',
customProperties: undefined,
enabled: undefined,
enabledForPixAdmin: undefined,
encryptedClientSecret: '#%@!!!!!!!!!!!!!',
Expand Down

0 comments on commit 84e49bd

Please sign in to comment.