Skip to content

Commit

Permalink
feat: scopes Form is broken -- missing most important field (id) #305
Browse files Browse the repository at this point in the history
  • Loading branch information
duttarnab committed Jul 19, 2022
1 parent 7c776d9 commit c1c7e8b
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 96 deletions.
12 changes: 6 additions & 6 deletions admin-ui/app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"consent_gathering_scripts": "Consent Gathering Scripts",
"custom_properties": "Custom Properties (key/values)",
"data_type": "Data Type",
"default_acr": "Default Authentication Method (ACR)",
"default_acr": "Default Authentication Method(Acr)",
"default_bucket": "Default Bucket",
"default_cleanup_batch_size": "Default Cleanup Batch Size",
"default_put_expiration": "Default Put Expiration",
Expand All @@ -76,7 +76,7 @@
"host_name": "Host Name",
"hide_on_discovery": "Hide On Discovery?",
"http_logging_enabled": "Enable HTTP Logging",
"id": "Id",
"id": "id",
"id_token_encrypted_response_alg": "JWE alg Algorithm for encrypting the ID Token",
"id_token_encrypted_response_enc": "JWE enc Algorithm for encrypting the ID Token",
"id_token_signed_response_alg": "JWS alg Algorithm for signing the ID Token",
Expand All @@ -85,7 +85,7 @@
"in_memory_configuration": "inMemoryConfiguration",
"internal": "Internal",
"introspection_scripts": "Introspection Scripts",
"inum": "Inum",
"inum": "inum",
"is_active": "Is Active",
"is_expirable_client": "Is Expirable Client?",
"is_trusted_client": "Skip Authorization Flow?",
Expand Down Expand Up @@ -139,7 +139,7 @@
"rpt_scripts": "Rpt Scripts",
"saml1_uri": "Saml1 URI",
"saml2_uri": "Saml2 URI",
"scope_type": "Scope Type",
"scope_type": "Scope type",
"scopes:": "Scopes",
"scripts": "Scripts",
"script_type": "Script Type",
Expand All @@ -148,7 +148,7 @@
"sender_name": "Sender Name",
"sentinel_master_group_name": "sentinelMasterGroupName",
"servers": "Server Details",
"show_in_onfiguration_endpoint": "Show In Configuration Endpoint",
"show_in_configuration_endpoint": "Show in configuration endpoint",
"smtp_server_port": "SMTP server port",
"smtp_test_status": "Smtp Test Status",
"smtp_user_name": "SMTP User Name",
Expand Down Expand Up @@ -741,7 +741,7 @@
"showInConfigurationEndpoint": "Show this scope In Configuration Endpoint",
"dynamicScopeScripts": "Dynamic Scope Scripts associated with the scope.",
"umaType": "Specifies if the scope is of type UMA.",
"id": "Based Url encode unique id for the scope",
"id": "The unique id for the scope",
"attributes": "Custom attributes for the scope"
},
"attribute": {
Expand Down
8 changes: 4 additions & 4 deletions admin-ui/app/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"consent_gathering_scripts": "Scripts de collecte de consentement",
"custom_properties": "Propriétés personnalisées (clé/valeurs)",
"data_type": "Type de données",
"default_acr": "Méthode d'authentification par défaut (ACR)",
"default_acr": "Méthode d'authentification par défaut (Acr)",
"default_bucket": "Seau par défaut",
"default_cleanup_batch_size": "Taille du lot de nettoyage par défaut",
"default_put_expiration": "Expiration de vente par défaut",
Expand All @@ -112,7 +112,7 @@
"host_name": "Nom d'hôte",
"hide_on_discovery": "Masquer à la découverte ?",
"http_logging_enabled": "Activer la journalisation HTTP",
"id": "Id",
"id": "id",
"id_token_encrypted_response_alg": "JWE alg Algorithm pour chiffrer le jeton d'identification",
"id_token_encrypted_response_enc": "JWE enc Algorithme pour chiffrer le jeton d'identification",
"id_token_signed_response_alg": "JWS alg Algorithm pour la signature du jeton d'identification",
Expand All @@ -121,7 +121,7 @@
"in_memory_configuration": "dansConfigurationMémoire",
"internal": "Interne",
"introspection_scripts": "Scripts d'introspection",
"inum": "Inum",
"inum": "inum",
"is_active": "C'est actif",
"is_expirable_client": "est un client expirable ?",
"is_trusted_client": "Est un client de confiance",
Expand Down Expand Up @@ -184,7 +184,7 @@
"sender_name": "Nom de l'expéditeur",
"sentinel_master_group_name": "sentinelleMasterGroupName",
"servers": "Les serveurs",
"show_in_onfiguration_endpoint": "Afficher dans le point de terminaison de configuration",
"show_in_configuration_endpoint": "Afficher dans le point de terminaison de configuration",
"smtp_server_port": "Port du serveur SMTP",
"smtp_test_status": "État du test SMTP",
"smtp_user_name": "Nom d'utilisateur SMTP",
Expand Down
8 changes: 4 additions & 4 deletions admin-ui/app/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"consent_gathering_scripts": "Scripts de coleta de consentimento",
"custom_properties": "Propriedades personalizadas (chave / valores)",
"data_type": "Tipo de dados",
"default_acr": "Método de autenticação padrão (ACR)",
"default_acr": "Método de autenticação padrão (Acr)",
"default_bucket": "Bucket padrão",
"default_cleanup_batch_size": "Tamanho de lote de limpeza padrão",
"default_put_expiration": "Expiração de venda padrão",
Expand All @@ -111,7 +111,7 @@
"host_name": "Nome de anfitrião",
"hide_on_discovery": "Ocultar na descoberta?",
"http_logging_enabled": "Habilitar registro de HTTP",
"id": "Id",
"id": "id",
"id_token_encrypted_response_alg": "Algoritmo JWE alg para criptografar o token de ID",
"id_token_encrypted_response_enc": "Algoritmo JWE enc para criptografar o token de ID",
"id_token_signed_response_alg": "Algoritmo de algoritmo JWS para assinar o token de ID",
Expand All @@ -120,7 +120,7 @@
"in_memory_configuration": "inMemoryConfiguration",
"internal": "interno",
"introspection_scripts": "Scripts de introspecção",
"inum": "Inum",
"inum": "inum",
"is_active": "Está ativo",
"is_expirable_client": "É cliente expirável?",
"is_trusted_client": "É um cliente confiávelÉ um cliente confiável",
Expand Down Expand Up @@ -183,7 +183,7 @@
"sender_name": "Nome do remetente",
"sentinel_master_group_name": "sentinelMasterGroupName",
"servers": "Servidores",
"show_in_onfiguration_endpoint": "Mostrar ponto final na configuração",
"show_in_configuration_endpoint": "Mostrar ponto final na configuração",
"smtp_server_port": "Porta do servidor SMTP",
"smtp_test_status": "Status do teste Smtp",
"smtp_user_name": "Nome de usuário SMTP",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function ScopeAddPage({ scripts, dispatch, attributes, loading, saveOperationFla
attributes: {
spontaneousClientId: null,
spontaneousClientScopes: [],
showInConfigurationEndpoint: 'false',
showInConfigurationEndpoint: false,
},
}

Expand Down
175 changes: 94 additions & 81 deletions admin-ui/plugins/auth-server/components/Scopes/ScopeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
const [showDynamicPanel, handleDynamicPanel] = useState(
enableDynamic(scope.scopeType),
)
const [showSpontaneousPanel, handleShowSpontaneousPanel] = useState(
enableSpontaneous(scope.scopeType),
)

function enableClaims(type) {
return type === 'openid'
}
function enableDynamic(type) {
return type === 'dynamic'
}
function enableSpontaneous(type) {
return type === 'spontaneous'
}
function handleScopeTypeChanged(type) {
if (type && type === 'openid') {
handleClaimsPanel(true)
Expand All @@ -59,8 +66,15 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
} else {
handleDynamicPanel(false)
}
if (type && type === 'spontaneous') {
handleShowSpontaneousPanel(true)
} else {
handleShowSpontaneousPanel(false)
}
scope.dynamicScopeScripts = ''
scope.claims = ''
scope.attributes.spontaneousClientId = ''
scope.attributes.spontaneousClientScopes = []
}

function getMapping(partial, total) {
Expand Down Expand Up @@ -108,10 +122,9 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
})}
onSubmit={(values) => {
const result = Object.assign(scope, values)
//result[‘scopeType’] = document.getElementById(‘scopeType’).value
result['id'] = result.displayName
result['id'] = result.id
result['attributes'].showInConfigurationEndpoint =
scope.attributes.showInConfigurationEndpoint
scope.attributes.showInConfigurationEndpoint
result['attributes'].spontaneousClientId =
scope.attributes.spontaneousClientId
result['attributes'].spontaneousClientScopes =
Expand All @@ -122,6 +135,30 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
>
{(formik) => (
<Form onSubmit={formik.handleSubmit}>

<GluuTooltip doc_category={SCOPE} doc_entry="id">
<FormGroup row>
<GluuLabel label="fields.id" size={4} required />
<Col sm={8}>
<Input
placeholder={t('placeholders.id')}
id="id"
valid={
!formik.errors.id &&
!formik.touched.id &&
init
}
name="id"
defaultValue={scope.id}
onKeyUp={activate}
onChange={formik.handleChange}
/>
</Col>
<ErrorMessage name="id">
{(msg) => <div style={{ color: 'red' }}>{msg}</div>}
</ErrorMessage>
</FormGroup>
</GluuTooltip>
{scope.inum && (
<GluuInumInput
label="fields.inum"
Expand Down Expand Up @@ -170,12 +207,19 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
</Col>
</FormGroup>
</GluuTooltip>
<GluuToogleRow
{ <GluuToogleRow
label="fields.default_scope"
name="defaultScope"
formik={formik}
value={scope.defaultScope}
doc_category={SCOPE}
/> }
<GluuToogleRow
label="fields.show_in_configuration_endpoint"
name="attributes.showInConfigurationEndpoint"
formik={formik}
value={scope.attributes.showInConfigurationEndpoint}
doc_category={SCOPE}
/>
<GluuTooltip doc_category={SCOPE} doc_entry="scopeType">
<FormGroup row>
Expand Down Expand Up @@ -208,7 +252,7 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
{showDynamicPanel && (
<Accordion className="mb-2 b-primary" initialOpen>
<Accordion.Header className="text-primary">
{t('fields.dynamic_scope_scripts').toUpperCase()}
{t('fields.claims').toUpperCase()}
</Accordion.Header>
<Accordion.Body>
<FormGroup row> </FormGroup>
Expand Down Expand Up @@ -244,89 +288,58 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
</Accordion.Body>
</Accordion>
)}
<Accordion className="mb-2 b-primary" initialOpen>
<Accordion.Header className="text-primary">
{t('fields.ox_attributes').toUpperCase()}
</Accordion.Header>
<Accordion.Body>
<FormGroup row> </FormGroup>
<GluuTooltip
doc_category={SCOPE}
doc_entry="spontaneousClientId"
>
<FormGroup row>
<GluuLabel label="fields.spontaneous_client_id" size={4} />
<Col sm={8}>
<Input
placeholder={t('placeholders.spontaneous_client_id')}
id="spontaneousClientId"
name="spontaneousClientId"
defaultValue={scope.attributes.spontaneousClientId}
onChange={(e) => {
scope.attributes.spontaneousClientId = e.target.value
formik.setFieldValue(
'spontaneousClientId',
e.target.value,
)
}}
/>
</Col>
</FormGroup>
</GluuTooltip>
<GluuTooltip
doc_category={SCOPE}
doc_entry="showInConfigurationEndpoint"
>
<FormGroup row>
<GluuLabel
label="fields.show_in_onfiguration_endpoint"
size={4}
/>
<Col sm={8}>
<InputGroup>
<CustomInput
type="select"
id="showInConfigurationEndpoint"
name="showInConfigurationEndpoint"
defaultValue={
scope.attributes.showInConfigurationEndpoint
}
{showSpontaneousPanel && (
<Accordion className="mb-2 b-primary" initialOpen>
<Accordion.Header className="text-primary">
{t('fields.spontaneous_scopes').toUpperCase()}
</Accordion.Header>
<Accordion.Body>
<FormGroup row> </FormGroup>
<GluuTooltip
doc_category={SCOPE}
doc_entry="spontaneousClientId"
>
<FormGroup row>
<GluuLabel label="fields.spontaneous_client_id" size={4} />
<Col sm={8}>
<Input
placeholder={t('placeholders.spontaneous_client_id')}
id="attributes.spontaneousClientId"
name="attributes.spontaneousClientId"
defaultValue={scope.attributes.spontaneousClientId}
onChange={(e) => {
scope.attributes.showInConfigurationEndpoint =
e.target.value
scope.attributes.spontaneousClientId = e.target.value
formik.setFieldValue(
'showInConfigurationEndpoint',
'attributes.spontaneousClientId',
e.target.value,
)
}}
>
<option value="true">{t('options.true')}</option>
<option value="false">{t('options.false')}</option>
</CustomInput>
</InputGroup>
</Col>
</FormGroup>
</GluuTooltip>
<GluuTypeAheadForDn
name="spontaneousClientScopes"
label="fields.spontaneous_client_scopes"
formik={formik}
value={getMapping(
spontaneousClientScopes,
scope?.attributes?.spontaneousClientScopes?.map((item) => ({
/>
</Col>
</FormGroup>
</GluuTooltip>

<GluuTypeAheadForDn
name="attributes.spontaneousClientScopes"
label="fields.spontaneous_client_scopes"
formik={formik}
value={getMapping(
spontaneousClientScopes,
scope?.attributes?.spontaneousClientScopes?.map((item) => ({
dn: item || '',
name: item || '',
})),
)}
allowNew={true}
options={spontaneousClientScopes?.map((item) => ({
dn: item || '',
name: item || '',
})),
)}
allowNew={true}
options={spontaneousClientScopes?.map((item) => ({
dn: item || '',
name: item || '',
}))}
doc_category={SCOPE}
/>
</Accordion.Body>
</Accordion>
}))}
doc_category={SCOPE}
/>
</Accordion.Body>
</Accordion>
)}
<FormGroup row></FormGroup>
<GluuCommitFooter saveHandler={toggle} />
<GluuCommitDialog
Expand Down

0 comments on commit c1c7e8b

Please sign in to comment.