-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #706 from supertokens/dashboard-permissions
Add docs explaining how to manage access for user dashboard users
- Loading branch information
Showing
15 changed files
with
998 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,96 @@ You can edit user information and perform actions such as resetting a user's pas | |
Some features such as user metadata and email verification have to be enabled in your backend before you can use them in the user management dashboard | ||
::: | ||
|
||
## Restricting access to dashboard users | ||
|
||
When using the dashboard recipe you can restrict access to certain features by providing a list of emails to be considered as "admins". When a dashboard user logs in with an email not present in this list, they will only be able to perform read operations and all write operations will result in the backend SDKs failing the request. | ||
|
||
You can provide an array of emails to the backend SDK when initialising the dashboard recipe: | ||
|
||
:::important | ||
- Not providing an admins array will result in all dashboard users being allowed both read and write operations | ||
- Providing an empty array as admins will result in all dashboard users having ONLY read access | ||
::: | ||
|
||
<BackendSDKTabs> | ||
<TabItem value="nodejs"> | ||
|
||
```tsx | ||
import SuperTokens from "supertokens-node"; | ||
import Dashboard from "supertokens-node/recipe/dashboard"; | ||
|
||
SuperTokens.init({ | ||
appInfo: { | ||
apiDomain: "...", | ||
appName: "...", | ||
websiteDomain: "...", | ||
}, | ||
recipeList: [ | ||
// TODO: Initialise other recipes | ||
// highlight-start | ||
Dashboard.init({ | ||
admins: [ | ||
"[email protected]", | ||
], | ||
}), | ||
// highlight-end | ||
], | ||
}); | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="go"> | ||
|
||
```go | ||
import ( | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard" | ||
"github.com/supertokens/supertokens-golang/supertokens" | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard/dashboardmodels" | ||
) | ||
|
||
func main() { | ||
supertokens.Init(supertokens.TypeInput{ | ||
RecipeList: []supertokens.Recipe{ | ||
// TODO: Initialise other recipes | ||
// highlight-start | ||
dashboard.Init(&dashboardmodels.TypeInput{ | ||
Admins: &[]string{ | ||
"[email protected]", | ||
}, | ||
}), | ||
// highlight-end | ||
}, | ||
}); | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="python"> | ||
|
||
```python | ||
from supertokens_python import init, InputAppInfo | ||
from supertokens_python.recipe import dashboard | ||
|
||
init( | ||
app_info=InputAppInfo( | ||
api_domain="...", app_name="...", website_domain="..."), | ||
framework='...', # type: ignore | ||
recipe_list=[ | ||
# TODO: Initialise other recipes | ||
# highlight-start | ||
dashboard.init( | ||
admins=[ | ||
"[email protected]", | ||
], | ||
), | ||
# highlight-end | ||
] | ||
) | ||
``` | ||
|
||
</TabItem> | ||
</BackendSDKTabs> | ||
|
||
## Content Security Policy | ||
|
||
If you return a `Content-Security-Policy` header in from your backend, you will need to include the following directives for the user management dashboard to work correctly | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,96 @@ You can edit user information and perform actions such as resetting a user's pas | |
Some features such as user metadata and email verification have to be enabled in your backend before you can use them in the user management dashboard | ||
::: | ||
|
||
## Restricting access to dashboard users | ||
|
||
When using the dashboard recipe you can restrict access to certain features by providing a list of emails to be considered as "admins". When a dashboard user logs in with an email not present in this list, they will only be able to perform read operations and all write operations will result in the backend SDKs failing the request. | ||
|
||
You can provide an array of emails to the backend SDK when initialising the dashboard recipe: | ||
|
||
:::important | ||
- Not providing an admins array will result in all dashboard users being allowed both read and write operations | ||
- Providing an empty array as admins will result in all dashboard users having ONLY read access | ||
::: | ||
|
||
<BackendSDKTabs> | ||
<TabItem value="nodejs"> | ||
|
||
```tsx | ||
import SuperTokens from "supertokens-node"; | ||
import Dashboard from "supertokens-node/recipe/dashboard"; | ||
|
||
SuperTokens.init({ | ||
appInfo: { | ||
apiDomain: "...", | ||
appName: "...", | ||
websiteDomain: "...", | ||
}, | ||
recipeList: [ | ||
// TODO: Initialise other recipes | ||
// highlight-start | ||
Dashboard.init({ | ||
admins: [ | ||
"[email protected]", | ||
], | ||
}), | ||
// highlight-end | ||
], | ||
}); | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="go"> | ||
|
||
```go | ||
import ( | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard" | ||
"github.com/supertokens/supertokens-golang/supertokens" | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard/dashboardmodels" | ||
) | ||
|
||
func main() { | ||
supertokens.Init(supertokens.TypeInput{ | ||
RecipeList: []supertokens.Recipe{ | ||
// TODO: Initialise other recipes | ||
// highlight-start | ||
dashboard.Init(&dashboardmodels.TypeInput{ | ||
Admins: &[]string{ | ||
"[email protected]", | ||
}, | ||
}), | ||
// highlight-end | ||
}, | ||
}); | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="python"> | ||
|
||
```python | ||
from supertokens_python import init, InputAppInfo | ||
from supertokens_python.recipe import dashboard | ||
|
||
init( | ||
app_info=InputAppInfo( | ||
api_domain="...", app_name="...", website_domain="..."), | ||
framework='...', # type: ignore | ||
recipe_list=[ | ||
# TODO: Initialise other recipes | ||
# highlight-start | ||
dashboard.init( | ||
admins=[ | ||
"[email protected]", | ||
], | ||
), | ||
# highlight-end | ||
] | ||
) | ||
``` | ||
|
||
</TabItem> | ||
</BackendSDKTabs> | ||
|
||
## Content Security Policy | ||
|
||
If you return a `Content-Security-Policy` header in from your backend, you will need to include the following directives for the user management dashboard to work correctly | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,96 @@ You can edit user information and perform actions such as resetting a user's pas | |
Some features such as user metadata and email verification have to be enabled in your backend before you can use them in the user management dashboard | ||
::: | ||
|
||
## Restricting access to dashboard users | ||
|
||
When using the dashboard recipe you can restrict access to certain features by providing a list of emails to be considered as "admins". When a dashboard user logs in with an email not present in this list, they will only be able to perform read operations and all write operations will result in the backend SDKs failing the request. | ||
|
||
You can provide an array of emails to the backend SDK when initialising the dashboard recipe: | ||
|
||
:::important | ||
- Not providing an admins array will result in all dashboard users being allowed both read and write operations | ||
- Providing an empty array as admins will result in all dashboard users having ONLY read access | ||
::: | ||
|
||
<BackendSDKTabs> | ||
<TabItem value="nodejs"> | ||
|
||
```tsx | ||
import SuperTokens from "supertokens-node"; | ||
import Dashboard from "supertokens-node/recipe/dashboard"; | ||
|
||
SuperTokens.init({ | ||
appInfo: { | ||
apiDomain: "...", | ||
appName: "...", | ||
websiteDomain: "...", | ||
}, | ||
recipeList: [ | ||
// TODO: Initialise other recipes | ||
// highlight-start | ||
Dashboard.init({ | ||
admins: [ | ||
"[email protected]", | ||
], | ||
}), | ||
// highlight-end | ||
], | ||
}); | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="go"> | ||
|
||
```go | ||
import ( | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard" | ||
"github.com/supertokens/supertokens-golang/supertokens" | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard/dashboardmodels" | ||
) | ||
|
||
func main() { | ||
supertokens.Init(supertokens.TypeInput{ | ||
RecipeList: []supertokens.Recipe{ | ||
// TODO: Initialise other recipes | ||
// highlight-start | ||
dashboard.Init(&dashboardmodels.TypeInput{ | ||
Admins: &[]string{ | ||
"[email protected]", | ||
}, | ||
}), | ||
// highlight-end | ||
}, | ||
}); | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="python"> | ||
|
||
```python | ||
from supertokens_python import init, InputAppInfo | ||
from supertokens_python.recipe import dashboard | ||
|
||
init( | ||
app_info=InputAppInfo( | ||
api_domain="...", app_name="...", website_domain="..."), | ||
framework='...', # type: ignore | ||
recipe_list=[ | ||
# TODO: Initialise other recipes | ||
# highlight-start | ||
dashboard.init( | ||
admins=[ | ||
"[email protected]", | ||
], | ||
), | ||
# highlight-end | ||
] | ||
) | ||
``` | ||
|
||
</TabItem> | ||
</BackendSDKTabs> | ||
|
||
## Content Security Policy | ||
|
||
If you return a `Content-Security-Policy` header in from your backend, you will need to include the following directives for the user management dashboard to work correctly | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,96 @@ You can edit user information and perform actions such as resetting a user's pas | |
Some features such as user metadata and email verification have to be enabled in your backend before you can use them in the user management dashboard | ||
::: | ||
|
||
## Restricting access to dashboard users | ||
|
||
When using the dashboard recipe you can restrict access to certain features by providing a list of emails to be considered as "admins". When a dashboard user logs in with an email not present in this list, they will only be able to perform read operations and all write operations will result in the backend SDKs failing the request. | ||
|
||
You can provide an array of emails to the backend SDK when initialising the dashboard recipe: | ||
|
||
:::important | ||
- Not providing an admins array will result in all dashboard users being allowed both read and write operations | ||
- Providing an empty array as admins will result in all dashboard users having ONLY read access | ||
::: | ||
|
||
<BackendSDKTabs> | ||
<TabItem value="nodejs"> | ||
|
||
```tsx | ||
import SuperTokens from "supertokens-node"; | ||
import Dashboard from "supertokens-node/recipe/dashboard"; | ||
|
||
SuperTokens.init({ | ||
appInfo: { | ||
apiDomain: "...", | ||
appName: "...", | ||
websiteDomain: "...", | ||
}, | ||
recipeList: [ | ||
// TODO: Initialise other recipes | ||
// highlight-start | ||
Dashboard.init({ | ||
admins: [ | ||
"[email protected]", | ||
], | ||
}), | ||
// highlight-end | ||
], | ||
}); | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="go"> | ||
|
||
```go | ||
import ( | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard" | ||
"github.com/supertokens/supertokens-golang/supertokens" | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard/dashboardmodels" | ||
) | ||
|
||
func main() { | ||
supertokens.Init(supertokens.TypeInput{ | ||
RecipeList: []supertokens.Recipe{ | ||
// TODO: Initialise other recipes | ||
// highlight-start | ||
dashboard.Init(&dashboardmodels.TypeInput{ | ||
Admins: &[]string{ | ||
"[email protected]", | ||
}, | ||
}), | ||
// highlight-end | ||
}, | ||
}); | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="python"> | ||
|
||
```python | ||
from supertokens_python import init, InputAppInfo | ||
from supertokens_python.recipe import dashboard | ||
|
||
init( | ||
app_info=InputAppInfo( | ||
api_domain="...", app_name="...", website_domain="..."), | ||
framework='...', # type: ignore | ||
recipe_list=[ | ||
# TODO: Initialise other recipes | ||
# highlight-start | ||
dashboard.init( | ||
admins=[ | ||
"[email protected]", | ||
], | ||
), | ||
# highlight-end | ||
] | ||
) | ||
``` | ||
|
||
</TabItem> | ||
</BackendSDKTabs> | ||
|
||
## Content Security Policy | ||
|
||
If you return a `Content-Security-Policy` header in from your backend, you will need to include the following directives for the user management dashboard to work correctly | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.