Skip to content

Commit

Permalink
secure FieldsList + handle token cache in session
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-albert committed Oct 21, 2024
1 parent ec71459 commit a7b4cec
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 49 deletions.
18 changes: 10 additions & 8 deletions _c8oProject/mobilePages/BrowseTables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ title: First page
directiveSource:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.forms_ApplicationsList","marker":""}],"path":"","prefix":"","suffix":"?.array","custom":"","useCustom":false}}
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.formscommon_ApplicationsList","marker":""}],"path":"","prefix":"","suffix":"?.array","custom":"","useCustom":false}}
↓Accordion [ngx.components.UIDynamicElement-1667634603474]:
beanData: '{"ionBean":"Accordion","Value":"source:{\"filter\":\"Iteration\",\"project\":\"lib_BaseRow\",\"input\":\"\",\"model\":{\"data\":[{\"priority\":1667635335398}],\"path\":\"?.id\",\"prefix\":\"\",\"suffix\":\"\",\"custom\":\"\",\"useCustom\":false}}"}'
tagName: ion-accordion
Expand Down Expand Up @@ -1428,7 +1428,7 @@ title: First page
directiveSource:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.FieldsList","marker":""}],"path":"?.array","prefix":"","suffix":"","custom":"","useCustom":false}}
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.formscommon_FieldsList","marker":""}],"path":"?.array","prefix":"","suffix":"","custom":"","useCustom":false}}
↓SelectOption [ngx.components.UIDynamicElement-1680695974741]:
beanData: '{"ionBean":"SelectOption","Value":"script:column.name"}'
tagName: ion-select-option
Expand Down Expand Up @@ -1693,7 +1693,7 @@ title: First page
directiveSource:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.FieldsList","marker":""}],"path":"?.array","prefix":"","suffix":"","custom":"","useCustom":false}}
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.formscommon_FieldsList","marker":""}],"path":"?.array","prefix":"","suffix":"","custom":"","useCustom":false}}
↓SelectOption [ngx.components.UIDynamicElement-1680696113217]:
beanData: '{"ionBean":"SelectOption","Value":"script:JSON.stringify(column)"}'
tagName: ion-select-option
Expand Down Expand Up @@ -1877,7 +1877,7 @@ title: First page
directiveSource:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.FieldsList","marker":""}],"path":"?.array","prefix":"","suffix":"","custom":"","useCustom":false}}
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.formscommon_FieldsList","marker":""}],"path":"?.array","prefix":"","suffix":"","custom":"","useCustom":false}}
↓tag [ngx.components.UIControlDirective-1680704190924]:
directiveName: If
directiveSource:
Expand Down Expand Up @@ -2974,7 +2974,7 @@ title: First page
↓PageEvent [ngx.components.UIPageEvent-1667634909158]:
viewEvent: onWillLoad
↓CallSequence [ngx.components.UIDynamicAction-1667634917133]:
beanData: '{"ionBean":"CallSequenceAction","requestable":"plain:lib_BaseRow.forms_ApplicationsList"}'
beanData: '{"ionBean":"CallSequenceAction","requestable":"plain:lib_BaseRow.formscommon_ApplicationsList"}'
↓ReadConfiguration [ngx.components.UICustomAsyncAction-1729087057370]:
actionValue:
- xmlizable:
Expand All @@ -2986,7 +2986,9 @@ title: First page
let result: any = await page.callParentFunction("getConfigurationData");
page.c8o.log.debug(''[MB] getConfigurationData: '' + result);
return JSON.parse(result);
let output = JSON.parse(result);
output.forms_config = result;
return output;
} catch (e) {
}
Expand Down Expand Up @@ -3038,11 +3040,11 @@ title: First page
↓InvokeSharedAction [ngx.components.UIDynamicInvoke-1729087093168]:
beanData: '{"ionBean":"InvokeAction"}'
stack: lib_BaseRow.Application.NgxApp.DisplayTableColumns
tableId [ngx.components.UIControlVariable-1729087093171]:
forms_config [ngx.components.UIControlVariable-1729516307947]:
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Action","project":"lib_BaseRow","input":"","model":{"data":[{"priority":1729087057370,"rootEvent":false,"pageLocals":false},{"priority":1667634909158,"rootEvent":true,"pageLocals":false},{"priority":1667634917133,"rootEvent":false,"pageLocals":false}],"path":"?.out","prefix":"","suffix":"?.table_id_int","custom":"","useCustom":false}}
- MobileSmartSourceType: source:{"filter":"Action","project":"lib_BaseRow","input":"","model":{"data":[{"priority":1729087057370,"rootEvent":false,"pageLocals":false},{"priority":1667634909158,"rootEvent":true,"pageLocals":false},{"priority":1667634917133,"rootEvent":false,"pageLocals":false}],"path":"?.out","prefix":"","suffix":"?.forms_config","custom":"","useCustom":false}}
↓SetLocal [ngx.components.UIDynamicAction-1729087093174]:
beanData: |
'{
Expand Down
18 changes: 9 additions & 9 deletions _c8oProject/mobileSharedActions/DisplayTableColumns.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
↓CallSequence [ngx.components.UIDynamicAction-1727686162011]:
beanData: '{"ionBean":"CallSequenceAction","requestable":"plain:lib_BaseRow.FieldsList"}'
↓table_id [ngx.components.UIControlVariable-1727686162014]:
comment: table_id
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: script:params.tableId
beanData: '{"ionBean":"CallSequenceAction","requestable":"plain:lib_BaseRow.formscommon_FieldsList"}'
↓SelectAllColumnsAfterInit [ngx.components.UICustomAction-1727686162038]:
actionValue:
- xmlizable:
Expand Down Expand Up @@ -127,5 +121,11 @@
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.FieldsList","marker":""}],"path":"?.array","prefix":"","suffix":"","custom":"","useCustom":false}}
↓tableId [ngx.components.UIStackVariable-1727686198206]:
- MobileSmartSourceType: source:{"filter":"Sequence","project":"lib_BaseRow","input":"","model":{"data":[{"sequence":"lib_BaseRow.formscommon_FieldsList","marker":""}],"path":"?.array","prefix":"","suffix":"","custom":"","useCustom":false}}
↓forms_config [ngx.components.UIControlVariable-1729516246665]:
comment: configure=lib_BaseRow/DisplayObjects/mobile/BrowseTables
varValue:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType
- MobileSmartSourceType: script:params.forms_config
↓forms_config [ngx.components.UIStackVariable-1727686198206]:
2 changes: 1 addition & 1 deletion _c8oProject/sequences/FieldsList.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessibility: Hidden
accessibility: Private
comment: Lists all the fields in a baserow table
responseExpiryDate: absolute,60
↓Call_Sequence [steps.SequenceStep-1667802514338]:
Expand Down
43 changes: 29 additions & 14 deletions _c8oProject/sequences/TokenGetOrRefresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,39 @@ comment: Gets a token or refresh it if the token is expired the Token will be pl
'email += "";
password += "";
var token_owner = context.httpSession.getAttribute("token_owner");
if (token_owner == null) {
token_owner = "owner";
} else {
token_owner += "";
}
if (password || email) {
owner = "" + org.apache.commons.codec.digest.DigestUtils.md5Hex("owner:" + email + ":" + password);
if (token_owner != owner) {
context.httpSession.setAttribute("token_for_" + token_owner, context.httpSession.getAttribute("token"));
context.httpSession.setAttribute("token_timestamp_for_" + token_owner, context.httpSession.getAttribute("token_timestamp"));
var exToken = context.httpSession.getAttribute("token_for_" + owner);
if (exToken != null) {
var exTokenTS = context.httpSession.getAttribute("token_timestamp_for_" + owner);
context.httpSession.setAttribute("token_owner", owner);
context.httpSession.setAttribute("token", exToken);
context.httpSession.setAttribute("token_timestamp", exTokenTS);
token_owner = owner;
log.info("swap token for this account: " + email);
} else {
log.info("no previous token for this account: " + email);
}
} else {
log.info("reuse token for this account: " + email);
}
} else {
owner = "owner";
}'
↓GetTokenOwnerFromSession [steps.SessionGetStep-1729093387316]:
key: token_owner
output: false
↓IfExistSameOwner [steps.IfExistStep-1729093461696]:
condition: IfExistSameOwner
sourceDefinition:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.XMLVector
- com.twinsoft.convertigo.beans.common.XMLVector:
- java.lang.String:
- ↑value: 1729093387316
- java.lang.String:
- ↑value: ./expression[. = '{{{ owner }}}' or 'owner' = '{{{ owner }}}']
log.info("use previous token");
}
'
↓jIf [steps.IfStep-1729518676568]:
condition: token_owner == owner || owner == "owner"
↓GetTokenFromSession [steps.SessionGetStep-1666701028415]:
key: token
output: false
Expand Down
70 changes: 70 additions & 0 deletions _c8oProject/sequences/formscommon_FieldsList.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
accessibility: Hidden
↓Call_Sequence2 [steps.SequenceStep-1729516092076]:
sourceSequence: lib_BaseRow.formscommon_CheckConfig
↓forms_config [variables.StepVariable-1729516092079]:
description: configure=lib_BaseRow/DisplayObjects/mobile/BrowseTables
required: true
↓IfError [steps.IfExistStep-1729516092082]:
condition: IfError
sourceDefinition:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.XMLVector
- com.twinsoft.convertigo.beans.common.XMLVector:
- java.lang.String:
- ↑value: 1729516092076
- java.lang.String:
- ↑value: ./document/error
↓Copy [steps.XMLCopyStep-1729516092085]:
sourceDefinition:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.XMLVector
- com.twinsoft.convertigo.beans.common.XMLVector:
- java.lang.String:
- ↑value: 1729516092076
- java.lang.String:
- ↑value: ./document/error
↓Return [steps.ReturnStep-1729516092088]:
↓ParseConfig [steps.SimpleStep-1729516153011]:
expression: |
jConfig = JSON.parse(forms_config);
table_id = jConfig.table_id;
↓Call_Sequence [steps.SequenceStep-1729515103812]:
sourceSequence: lib_BaseRow.FieldsList
↓table_id [variables.StepVariable-1729515103814]:
comment: Returns only the fields of the table related to the provided value.
description: table_id
required: true
value:
↓Copy [steps.XMLCopyStep-1729515122166]:
sourceDefinition:
- xmlizable:
- ↑classname: com.twinsoft.convertigo.beans.common.XMLVector
- com.twinsoft.convertigo.beans.common.XMLVector:
- java.lang.String:
- ↑value: 1729515103812
- java.lang.String:
- ↑value: ./document/*
↓forms_config [variables.RequestableVariable-1729516077599]:
comment: |
'{
"en": {
"comment": "Choose a table in Baserow",
"displayName": "Configuration"
},
"fr": {
"comment": "Choisissez une table dans Baserow",
"displayName": "Configuration"
},
"es": {
"comment": "Elija una tabla en Baserow",
"displayName": "Configuración"
},
"it": {
"comment": "Scegli una tabella in Baserow",
"displayName": "Configurazione"
}
}'
description: configure=lib_BaseRow/DisplayObjects/mobile/BrowseTables
required: true
value:
5 changes: 3 additions & 2 deletions c8oProject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
contextTimeout: ${lib_baserow.context_timout=3600}
corsOrigin: =Origin
httpSessionTimeout: ${lib_baserow.session_timout=3600}
version: 1.1.0-beta3
version: 1.1.0-beta5
↓Baserow_API_spec [connectors.HttpConnector]: 🗏 connectors/Baserow_API_spec.yaml
↓MediaConnector [connectors.HttpConnector]: 🗏 connectors/MediaConnector.yaml
↓AdminLogin [sequences.GenericSequence]: 🗏 sequences/AdminLogin.yaml
Expand All @@ -28,9 +28,10 @@
↓FieldsList [sequences.GenericSequence]: 🗏 sequences/FieldsList.yaml
↓FieldsListApiKey [sequences.GenericSequence]: 🗏 sequences/FieldsListApiKey.yaml
↓forms_AddRow [sequences.GenericSequence]: 🗏 sequences/forms_AddRow.yaml
↓forms_ApplicationsList [sequences.GenericSequence]: 🗏 sequences/forms_ApplicationsList.yaml
↓forms_DeleteRow [sequences.GenericSequence]: 🗏 sequences/forms_DeleteRow.yaml
↓formscommon_ApplicationsList [sequences.GenericSequence]: 🗏 sequences/formscommon_ApplicationsList.yaml
↓formscommon_CheckConfig [sequences.GenericSequence-1729157158814]: 🗏 sequences/formscommon_CheckConfig.yaml
↓formscommon_FieldsList [sequences.GenericSequence-1729515070603]: 🗏 sequences/formscommon_FieldsList.yaml
↓formssource_GetFieldValues [sequences.GenericSequence]: 🗏 sequences/formssource_GetFieldValues.yaml
↓formssource_GetSelectData [sequences.GenericSequence]: 🗏 sequences/formssource_GetSelectData.yaml
↓formssource_GetTableData [sequences.GenericSequence]: 🗏 sequences/formssource_GetTableData.yaml
Expand Down
48 changes: 39 additions & 9 deletions project.md
Original file line number Diff line number Diff line change
Expand Up @@ -14831,14 +14831,6 @@ The Identifier of the row to update. If not set, the action will add a row. If s

</p></blockquote></details>

<details><summary><b>forms_ApplicationsList</b> : Lists all applications (databases) in baserow</summary><blockquote><p>


## ![](https://github.com/convertigo/convertigo/blob/develop/engine/src/com/twinsoft/convertigo/beans/sequences/images/genericsequence_color_16x16.png?raw=true "GenericSequence") forms_ApplicationsList

Lists all applications (databases) in baserow
</p></blockquote></details>

<details><summary><b>forms_DeleteRow</b> : Deletes a data row from a Baserow table</summary><blockquote><p>


Expand Down Expand Up @@ -14893,6 +14885,14 @@ The Identifier of the row to delete

</p></blockquote></details>

<details><summary><b>formscommon_ApplicationsList</b> : Lists all applications (databases) in baserow</summary><blockquote><p>


## ![](https://github.com/convertigo/convertigo/blob/develop/engine/src/com/twinsoft/convertigo/beans/sequences/images/genericsequence_color_16x16.png?raw=true "GenericSequence") formscommon_ApplicationsList

Lists all applications (databases) in baserow
</p></blockquote></details>

<details><summary><b>formscommon_CheckConfig</b></summary><blockquote><p>


Expand Down Expand Up @@ -14923,6 +14923,36 @@ Fills the select component from data with a given configuration. The first colum

</p></blockquote></details>

<details><summary><b>formscommon_FieldsList</b></summary><blockquote><p>


## ![](https://github.com/convertigo/convertigo/blob/develop/engine/src/com/twinsoft/convertigo/beans/sequences/images/genericsequence_color_16x16.png?raw=true "GenericSequence") formscommon_FieldsList



<span style="color:DarkGoldenRod">Variables</span>

<table>
<tr>
<th>
name
</th>
<th>
comment
</th>
</tr>
<tr>
<td>
<img src="https://github.com/convertigo/convertigo/blob/develop/engine/src/com/twinsoft/convertigo/beans/variables/images/variable_color_16x16.png?raw=true " alt="RequestableVariable" >&nbsp;forms_config
</td>
<td>
Choose a table in Baserow
</td>
</tr>
</table>

</p></blockquote></details>

<details><summary><b>formssource_GetFieldValues</b> : Get all possible values for a given field to feed a Select</summary><blockquote><p>


Expand Down Expand Up @@ -16459,7 +16489,7 @@ comment
</tr>
<tr>
<td>
<img src="https://github.com/convertigo/convertigo/blob/develop/engine/src/com/twinsoft/convertigo/beans/ngx/components/images/uistackvariable_16x16.png?raw=true " alt="UIStackVariable" >&nbsp;tableId
<img src="https://github.com/convertigo/convertigo/blob/develop/engine/src/com/twinsoft/convertigo/beans/ngx/components/images/uistackvariable_16x16.png?raw=true " alt="UIStackVariable" >&nbsp;forms_config
</td>
<td>

Expand Down
26 changes: 20 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ For more technical informations : [documentation](./project.md)
- [FieldsList](#fieldslist)
- [FieldsListApiKey](#fieldslistapikey)
- [forms_AddRow](#forms_addrow)
- [forms_ApplicationsList](#forms_applicationslist)
- [forms_DeleteRow](#forms_deleterow)
- [formscommon_ApplicationsList](#formscommon_applicationslist)
- [formscommon_CheckConfig](#formscommon_checkconfig)
- [formscommon_FieldsList](#formscommon_fieldslist)
- [formssource_GetFieldValues](#formssource_getfieldvalues)
- [formssource_GetSelectData](#formssource_getselectdata)
- [formssource_GetTableData](#formssource_gettabledata)
Expand Down Expand Up @@ -260,10 +261,6 @@ Add or update a row to a Baserow table. Each column of the table must have the s
</tr>
</table>
### forms_ApplicationsList
Lists all applications (databases) in baserow
### forms_DeleteRow
Deletes a data row from a Baserow table
Expand All @@ -288,6 +285,10 @@ Deletes a data row from a Baserow table
</tr>
</table>
### formscommon_ApplicationsList
Lists all applications (databases) in baserow
### formscommon_CheckConfig
**variables**
Expand All @@ -301,6 +302,19 @@ Deletes a data row from a Baserow table
</tr>
</table>
### formscommon_FieldsList
**variables**
<table>
<tr>
<th>name</th><th>comment</th>
</tr>
<tr>
<td>forms_config</td><td>Choose a table in Baserow</td>
</tr>
</table>
### formssource_GetFieldValues
Get all possible values for a given field to feed a Select
Expand Down Expand Up @@ -1052,7 +1066,7 @@ Describes the mobile application global properties
<th>name</th><th>comment</th>
</tr>
<tr>
<td>tableId</td><td></td>
<td>forms_config</td><td></td>
</tr>
</table>
Expand Down

0 comments on commit a7b4cec

Please sign in to comment.