strategy attributes

This commit is contained in:
Valentin Bouzin
2025-12-19 17:28:26 +01:00
parent 569ae62691
commit a53f763d59
3 changed files with 25 additions and 23 deletions

View File

@@ -19,8 +19,6 @@ import { ABSTRACT_INTERNAL_OBJECT } from '../../schema/general';
import type { StrategyType } from '../../config/providers-configuration';
const isSingleSignOnEnabled = isFeatureEnabled('SINGLE_SIGN_ON_ENABLED');
export const getConfigurationKeyList = (strategy: StrategyType) => CONFIGURATION_MANDATORY_KEY_LIST[strategy];
// Create a function to check all mandatory fields before creation
export const getStrategyAttributes = (strategy: StrategyType) => {
@@ -30,11 +28,29 @@ export const getStrategyAttributes = (strategy: StrategyType) => {
// If this solution is used, maybe we will not have to keep the value on resolver : mandatoryFields
// something like :
/*
const STRATEGY_ATTRIBUTES = {
export enum AttributeType {
STRING = 'string',
NUMBER = 'number',
BOOLEAN = 'boolean',
STRATEGY_LDAP = 'LdapStrategy',
}
type StrategyAttributesType = {
["string"]: {
key: string;
displayName: string;
type: AttributeType;
mandatory: boolean;
tooltip?: string;
}
}
const STRATEGY_ATTRIBUTES: StrategyAttributesType = {
[StrategyType.STRATEGY_SAML]: [
{ key: 'name', type: 'string', mandatory: true, order: 1 },
{ key: 'description', type: 'string', mandatory: false, order: 2 },
{ key: 'issuer', type: 'string', mandatory: true,; order: 3 },
{ key: 'name', displayName: 'name', type: AttributeType.STRING , mandatory: true, order: 1 },
{ key: 'description', displayName: 'description', type: AttributeType.BOOLEAN, mandatory: false, order: 2 },
{ key: 'issuer', displayName: 'issuer', type: AttributeType.STRING, mandatory: true, order: 3 },
{ key: 'cert', displayName: 'certificat', type: AttributeType.STRING, mandatory: true, order: 4, tooltip: 'Here is a tooltip' },
{....}
],
[StrategyType.STRATEGY_LDAP]: [{....}],

View File

@@ -1,15 +1,12 @@
import type { Resolvers } from '../../generated/graphql';
import { findSingleSignOnById, findSingleSignOnPaginated, addSingleSignOn, fieldPatchSingleSignOn, deleteSingleSignOn, getConfigurationKeyList, getStrategyAttributes } from './SingleSignOn-domain';
import { findSingleSignOnById, findSingleSignOnPaginated, addSingleSignOn, fieldPatchSingleSignOn, deleteSingleSignOn } from './SingleSignOn-domain';
const singleSignOnResolver: Resolvers = {
Query: {
singleSignOn: (_, { id }, context) => findSingleSignOnById(context, context.user, id),
singleSignOns: (_, args, context) => findSingleSignOnPaginated(context, context.user, args),
// singleSignOnAttributes: (_, { strategy }, context) => getStrategyAttributes(strategy),
},
SingleSignOn: {
// used to have all mandatory fields for strategy
mandatoryFields: (singleSignOn) => getConfigurationKeyList(singleSignOn.strategy),
// to be fetched when strategy is selected in front
// strategyAttributes: (_, { strategy }, context) => getStrategyAttributes(strategy),
},
Mutation: {
singleSignOnAdd: (_, { input }, context) => {

View File

@@ -22,17 +22,6 @@ interface GroupsManagement {
read_userinfo: boolean;
}
// # Examples : declare here specific keys for each type of SSO
// SAML keys from notion :
// Page : SSO in GUI - Overall task => resources => "List of fields to be included in each Auth Type"
export const SAML_CONFIGURATION_MANDATORY_KEY_LIST = ['name', 'label', 'issuer', 'cert', 'saml_callback_url', 'entry_point'];
// export const LDAP_CONFIGURATION_KEY_LIST = [];
export const CONFIGURATION_MANDATORY_KEY_LIST = {
[StrategyType.STRATEGY_SAML]: SAML_CONFIGURATION_MANDATORY_KEY_LIST,
// [StrategyType.STRATEGY_LDAP]: LDAP_CONFIGURATION_KEY_LIST,
// [...]
}
export interface BasicStoreEntitySingleSignOn extends BasicStoreEntity {
name: string;
description: string;