mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
d5fbd0b743
## What This (admittedly massive) PR updates the "physical" documentation structure and fixes url inconsistencies and SEO problems reported by marketing. The main points are: - remove or move directories : advanced, user_guide, deploy, api - move the files contained within to the appropriate one of topics, how-to, tutorials, or reference - update internal doc links and product links to the content - create client-side redirects for all the urls that have changed. A number of the files have been renamed in small ways to better match their url and to make them easier to find. Additionally, the top-level api directory has been moved to /reference/api/legacy/unleash (see the discussion points section for more on this). ## Why When moving our doc structure to diataxis a while back, we left the "physical' files lying where they were, because it didn't matter much to the new structure. However, that did introduce some inconsistencies with where you place docs and how we organize them. There's also the discrepancies in whether urls us underscores or hyphens (which isn't necessarily the same as their file name), which has been annoying me for a while, but now has also been raised by marketing as an issue in terms of SEO. ## Discussion points The old, hand-written API docs have been moved from /api to /reference/api/legacy/unleash. There _is_ a /reference/api/unleash directory, but this is being populated by the OpenAPI plugin, and mixing those could only cause trouble. However, I'm unsure about putting /legacy/ in the title, because the API isn't legacy, the docs are. Maybe we could use another path? Like /old-docs/ or something? I'd appreciate some input on this.
59 lines
2.2 KiB
Markdown
59 lines
2.2 KiB
Markdown
---
|
|
title: Securing Unleash
|
|
---
|
|
|
|
**If you are still using Unleash v3 you need to follow the [securing-unleash-v3](./securing-unleash-v3)**
|
|
|
|
> This guide is only relevant if you are using Unleash Open-Source. The Enterprise edition does already ship with multiple SSO options, such as SAML 2.0, OpenID Connect.
|
|
|
|
Unleash Open-Source v4 comes with username/password authentication out of the box. In addition Unleash v4 also comes with API token support, to make it easy to handle access tokens for Client SDKs and programmatic access to the Unleash APIs.
|
|
|
|
### Password requirements {#password-requirements}
|
|
|
|
Unleash requires a strong password.
|
|
|
|
- minimum 10 characters long
|
|
- contains at least one uppercase letter
|
|
- contains at least one number
|
|
- contains at least one special character (symbol)
|
|
|
|
### Implementing Custom Authentication {#implementing-custom-authentication}
|
|
|
|
If you do not wish to use the built-in username/password authentication you can add a customAuthHandler
|
|
|
|
To secure the Admin API, you have to tell Unleash that you are using a custom admin authentication and implement your authentication logic as a preHook.
|
|
|
|
```javascript
|
|
const unleash = require('unleash-server');
|
|
const myCustomAdminAuth = require('./auth-hook');
|
|
|
|
unleash
|
|
.start({
|
|
databaseUrl: 'postgres://unleash_user:passord@localhost:5432/unleash',
|
|
authentication: {
|
|
type: 'custom',
|
|
customAuthHandler: myCustomAdminAuth,
|
|
},
|
|
})
|
|
.then((unleash) => {
|
|
console.log(
|
|
`Unleash started on http://localhost:${unleash.app.get('port')}`,
|
|
);
|
|
});
|
|
```
|
|
|
|
Additionally, you can trigger the admin interface to prompt the user to sign in by configuring your middleware to return a `401` status on protected routes. The response body must contain a `message` and a `path` used to redirect the user to the proper login route.
|
|
|
|
```json
|
|
{
|
|
"message": "You must be logged in to use Unleash",
|
|
"path": "/custom/login"
|
|
}
|
|
```
|
|
|
|
Examples of custom authentication hooks:
|
|
|
|
- [securing-google-auth](https://github.com/Unleash/unleash-examples/tree/main/v4/securing-google-auth)
|
|
- [securing-basic-auth](https://github.com/Unleash/unleash-examples/tree/main/v4/securing-basic-auth)
|
|
- [securing-keycloak-auth](https://github.com/Unleash/unleash-examples/tree/main/v4/securing-keycloak-auth)
|