You have been redirected from an outdated version of the article.
Below is the content available on this topic. To view the old article click here.
Store
The Store element is a two way data storage element used to store or retrieve data within the current flow’s context.
Name |
Description |
Prev |
Accepts connection from another element’s Next socket |
Next |
Connects to another elements Prev socket |
DataTarget |
Connects to element’s DataSource |
DataSource |
Accepts connection from another element’s DataTarget |
Operation |
Switches between storing or receiving data. When receiving DataSource is ignored and when storing DataTarget is ignored. |
Key |
Key under which to store or from which to retrieve data |
Search results for "Store"
requestStore
Can be used to store data in-memory for the duration of the current request. The requestStore can be accessed like a simple JavaScript object and can store arbitrary things.
This keywords uses the same data store as the $.store() and $.retrieve() functions but is easier to use in JavaScript. The newer set of helper functions for this keyword is preferred versus store() and retrieve().
applicationStore
Can be used to store data in-memory as long as the instance is running. The applicationStore can be accessed like a simple JavaScript object and can store arbitrary things.
request_store_get()
Retrieves a stored value from the request level store.
application_store_put()
Stores a value in the application level store.
application_store_put(key, value)
application_store_get_keys()
Lists all keys stored in the application level store.
application_store_get_keys()
application_store_get()
Retrieves a stored value from the application level store.
application_store_get(key)
application_store_delete()
Removes a stored value from the application level store.
application_store_delete(key)
request_store_delete()
Removes a stored value from the request level store.
request_store_delete(key)
request_store_get_keys()
Lists all keys stored in the request level store.
request_store_put()
Stores a value in the request level store.
request_store_put(key, value)
store()
Stores the given value in the current request context under the given key. This method can be used to temporarily save the results of a computation step etc. and is often used to provide some sort of “variables” in the scripting context. See retrieve()
for the inverse operation.
application_store_has()
Checks if a key is present in the application level store.
application_store_has(key)
request_store_has()
Checks if a key is present in the request level store.
Interfaces
application.host | The listen address of the Structr HTTP server. If you set the listen address to 127.0.0.1 , Structr will only be accessible for applications that run on the local host. This value essentially binds the HTTP server to the local loopback interface. The other option is 0.0.0.0 which makes Structr accessible from all networks. |
application.http.port | The HTTP port that Structr listens on. If you want to be able to access Structr under a simple http:// URL, you need to set this value to 80 . |
application.https.port | The HTTPS port that Structr listens on. If you want to be able to access Structr under a simple https:// URL, you need to set this value to 443 . |
application.ssh.port | The port that the SSHService listens on. |
application.ftp.port | The port that the FTPService listens on. |
application.https.enabled | If enabled, the internal HTTP server will be configured to allow HTTPS connections to the application.https.port. |
application.keystore.path | The path to a JKS keystore file that contains the certificate chain and private key for the SSL configuration needed for HTTPS. The keystore must be in PCK12 format. |
application.keystore.password | The password for the JKS keystore used in application.keystore.path. |
application.baseurl.override | Overrides baseUrl value that is originally assembled dynamically from the protocol, hostname and port of the server instance Structr is running on. |
Authentication - JSON Web Tokens
JWT Auth
security.jwt.secrettype | Selects the secret type that will be used to sign or verify a given access or refresh token. |
security.jwt.secret | Used if ‘security.jwt.secrettype’=secret. The secret that will be used to sign and verify all tokens issued and sent to Structr. Must have a min. length of 32 characters. |
security.jwt.jwtissuer | The issuer for the JWTs created by this Structr instance. |
security.jwt.expirationtime | Access token timeout in minutes. |
security.jwt.refreshtoken.expirationtime | Refresh token timeout in minutes. |
security.jwt.keystore | Used if ‘security.jwt.secrettype’=keypair. A valid keystore file containing a private/public keypair that can be used to sign and verify JWTs |
security.jwt.keystore.password | The password for the given ‘security.jwt.keystore’. |
security.jwt.key.alias | The alias of the private key of the given ‘security.jwt.keystore’. |
security.jwks.provider | The URL of the authentication system that issues JWTs. Structr will try to read the .well-known information of the service. |
Self-signed certificate for local development
This command will ask for a keystore password and some information and then create a file named “domain.key.keystore”. Place this file inside the structr main directory alongside the structr.conf configuration file. Configure the keystore password in structr.conf in the key application.keystore.password
and enable HTTPS by setting application.https.enabled = true
. Restarting structr will result in a HTTPS-enabled instance.
NOTE: Some browsers will refuse to connect to servers using self-signed certificates citing security risk as the cause. In some browsers the user can accept the risk and still connect.
Example Implementation
<div id="qrimage-wrapper">
<img id="qrimage" style="margin-left: calc(50% - 100px);">
<div>To use two factor authentication, scan this QR code with an authenticator app on your smartphone.</div>
<div class="text-sm mt-6">
<div>
<b>Android: </b>
<a class="cursor-pointer hover:text-blue-400 text-blue-700" href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en&gl=US">Google Authenticator</a> on Google Playstore
</div>
<div>
<b>Apple iOS: </b>
<a class="cursor-pointer hover:text-blue-400 text-blue-700" href="https://apps.apple.com/us/app/google-authenticator/id388497605">Google Authenticator</a> on App Store
</div>
</div>
</div>
<form action="#" id="twoFactorForm">
<input id="twoFactorToken" type="hidden" value="${request.token}">
<div class="my-6">
<label class="block text-sm font-medium leading-5 text-gray-700">Two Factor Code</label>
<input id="twoFactorCode" class="appearance-none block w-full px-3 py-2 bg-blue-100 border border-gray-300 rounded-md placeholder-gray-400 focus:outline-none focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:text-sm sm:leading-5">
</div>
<button type="submit" id="login-button" class="w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-500 focus:outline-none focus:border-blue-700 focus:shadow-outline-indigo active:bg-blue-700 transition duration-150 ease-in-out">Login</button>
</form>
<script>
document.addEventListener('DOMContentLoaded', () => {
// get all required elements
const qrimageWrapper = document.getElementById('qrimage-wrapper');
const token = document.getElementById('twoFactorToken').value;
const codeInput = document.getElementById('twoFactorCode').value;
const loginButton = document.getElementById('login-button');
let qrdata = (new URLSearchParams(location.search)).get('qrdata');
if (!qrdata) {
// remove qr code placeholder if user is not shown qr code
qrimageWrapper.remove();
} else {
// transform url-safe qr code to regular base64 to display as image
qrimageWrapper.querySelector('#qrimage').src = 'data:image/png;base64, ' + qrdata.replaceAll('_', '/').replaceAll('-', '+');
}
document.getElementById('twoFactorForm').addEventListener('submit', async (event) => {
event.preventDefault();
loginButton.disabled = true;
const response = await fetch('/structr/rest/login', {
method: 'POST',
body: JSON.stringify({
twoFactorToken: token,
twoFactorCode: codeInput
})
});
if (response.ok) {
loginButton.textContent = 'Login successful';
window.location.href = '/';
} else {
let buttonText = 'Login failed - is device time correct?';
let reason = response.headers.get('reason');
if (reason === 'wrongTwoFactorCode') {
buttonText = 'Two Factor Code is not correct';
}
loginButton.disabled = false;
loginButton.textContent = buttonText;
window.setTimeout(function() {
loginButton.textContent = 'Login';
loginButton.disabled = false;
}, 2000);
}
});
});
</script>
Store
The Store element is a two way data storage element used to store or retrieve data within the current flow’s context.
About Me
The About Me section displays information about the user that is currently logged in to the system.
ID | The UUID of the user. |
E-Mail | The E-Mail address of the user. |
Working Directory | The directory in Structr’s virtual file system that the user is currently visiting. This is also the directory where files uploaded via the Structr upload servlet will be uploaded (if no upload path is provided). |
Session ID(s) | A collection of the current session IDs of the user. |
Groups | The list of user groups the user is a member of. |
In addition to these information, Structr also stores the UI preferences of the logged-in user. They can be reset by clicking on “Reset stored UI settings”.