1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
Commit Graph

599 Commits

Author SHA1 Message Date
sjaanus
a22d5f5a43
Favorite project (#2569)
Adds ability to favorite projects.

1. Can favorite project
2. Can unfavorite project
3. Favorite field is returned on `/api/admin/projects/default`
4. Favorite field is returned on` /api/admin/projects`
2022-11-30 13:41:53 +02:00
sjaanus
0d58371f11
Some tweaks to favorites (#2563)
This is follow up PR to https://github.com/Unleash/unleash/pull/2550,
which addresses the issues that came up from reviews.
2022-11-30 09:47:57 +02:00
sjaanus
9ac6b945be
Fix super small text issue (#2473)
Fix super small text issue

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-11-30 09:18:49 +02:00
Nuno Góis
7ce38ffe89
feat: update seen_at pat column (#2516)
https://linear.app/unleash/issue/2-451/update-last-seen-column-for-pats
2022-11-30 08:10:31 +02:00
Nuno Góis
4d8817698a
feat: add last seen column to token table (#2520)
https://linear.app/unleash/issue/2-449/add-table-column-to-api-tokens-table-ui
2022-11-30 08:07:13 +02:00
Nuno Góis
564c287025
Feat update token seen at (#2514)
https://linear.app/unleash/issue/2-448/update-last-seen-column-for-api-tokens

Co-authored-by: Ivar Conradi Østhus <ivar@getunleash.ai>
2022-11-29 19:46:40 +00:00
sjaanus
b32d3d0fee
Favorite features (#2550) 2022-11-29 16:06:08 +01:00
Nuno Góis
1fec43947d
add feature flag: network view (#2543)
https://linear.app/unleash/issue/2-453/add-feature-flag
2022-11-28 13:48:02 +00:00
Christopher Kolstad
1ecbc32e14
task: Make operations on the API Token store auditable. (#2531)
## About the changes
We need a way to have an audit log for operations made on Api Tokens.
These changes adds three new event types, API_TOKEN_CREATED,
API_TOKEN_UPDATED, API_TOKEN_DELETED and extends api-token-service to
store these to our event store to reflect the action being taken.
2022-11-28 10:56:34 +01:00
Fredrik Strand Oseberg
5d52216d53
fix: adds cors caching (#2522)
* This PR adds a configurable maxAge header to the CORS middleware. This
allows the preflight request to be cached so that we can reduce the
request load on our end for the frontend clients starting to utilise the
frontend api.
2022-11-24 16:14:47 +01:00
andreas-unleash
35d9a62d89
Soft landing page on projects or last viewed project (#2499)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

This PR introduces a soft landing page to the last viewed project or to
the project list (if there is more than 1 project)

Changes: 
- Replaced clearing of `storage` with clearing `cache` in logout.ts ::
REVERTED
- Root redirects to `projects` instead of `features`

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2022-11-23 15:58:02 +02:00
Simon Hornby
0897180af5
fix: resolve an issue where cloning a feature toggle with a segment (#2511)
fix an issue where cloning a feature toggle with a strategy with segments would raise an error but still clone successfully
2022-11-23 15:39:09 +02:00
Nuno Góis
f9726fdee9
add tokens last seen feature flag (#2512)
https://linear.app/unleash/issue/2-450/add-feature-flag
2022-11-23 13:33:02 +00:00
sjaanus
b071de6742
Add possibility to soft delete users (#2497)
Previously we hard deleted the users, but due to change requests and
possibly other features in future, we really want to hard-link user
table and have meaningful relationships.

But this means, when user is deleted, all linked data is also deleted.
**Workaround is to soft delete users and just clear users data and keep
the relationships alive for audit logs.**

This PR implements this feature.
2022-11-23 09:30:54 +02:00
Simon Hornby
801df6953c
fix: force clone feature to correctly copy variant environments (#2498)
patches an issue where cloning a feature would clone variants for
it's last found environment in the db. This now will clone the feature
environments correctly
2022-11-22 17:00:44 +02:00
Mateusz Kwasniewski
8af64e9370
add events and expose them for webhooks (#2493) 2022-11-22 13:39:15 +01:00
Simon Hornby
2a4ca96da2
Permission for variant environments (#2490)
adds permissions for variants per environment
2022-11-22 11:54:04 +02:00
Thomas Heartman
d5fbd0b743
refactor: move docs into new structure / fix links for SEO (#2416)
## 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.
2022-11-22 09:05:30 +00:00
Christopher Kolstad
f937e80272
fix: Updated event to include project (#2491)
### What
Our EnvironmentVariant needs project name so this PR makes sure our
service accepts the project id as one of the arguments.
2022-11-22 09:57:12 +01:00
andreas-unleash
6e5b214475
implement proxy all endpoint (#2460)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

This PR implements the `all` endpoint of unleash-proxy, by adding an
experimental flag that can control the behaviour

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2022-11-21 12:57:07 +02:00
Gastón Fournier
efd47b72a8
feat: Add variants per env (#2471)
## About the changes
Variants are now stored in each environment rather than in the feature
toggle. This enables RBAC, suggest changes, etc to also apply to
variants.

Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#2254

### Important files
- **src/lib/db/feature-strategy-store.ts** a complex query was moved to
a view named `features_view`
- **src/lib/services/state-service.ts** export version number increased
due to the new format

## Discussion points
We're keeping the old column as a safeguard to be able to go back

Co-authored-by: sighphyre <liquidwicked64@gmail.com>
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2022-11-21 10:37:16 +01:00
andreas-unleash
a165eb191c
add back removed permissions and eventType from module exports (#2476)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
This PR adds (back) the permissions and eventType module exports

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2022-11-21 10:42:43 +02:00
Nuno Góis
93bd9d869a
Variants per environment (frontend) (#2453)
![image](https://user-images.githubusercontent.com/14320932/202286759-b9c30228-59cc-4c58-a7b0-3c6c3d0ecba6.png)
## About the changes

https://linear.app/unleash/issue/2-425/variants-crud-new-environment-cards-with-tables-inside-add-edit-and

Basically created parallel components for the **variants per
environments** feature, so both flows should work correctly depending on
the feature flag state. Some of the duplication means that cleanup
should be straightforward - Once we're happy with this feature it should
be enough to delete
`frontend/src/component/feature/FeatureView/FeatureVariants/FeatureVariantsList`
and do some little extra cleanup.

I noticed we had some legacy-looking code in variants, so this involved
*some* rewriting of the current variants logic. Hopefully this new code
looks nicer, more maintainable, and more importantly **doesn't break
anything**.

Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#2254

### Important files
Everything inside the
`frontend/src/component/feature/FeatureView/FeatureVariants/FeatureEnvironmentVariants`
folder.
2022-11-18 11:43:24 +00:00
Mateusz Kwasniewski
ac65778cfa
separate protected and unprotected routes (#2466) 2022-11-18 09:29:26 +01:00
Gastón Fournier
dc08f1dadd
fix: broken UI after import (#2447)
fix: broken UI when importing features into environments which are not linked to the feature's project

## Related to
- PR: https://github.com/Unleash/unleash/pull/2209
- Issue: https://github.com/Unleash/unleash/issues/2186
- Issue: https://github.com/Unleash/unleash/issues/2193

## Expected behaviour:
After importing we should see:

![image](https://user-images.githubusercontent.com/455064/202149719-fa74b3b7-3936-443b-9d0e-8f1ca2e779f4.png)

## About the changes
**The problem:** when we import we have projects, features and
environments. Each feature belongs to a project (this is by default and
the imported file enforces that). The links between projects and
features, or projects and environments, depend on us creating those
relationships. When we add a feature to an environment we're not
validating that the project and the environment are connected. Because
of that, in some situations (like in this test), we can end up with a
project with features but no environment.

This breaks a weak constraint we had which is that all projects should
have at least one environment.

**This PR makes the following assumption when importing**: _if a feature
is added to an environment, and that environment is still not linked to
the project that feature belongs to, then the project and environments
have to be linked_. The rationale behind this is that the user couldn't
have generated this export file without the project and environment
being linked together.
2022-11-17 14:05:57 +01:00
andreas-unleash
726ede5cbe
Define exports for enterprise (#2435)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
This PR sets up exports so that we can import in enterprise with just
"unleash-server".
This will free us to refactor unleash internals without breaking
enterprise

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->
2022-11-17 13:02:40 +02:00
sjaanus
9176ffae1e
Change requests - add multiple reviewers (#2448)
This PR adds implements the frontend and migrations part of multiple
reviewers.

2 UI parts:

1. Configuration to add the count of required approvals
2. Handle multiple approvers in review page.
2022-11-17 11:08:29 +02:00
Fredrik Strand Oseberg
978674e33a
feat: update strategy segments with edit / create strategy (#2420)
* Refactors how we add / edit segments to make it more ergonomic to work with in regards to change requests
2022-11-16 15:35:39 +01:00
sjaanus
3ef0ca580a
Remove change request api protection (#2434)
Remove change request api protection
2022-11-15 14:13:09 +02:00
Nuno Góis
1ddc46011c
Feature toggles: Filtering by tags (#2396)
https://linear.app/unleash/issue/UNL-140/experiment-with-filtering-feature-toggles-by-tags-on-the-ui

Going with a naïve approach for now, tags can be searchable the same way
we search for text. The tags column only shows up if at least one toggle
has tags set. There's a simple highlightable component that lets us know
a match was found and then shows all the tags on a tooltip:
<img width="1289" alt="image"
src="https://user-images.githubusercontent.com/14320932/201155093-b8605ff2-5bf7-45c5-b240-a33da254c278.png">
2022-11-15 10:24:36 +00:00
Tymoteusz Czech
a191313956
refactor: remove public signup link feature flag (#2423)
## About the changes
Cleanup: remove feature flag.

Closes
[1-356/remove-feature-flag-from-the-code](https://linear.app/unleash/issue/1-356/remove-feature-flag-from-the-code)
2022-11-15 10:03:20 +01:00
sjaanus
131ebb931a
Permission guards in existing endpoints interacting with feature toggle configuration (#2418)
This PR adds permission guards for operations.

1. Toggling feature flag
2. Adding a strategy
3. Updating a strategy
4. Deleting a strategy
2022-11-14 15:05:26 +02:00
Nuno Góis
2fa154a3e4
Update environments (#2339)
https://linear.app/unleash/issue/2-357/update-environments-pages
2022-11-11 10:24:56 +00:00
andreas-unleash
74c5189159
Feat/add change request settings (#2390)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
Add change_request_settings table 
Remove change_request_enabled column

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->
2022-11-11 10:09:25 +02:00
Thomas Heartman
665638b9da
fix: Fix broken OpenAPI (#2379)
## What

This change removes the use of double quotes in the
'addPublicSignupTokenUser' endpoint summary. It also changes the
original summary to a description and adds a new, shorter summary.

## Why

The OpenAPI / docusaurus integration errors out (refer to [this failed
build](https://github.com/Unleash/unleash/actions/runs/3434792557/jobs/5726445104))
if the frontmatter contains invalid characters. In this case, it's
because the automatic sidebar label contains double quotes, which it
interprets as a new key having been declared:

```
Error:  Error while parsing Markdown front matter.
This can happen if you use special characters in front matter values (try using double quotes around that value).
Error:  Loading of version failed for version current
Error:  Unable to build website for locale en.
Error:  YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 4, column 12:
    description: "Create a user with the 'viewe ...
               ^
```

For some reason, I cannot reproduce this error locally. Instead, the
generation goes as expected.

---

Regarding using description instead of summary: summaries should be very
short and sweet, especially because they're also used in the generated
sidebar. Descriptions can be a bit wordier, so I added a shorter summary
for going forward.

## Generated output

This is what the old configuration would generate. Notice the
`sidedar_label` key on line 2:

```md
---
id: add-public-signup-token-user
sidebar_label: Create a user with the "viewer" root role and link them to a signup token
hide_title: true
hide_table_of_contents: true
api: {'tags': ['Public signup tokens'], 'operationId': 'addPublicSignupTokenUser', 'requestBody': {'description': 'createInvitedUserSchema', 'required': true, 'content': {'application/json': {'schema': {'type': 'object', 'additionalProperties': false, 'required': ['email', 'name', 'password'], 'properties': {'username': { 'type': 'string' }, 'email': { 'type': 'string' }, 'name': { 'type': 'string' }, 'password': { 'type': 'string' },},},},},}, 'responses': {'200': {'description': 'userSchema', 'content': {'application/json': {'schema': {'type': 'object', 'additionalProperties': false, 'required': ['id'], 'properties': {'id': {'type': 'number',}, 'isAPI': {'type': 'boolean',}, 'name': {'type': 'string',}, 'email': {'type': 'string',}, 'username': {'type': 'string',}, 'imageUrl': {'type': 'string',}, 'inviteLink': {'type': 'string',}, 'loginAttempts': {'type': 'number',}, 'emailSent': {'type': 'boolean',}, 'rootRole': {'type': 'number',}, 'seenAt': {'type': 'string', 'format': 'date-time', 'nullable': true,}, 'createdAt': {'type': 'string', 'format': 'date-time',},},},},},}, '400': {'description': 'The request data does not match what we expect.',}, '409': {'description': 'The provided resource can not be created or updated because it would conflict with the current state of the resource or with an already existing resource, respectively.',},}, 'parameters': [{'name': 'token', 'in': 'path', 'required': true, 'schema': { 'type': 'string' },},], 'description': 'Create a user with the "viewer" root role and link them to a signup token', 'method': 'post', 'path': '/invite/{token}/signup', 'servers': [{ 'url': '<your-unleash-url>' }], 'security': [{ 'apiKey': [] }], 'securitySchemes': {'apiKey': {'type': 'apiKey', 'in': 'header', 'name': 'Authorization',},}, 'jsonRequestBodyExample': {'username': 'string', 'email': 'string', 'name': 'string', 'password': 'string',}, 'info': { 'title': 'Unleash API', 'version': '4.17.2' }, 'postman': {'name': 'Create a user with the "viewer" root role and link them to a signup token', 'description': { 'type': 'text/plain' }, 'url': {'path': ['invite', ':token', 'signup'], 'host': ['{{baseUrl}}'], 'query': [], 'variable': [{'disabled': false, 'description': {'content': '(Required) ', 'type': 'text/plain',}, 'type': 'any', 'value': '', 'key': 'token',},],}, 'header': [{ 'key': 'Content-Type', 'value': 'application/json' }, { 'key': 'Accept', 'value': 'application/json' },], 'method': 'POST', 'body': {'mode': 'raw', 'raw': '""', 'options': { 'raw': { 'language': 'json' } }}}}
sidebar_class_name: 'post api-method'
info_path: docs/reference/api/unleash/unleash-api
---

import ApiTabs from "@theme/ApiTabs"; import MimeTabs from "@theme/MimeTabs"; import ParamsItem from "@theme/ParamsItem"; import ResponseSamples from "@theme/ResponseSamples"; import SchemaItem from "@theme/SchemaItem" import SchemaTabs from "@theme/SchemaTabs"; import DiscriminatorTabs from "@theme/DiscriminatorTabs"; import TabItem from "@theme/TabItem";

## Create a user with the &quot;viewer&quot; root role and link them to a signup token

Create a user with the &quot;viewer&quot; root role and link them to a signup token

<!-- And much much more! -->
```
2022-11-10 22:55:01 +01:00
sjaanus
e5a5d7ded9
Fix async issue (#2387)
Currently rows were returned as a list of promise, but we need to await
for them.
2022-11-10 14:27:09 +02:00
Mateusz Kwasniewski
076ce027ed
Extract gravatar URL fn (#2386) 2022-11-10 12:13:45 +01:00
Fredrik Strand Oseberg
ac78c8f732
Feat/change request permissions (#2382)
* Adds two new permissions for the new enterprise level change request: APPROVE_CHANGE_REQUEST and APPLY_CHANGE_REQUEST
2022-11-10 11:08:58 +01:00
Ivar Conradi Østhus
1312579bf6
fix: upgrade @types/node to v16.18.3 (#2365)
This pr upgrade @types/node to v16.18.3.
This also detected some inconsitent retrun types that I decided to fix.
2022-11-10 08:20:15 +01:00
Ivar Conradi Østhus
325cd34c0c
fix: remove 'fixHourMetrics' flag 2022-11-09 22:45:30 +01:00
andreas-unleash
47a617c78b
Add changeRequestEnabled to project and project_environments (#2357)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

- Add `change_request_enabled` column to `projects` and
`project_environments`
- Modified the store to include the new column
- Added new column to Project open api schema 

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->
2022-11-09 14:44:53 +02:00
Sebastian Bury
f316e99dca
Authorization header webhook (#2356)
Added unit test and made code prettier in 
webhook.ts
webhook.test.ts
2022-11-09 11:45:30 +01:00
sjaanus
5e14e80ae3
Change request approvals table (#2347)
1. Added database table for change request approvals
2. Removed separate endpoint for applying. **Now all state changes will
go through same endpoint.**
2022-11-09 10:40:47 +02:00
Christopher Kolstad
5b3d95cc3a
If baseUriPath is set format it, but if it's not, don't override default with empty string (#2118)
From Thomas and mine testing. BaseUriPath can't be set as an environment
variable because we override it when trying to format the URI from the
server config. This PR makes sure we only format if the custom server
options actually have baseUriPath set.

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-11-08 15:29:14 +01:00
Thomas Heartman
d5e33ab1f2
Fix(export API): accept true and false as param values (#2349)
## What

This PR updates the `paramToBool` function to first check whether the
incoming argument is a boolean. This fixes the bug where using `true` or
`false` (e.g. `Strategies=false`) in the query would cause the server to
crash.

I've also added a test case to check for these values.

## Why

While working on the import/export API docs, I noticed that using
`false` in an export request caused the server to crash.

As we want to allow `true` and `false` (and use these values in the
documentation), we should ensure that they work as expected.

## Background

It's likely that this bug was introduced when we added the new OpenAPI
query parameters to the export endpoint. Because of the way that the
OpenAPI service we use does conversion, we now get `true` and `false`
converted to actual boolean values instead of strings. The `paramToBool`
function didn't account for that previously, which is why it caused the
server to crash.
2022-11-08 15:25:02 +01:00
Thomas Heartman
f5fb7b66d1
Fix: validate that the project is correct when getting feature by project (#2344)
## What

This PR fixes a bug where fetching a feature toggle via the
`/api/admin/projects/:projectId/features/:featureName` endpoint doesn't
validate that the feature belongs to the provided project. The same
thing applies to the archive functionality. This has also been fixed.

In doing so, it also adds corresponding tests to check for edge cases,
updates the 403 error response we use to provide clearer steps for the
user, and adds more error responses to the OpenAPI documentation.

## Why

As mentioned in #2337, it's unexpected that the provided project
shouldn't matter at all, and after discussions internally, it was also
discovered that this was never intended to be the case.

## Discussion points

It might be worth rethinking this for Unleash v5. Why does the features
API need the projects part at all when features are unique across the
entire instance? Would it be worth reverting to a simpler feature API
later or would that introduce issues with regards to how different
projects can have different active environments and so on?

### Further improvements

I have _not_ provided schemas for the error responses for the endpoints
at this time. I considered it, but because it would introduce new schema
code, more tests, etc, I decided to leave it for later. There's a
thorough OpenAPI walkthrough coming up, so I think it makes sense to do
it as part of that work instead. I am happy to be challenged on this,
however, and will implement it if you think it's better.

### Why 403 when the project is wrong?

We could also have used the 404 status code for when the feature exists
but doesn't belong to this project, but this would require more (and
more complex) code. We also already use 403 for cases like this for
post, patch, and put. Finally, the [HTTP spec's section on the 403
status code](https://httpwg.org/specs/rfc9110.html#status.403) says the
following (emphasis mine):

> The 403 (Forbidden) status code indicates that the server
**_understood the request but refuses to fulfill it_**. A server that
wishes to make public why the request has been forbidden can describe
that reason in the response content (if any).
>
> If authentication credentials were provided in the request, the server
considers them insufficient to grant access. The client SHOULD NOT
automatically repeat the request with the same credentials. The client
MAY repeat the request with new or different credentials. However, **_a
request might be forbidden for reasons unrelated to the credentials_**.

As such, I think using 403 makes sense in this case.

---

Closes #2337.
2022-11-08 13:34:01 +01:00
Fredrik Strand Oseberg
f76ac0edb3
Fix/embedded proxy memory leak (#2345)
* Fixes a memory leak where events would trigger the data polling to restart. Any event would setup another polling interval, which would strain our database. Separated the logic for fetching the data and the polling, and made sure that the polling was only initialized once.
2022-11-08 12:35:53 +01:00
Ivar Conradi Østhus
bf521b58fd
fix: merge order for UI config 2022-11-04 14:43:12 +01:00
Ivar Conradi Østhus
2d2d6f268a
fix: generate all hour buckets if missing (#2319) 2022-11-04 09:30:02 +01:00
Nuno Góis
9fb431aab7
fix: limit total of PATs a user can have (#2301)
* fix: limit total of PATs a user can have

* increase PAT limit to 10

* Update src/lib/services/pat-service.ts

Co-authored-by: Simon Hornby <liquidwicked64@gmail.com>

* disable button on the front-end when PAT limit is reached

* import from server instead of repeating ourselves

Co-authored-by: Simon Hornby <liquidwicked64@gmail.com>
2022-11-02 08:11:35 +00:00