Skip to content

Commit

Permalink
Deployment from App Services
Browse files Browse the repository at this point in the history
  • Loading branch information
mongodb-atlas-app-services[bot] authored Jan 5, 2024
1 parent 689d34d commit 1332603
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 0 deletions.
3 changes: 3 additions & 0 deletions auth/custom_user_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enabled": false
}
18 changes: 18 additions & 0 deletions auth/providers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"api-key": {
"name": "api-key",
"type": "api-key",
"disabled": false
},
"local-userpass": {
"name": "local-userpass",
"type": "local-userpass",
"config": {
"autoConfirm": true,
"resetFunctionName": "resetFunc",
"runConfirmationFunction": false,
"runResetFunction": true
},
"disabled": false
}
}
10 changes: 10 additions & 0 deletions data_sources/FLE-Project-Cluster/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "FLE-Project-Cluster",
"type": "mongodb-atlas",
"config": {
"clusterName": "FLE-Project-Cluster",
"readPreference": "primary",
"wireProtocolEnabled": false
},
"version": 1
}
14 changes: 14 additions & 0 deletions data_sources/FLE-Project-Cluster/default_rule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "6596bbc2032cebd75be23b3b",
"roles": [
{
"name": "readAndWriteAll",
"apply_when": {},
"read": true,
"write": true,
"insert": true,
"delete": true,
"search": true
}
]
}
3 changes: 3 additions & 0 deletions environments/development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": {}
}
3 changes: 3 additions & 0 deletions environments/no-environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": {}
}
3 changes: 3 additions & 0 deletions environments/production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": {}
}
3 changes: 3 additions & 0 deletions environments/qa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": {}
}
3 changes: 3 additions & 0 deletions environments/testing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": {}
}
6 changes: 6 additions & 0 deletions functions/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"name": "resetFunc",
"private": false
}
]
69 changes: 69 additions & 0 deletions functions/resetFunc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
This function will be run when the client SDK 'callResetPasswordFunction' is called with an object parameter that
contains five keys: 'token', 'tokenId', 'username', 'password', and 'currentPasswordValid'.
'currentPasswordValid' is a boolean will be true if a user changes their password by entering their existing
password and the password matches the actual password that is stored. Additional parameters are passed in as part
of the argument list from the SDK.
The return object must contain a 'status' key which can be empty or one of three string values:
'success', 'pending', or 'fail'
'success': the user's password is set to the passed in 'password' parameter.
'pending': the user's password is not reset and the UserPasswordAuthProviderClient 'resetPassword' function would
need to be called with the token, tokenId, and new password via an SDK. (see below)
const Realm = require("realm");
const appConfig = {
id: "my-app-id",
timeout: 1000,
app: {
name: "my-app-name",
version: "1"
}
};
let app = new Realm.App(appConfig);
let client = app.auth.emailPassword;
await client.resetPassword(token, tokenId, newPassword);
'fail': the user's password is not reset and will not be able to log in with that password.
If an error is thrown within the function the result is the same as 'fail'.
Example below:
exports = (
{ token, tokenId, username, password, currentPasswordValid },
sendEmail,
securityQuestionAnswer
) => {
// process the reset token, tokenId, username and password
if (sendEmail) {
context.functions.execute(
"sendResetPasswordEmail",
username,
token,
tokenId
);
// will wait for SDK resetPassword to be called with the token and tokenId
return { status: "pending" };
} else if (
context.functions.execute(
"validateSecurityQuestionAnswer",
username,
securityQuestionAnswer || currentPasswordValid
)
) {
// will set the users password to the password parameter
return { status: "success" };
}
The uncommented function below is just a placeholder and will result in failure.
*/

exports = ({ token, tokenId, username, password }) => {
console.log("Please visit the App Services UI to fully configure your password reset function");
// will not reset the password
return { status: 'fail' };
};
4 changes: 4 additions & 0 deletions graphql/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"use_natural_pluralization": true,
"disable_schema_introspection": false
}
1 change: 1 addition & 0 deletions http_endpoints/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
14 changes: 14 additions & 0 deletions http_endpoints/data_api_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"versions": [
"v1"
],
"run_as_user_id": "",
"run_as_user_id_script_source": "",
"log_function_arguments": false,
"disabled": false,
"validation_method": "NO_VALIDATION",
"secret_name": "",
"fetch_custom_user_data": false,
"create_user_on_auth": false,
"return_type": "JSON"
}
9 changes: 9 additions & 0 deletions realm_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"app_id": "data-ieyeu",
"config_version": 20210101,
"name": "data",
"location": "US-OR",
"provider_region": "aws-us-west-2",
"deployment_model": "LOCAL",
"environment": "development"
}
3 changes: 3 additions & 0 deletions sync/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"development_mode_enabled": false
}

0 comments on commit 1332603

Please sign in to comment.