1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
Commit Graph

1051 Commits

Author SHA1 Message Date
Thomas Heartman
d49626133e
tests: don't use multiple expect.stringContaining in one statement (#4158)
Apparently Jest doesn't like it when you use multiple stringContaining
statements for one property. Only the last `stringContaining`
statement is evaluated while the others are ignored.

This means that a lot of these assertions were never checked. To fix
that, I've extracted them into separate assertions.
2023-07-06 11:09:59 +02:00
Christopher Kolstad
b04545c25f
docs: Events tag (#4152)
### What
This PR adds documentation for our endpoints that are covered by our
"Events" tag. It also adds a type for all valid events, and then uses
this as valid values for type argument.
2023-07-06 08:57:09 +00:00
Thomas Heartman
6d591fcd17
openapi: update API tokens tag (#4137)
This PR updates endpoints and schemas for the API tokens tag.

As part of that, they also handle oneOf openapi validation errors and improve the console output for the enforcer tests.
2023-07-06 07:30:31 +00:00
Mateusz Kwasniewski
79b34121a4
feat: openapi schema for user admin (#4146) 2023-07-06 08:24:46 +02:00
Simon Hornby
b0e4c8a57e
chore: remove group root role toggle (#4026) 2023-07-05 14:33:33 +02:00
Gastón Fournier
661cbf2b91
fix: some security vulnerabilities (#4143)
## About the changes
This should address:
https://github.com/Unleash/unleash/security/code-scanning/1,
https://github.com/Unleash/unleash/security/code-scanning/49 and
https://github.com/Unleash/unleash/security/code-scanning/52

Refs:
-
https://securitylab.github.com/research/github-actions-untrusted-input/
-
https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1.1

---------

Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-07-05 11:51:27 +02:00
Tymoteusz Czech
de8e9a03ae
Inline endpoint descriptions (#4145)
Update OpenApi docs
2023-07-05 11:25:58 +02:00
Christopher Kolstad
186fda1657
task: Add customHeaders as possible parameter. (#4139)
###What
Adds an optional sensitive parameter for customHeaders to all current
addons. It is sensitive because the user might be including api key headers.
2023-07-05 09:42:17 +02:00
Thomas Heartman
451c67a24b
refactor: use requestType instead of isAdmin, optionalIncludes (#4115)
This removes the burden of knowing what optionalIncludes is and also
prevents weird edge cases like isAdmin with optionalIncludes.
2023-07-05 09:32:42 +02:00
andreas-unleash
64c1527213
chore: document endpoint tagged Unstable (#4118)
Adds description and summary to all endpoints with Unstable tag
2023-07-04 14:41:16 +00:00
Thomas Heartman
f799f72697
openapi: strategies tag (#4116)
Update OpenAPI schemas and operation descriptions for the strategies
tag.
2023-07-04 14:21:09 +02:00
Christopher Kolstad
0b18491237
docs: Auth tag (#4126)
## What
This adds openapi documentation for the Auth tagged operations and
connected schemas.

## Discussion points
Our user schema seems to be exposing quite a bit of internal fields, I
flagged the isApi field as deprecated, I can imagine quite a few of
these fields also being deprecated to prepare for removal in next major
version, but I was unsure which ones were safe to do so with.

## Observation
We have some technical debt around the shape of the schema we're
claiming we're returning and what we actually are returning. I believe
@gastonfournier also observed this when we turned on validation for our
endpoints.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-07-04 08:31:54 +00:00
Mateusz Kwasniewski
b50b06c257
feat: Frontend api openapi spec (#4133) 2023-07-03 15:48:09 +02:00
Gard Rimestad
608b1b9674
fix: SERVER_KEEPALIVE_TIMEOUT env variable should be seconds (#4130)
This changes SERVER_KEEPALIVE_TIMEOUT to take in seconds instead of
milliseconds.
2023-07-03 09:35:02 +02:00
Jaanus Sellin
b329084a69
chore: openapi docs for archive (#4127) 2023-06-30 15:22:08 +03:00
Nuno Góis
dc52c95787
refactor: clean up deprecated permissions (#4124)
https://linear.app/unleash/issue/2-1158/add-delete-migration-to-clean-up-no-longer-used-permissions

Cleans up the filter in https://github.com/Unleash/unleash/pull/4083 and
deletes the deprecated permissions from the database.
2023-06-30 11:15:11 +01:00
David Leek
78ba72d861
feat: remove experimental flag for telemetry (#4123)
<!-- 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. -->

This removes the experimental feature flag that defaulted to turn off
telemetry collection
2023-06-30 11:27:54 +02:00
Thomas Heartman
4a4f14f69b
ux: return better error message if a segment doesn't exist (#4122)
Catch cases where the segment doesn't exist and populate that error
message with more info: it now says that a segment
with <id> doesn't exist instead of just 'No row'.
2023-06-30 09:02:24 +00:00
David Leek
3a14b97fdd
feat/telemetry opt out (#4035)
<!-- 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. -->

Adds a UI that shows current status of version and feature usage
collection configuration, and a presence in the configuration menu +
menu bar.

Configuring these features is done by setting environment variables. The
version info collection is an existing feature that we're making more
visible, the feature usage collection feature is a new feature that has
it's own environment configuration but also depends on version info
collection being active to work.

When version collection is turned off and the experimental feature flag
for feature usage collection is turned off:
<img width="1269" alt="image"
src="https://github.com/Unleash/unleash/assets/707867/435a07da-d238-4b5b-a150-07e3bd6b816f">


When version collection is turned on and the experimental feature flag
is off:
<img width="1249" alt="image"
src="https://github.com/Unleash/unleash/assets/707867/8d1a76c5-99c9-4551-9a4f-86d477bbbf6f">


When the experimental feature flag is enabled, and version+telemetry is
turned off:
<img width="1239" alt="image"
src="https://github.com/Unleash/unleash/assets/707867/e0bc532b-be94-4076-bee1-faef9bc48a5b">


When version collection is turned on, the experimental feature flag is
enabled, and telemetry collection is turned off:
<img width="1234" alt="image"
src="https://github.com/Unleash/unleash/assets/707867/1bd190c1-08fe-4402-bde3-56f863a33289">


When version collection is turned on, the experimental feature flag is
enabled, and telemetry collection is turned on:
<img width="1229" alt="image"
src="https://github.com/Unleash/unleash/assets/707867/848912cd-30bd-43cf-9b81-c58a4cbad1e4">


When version collection is turned off, the experimental feature flag is
enabled, and telemetry collection is turned on:
<img width="1241" alt="image"
src="https://github.com/Unleash/unleash/assets/707867/d2b981f2-033f-4fae-a115-f93e0653729b">

---------

Co-authored-by: sighphyre <liquidwicked64@gmail.com>
Co-authored-by: Nuno Góis <github@nunogois.com>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-06-30 08:43:58 +02:00
Christopher Kolstad
b99eafc9cc
docs: Context api tag (#4117)
### What
Added documentation for context fields and endpoints tagged with the
"Context" tag.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-06-29 14:04:48 +02:00
Jaanus Sellin
19770fc33c
fix: metrics performance patch (#4108) 2023-06-29 13:14:37 +03:00
Thomas Heartman
be0e94105d
bug(#3545): include strategy titles on playground evaluation results (#4084)
This PR adds strategy titles as an optional bit of data added to client
features. It's only added when prompted.


![image](https://github.com/Unleash/unleash/assets/17786332/99509679-2aab-4c2a-abff-c6e6f27d8074)

## Discussion points:

### getPlaygroundFeatures

The optional `includeStrategyId` parameter has been replaced by a
`getPlaygroundFeatures` in the service (and in the underlying store).
The playground was the only place that used this specific include, so
instead of adding more and making the interface for that method more
complex, I created a new method that deals specifically with the
playground.

The underlying store still uses an `optionalIncludes` parameter,
however. I have a plan to make that interface more fluid, but I'd like
to propose that in a follow-up PR.
2023-06-29 10:38:51 +02:00
Christopher Kolstad
c2cf24ae1d
fix: Default email sender to getunleash.io domain (#3739)
As part of the move to a unified domain this PR updates the default
EMAIL_SENDER to noreply@getunleash.io . Should not be merged/deployed
until we've verified DMARC, DKIM for the new domain.
2023-06-29 06:44:27 +00:00
andreas-unleash
5cbbd6f798
chore: remove strategyImprovements flag (#4043)
<!-- 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! ❤️ -->
Remove strategy improvements flag 
## 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 #
[1-1048](https://linear.app/unleash/issue/1-1048/remove-strategyimprovements-flag)

<!-- (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>
2023-06-28 11:38:21 +03:00
Jaanus Sellin
803610ab82
fix: max revision query order (#4096) 2023-06-27 12:07:23 +03:00
Gastón Fournier
ee8c9a62da
chore: filter out deprecated permissions (#4083)
## About the changes
This makes these permissions not available for selection. In particular
`UPDATE_ROLE`, `CREATE_API_TOKEN`, `UPDATE_API_TOKEN`,
`DELETE_API_TOKEN`, `READ_API_TOKEN` are long-lived and should be taken
out with special care which is why we have
https://linear.app/unleash/issue/2-1158/add-delete-migration-to-clean-up-no-longer-used-permissions

## Discussion points
If a role has this permission assigned, it will be displayed but will
not be able to remove it. Because the application code does not rely on
these permissions, this shouldn't be a problem. Later when we remove
them from the DB, the permission will be removed as well from the role
by the migration
2023-06-23 12:26:35 +02:00
Gastón Fournier
89cf16f915
Feat/more granular permissions check in create apitoken (#4072)
## About the changes
This PR enables or disables create API token button based on the
permissions.

**Note:** the button is only displayed if you have READ permissions on
some API token. This is a minor limitation as having CREATE permissions
should also grant READ permissions, but right now this is up to the user
to set up the custom role with the correct permissions

**Note 2:** Project-specific API tokens are also ruled by the
project-specific permission to create API tokens in a project (just
having the root permissions to create a client token or frontend token
does not grant access to create a project-specific API token). The
permissions to access the creation of a project-specific API token then
rely on the root permissions to allow the user to create either a client
token or a frontend token.

---------

Co-authored-by: David Leek <david@getunleash.io>
2023-06-23 10:57:08 +02:00
Gastón Fournier
4cedb00e04
fix: fetching user root roles include custom ones (#4068)
## About the changes
`getUserRootRoles` should also consider custom root roles

This introduces test cases that unveiled a dependency between stores
(this happens actually at the DB layer having access-service access
tables from two different stores but skipping the store layer).


https://linear.app/unleash/issue/2-1161/a-user-with-custom-root-role-and-permission-to-create-client-api

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2023-06-22 14:42:01 +00:00
Thomas Heartman
3fb00b281c
fix: disallow empty list of envs and invalid env names in advanced playground (#4060)
This PR changes the OpenAPI schema for the advanced playground to not
accept empty lists of environments and to not accept environment names
that don't match the env name pattern we use.

The pattern is the same as the one we use for controlling environment
names on creation.

However, there is a (small) chance that these may get out of sync later,
so we could do something to only define this pattern once (and import it
in the enterprise package), but that may be more work than is necessary,
and I'd suggest we do that later.

I've also added a minLength to the string items although it isn't
strictly necessary. It's primarily to give the users better feedback if
the name is empty.
2023-06-22 09:01:10 +00:00
Mateusz Kwasniewski
374d49f5bf
feat: ui tweaks for playground (#4058) 2023-06-22 10:13:17 +02:00
Nuno Góis
7e9069e390
refactor: token permissions, drop admin-like permissions (#4050)
https://linear.app/unleash/issue/2-1155/refactor-permissions

- Our `rbac-middleware` now supports multiple OR permissions;
- Drops non-specific permissions (e.g. CRUD API token permissions
without specifying the token type);
- Makes our permission descriptions consistent;
- Drops our higher-level permissions that basically mean ADMIN (e.g.
ADMIN token permissions) in favor of `ADMIN` permission in order to
avoid privilege escalations;

This PR may help with
https://linear.app/unleash/issue/2-1144/discover-potential-privilege-escalations
as it may prevent privilege escalations altogether.

There's some UI permission logic around this, but in the future
https://linear.app/unleash/issue/2-1156/adapt-api-tokens-creation-ui-to-new-permissions
could take it a bit further by adapting the creation of tokens as well.

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-06-22 08:35:54 +01:00
Thomas Heartman
24e9cf7c8f
feat: add "edit" link to playground strategies (#4027)
This change adds an "edit" link to all playground strategies when they
are returned from the API, allowing the user to jump directly to the
evaluated strategy edit screen.

This change applies to both old and new strategies, so it should even
work in the old playground.

This does not use this information in the frontend yet.

## Discussion points:

Should "links" be an object or a singular string? I know the
notifications service uses just "link", but using an object will make
it easier to potentially add more actions in the future (such as
"enable"/"disable", maybe?)

Do we need to supply basePath? I noticed that the notifications links
only ever use an empty string for base path, so it might not be
necessary and can potentially be left out.

## Changes

I've implemented the link building in a new view model file. Inspecting
the output after the result is fully ready requires some gnarly
introspection and mapping, but it's tested.

Further, I've done a little bit of work to stop the playground service
using the schema types directly as the schema types now contain extra
information.

This PR also updates the `urlFriendlyString` arbitrary to not produce
strings that contain only periods. This causes issues when parsing URLs
(and is also something we struggle with in the UI).
2023-06-22 07:19:35 +00:00
Mateusz Kwasniewski
ffed4e78b0
feat: configurable playground limit (#4047) 2023-06-22 08:46:13 +02:00
Tymoteusz Czech
02ca60511f
Splitted strategy button (#4025)
## About the changes

![image](https://github.com/Unleash/unleash/assets/2625371/afaaaedf-4539-4a0b-a0fb-916d858ac6d3)


https://linear.app/unleash/issue/1-1038/strategy-creation-split-into-two-buttons
2023-06-21 15:26:07 +02:00
Jaanus Sellin
71d242a299
chore: remove variant metrics flag (#4042) 2023-06-21 15:55:21 +03:00
Nuno Góis
197df96ff4
fix: consider ADMIN in API tokens fetch permissions (#4032)
https://github.com/Unleash/unleash/pull/4019 introduced a bug where API
token filtering was not taking into account ADMIN permissions, which
means the API tokens were not being displayed on the UI.
2023-06-21 12:12:21 +00:00
Jaanus Sellin
6442a8a386
fix: creating groups should work without users (#4033) 2023-06-21 14:44:43 +03:00
Mateusz Kwasniewski
5b34ceff4c
feat: enable oas by default (#4021) 2023-06-20 15:39:15 +02:00
Thomas Heartman
80a2e1b93f
fix: reject API admin tokens when importing features (#4016)
This PR fixes an issue where trying to use an admin token to import
features via the API resulted in a 500 (due to missing properties).

The solution is to catch when the user is using and admin token in the
controller, throw a 400, and tell them to use personal access tokens or
service accounts.

The PR includes a new test file for this specific use case. We don't
really test these cases many other places, so it seemed the logical
choice.
2023-06-20 12:57:59 +00:00
Mateusz Kwasniewski
a0862cfc10
feat: Query complexity validation (#4017) 2023-06-20 14:28:02 +02:00
Christopher Kolstad
3acb116ab2
feat: Separate api token roles (#4019)
## What
As part of the move to enable custom-root-roles, our permissions model
was found to not be granular enough to allow service accounts to only be
allowed to create read-only tokens (client, frontend), but not be
allowed to create admin tokens to avoid opening up a path for privilege
escalation.

## How
This PR adds 12 new roles, a CRUD set for each of the three token types
(admin, client, frontend). To access the `/api/admin/api-tokens`
endpoints you will still need the existing permission (CREATE_API_TOKEN,
DELETE_API_TOKEN, READ_API_TOKEN, UPDATE_API_TOKEN). Once this PR has
been merged the token type you're modifying will also be checked, so if
you're trying to create a CLIENT api-token, you will need
`CREATE_API_TOKEN` and `CREATE_CLIENT_API_TOKEN` permissions. If the
user performing the create call does not have these two permissions or
the `ADMIN` permission, the creation will be rejected with a `403 -
FORBIDDEN` status.


### Discussion points
The test suite tests all operations using a token with
operation_CLIENT_API_TOKEN permission and verifies that it fails trying
to do any of the operations against FRONTEND and ADMIN tokens. During
development the operation_FRONTEND_API_TOKEN and
operation_ADMIN_API_TOKEN permission has also been tested in the same
way. I wonder if it's worth it to re-add these tests in order to verify
that the permission checker works for all operations, or if this is
enough. Since we're running them using e2e tests, I've removed them for
now, to avoid hogging too much processing time.
2023-06-20 14:21:14 +02:00
Christopher Kolstad
fa081e9014
task: Make keepalive configurable via an environment variable (#4015)
As requested in
[Linear](https://linear.app/unleash/issue/2-1147/unleash-cloud-make-keepalive-configurable)
this PR makes the serverKeepAliveTimeout configurable via the
SERVER_KEEPALIVE_TIMEOUT environment variable. This was already
configurable when starting Unleash programmatically, but it's nice to
have as an env variable as well
2023-06-20 12:10:05 +02:00
Jaanus Sellin
9c8651879f
fix: filter out usage for export (#4006) 2023-06-19 13:42:55 +03:00
Nuno Góis
eb8f16da8d
feat: roles unification (#3999)
https://linear.app/unleash/issue/2-1137/roles-unification-on-the-ui

Root and project roles should be managed in a similar manner, which
means using the same roles route and tab for both.

Additionally, this includes a big revamp to the project roles to align
them more closely with the modern and standardized custom root roles
that were recently developed. They mostly use the same components.

There are still more things we want to improve and unify, but we've left
some of that out of this PR due to PR size concerns.
2023-06-19 09:41:40 +01:00
David Leek
4cc1505308
feat: add support for turning telemetry off with environment variable (#3987)
<!-- 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. -->

Adds an environment variable for switching off feature telemetry in
version check
2023-06-15 15:11:58 +02:00
andreas-unleash
650f6cc857
feat: Advanced playground table (#3978)
<!-- 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! ❤️ -->
Implements the Advanced Playground Table

## 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 #
[1-1007](https://linear.app/unleash/issue/1-1007/env-aware-results-table)

<!-- (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? -->


![Screenshot 2023-06-14 at 15 04
08](https://github.com/Unleash/unleash/assets/104830839/2f76d6f5-f92b-4586-bb4b-265f26eeb836)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-06-15 09:29:31 +00:00
Jaanus Sellin
a066d7888d
feat: add max order to environments (#3988)
Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
2023-06-15 12:21:35 +03:00
Thomas Heartman
2be143a64e
docs: mark 'yes' and no as required, add more details to variants (#3984)
This change adds a little more detail to the client metrics schema. The
description for variants felt a
little unclear.

---------

Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-06-15 07:14:17 +00:00
Nuno Góis
bb026c0ba1
feat: custom root roles (#3975)
## About the changes
Implements custom root roles, encompassing a lot of different areas of
the project, and slightly refactoring the current roles logic. It
includes quite a clean up.

This feature itself is behind a flag: `customRootRoles`

This feature covers root roles in:
 - Users;
 - Service Accounts;
 - Groups;

Apologies in advance. I may have gotten a bit carried away 🙈 

### Roles

We now have a new admin tab called "Roles" where we can see all root
roles and manage custom ones. We are not allowed to edit or remove
*predefined* roles.

![image](https://github.com/Unleash/unleash/assets/14320932/1ad8695c-8c3f-440d-ac32-39746720d588)
This meant slightly pushing away the existing roles to `project-roles`
instead. One idea we want to explore in the future is to unify both
types of roles in the UI instead of having 2 separate tabs. This
includes modernizing project roles to fit more into our current design
and decisions.

Hovering the permissions cell expands detailed information about the
role:

![image](https://github.com/Unleash/unleash/assets/14320932/81c4aae7-8b4d-4cb4-92d1-8f1bc3ef1f2a)

### Create and edit role

Here's how the role form looks like (create / edit):

![image](https://github.com/Unleash/unleash/assets/14320932/85baec29-bb10-48c5-a207-b3e9a8de838a)
Here I categorized permissions so it's easier to visualize and manage
from a UX perspective.

I'm using the same endpoint as before. I tried to unify the logic and
get rid of the `projectRole` specific hooks. What distinguishes custom
root roles from custom project roles is the extra `root-custom` type we
see on the payload. By default we assume `custom` (custom project role)
instead, which should help in terms of backwards compatibility.

### Delete role

When we delete a custom role we try to help the end user make an
informed decision by listing all the entities which currently use this
custom root role:

![image](https://github.com/Unleash/unleash/assets/14320932/352ed529-76be-47a8-88da-5e924fb191d4)
~~As mentioned in the screenshot, when deleting a custom role, we demote
all entities associated with it to the predefined `Viewer` role.~~
**EDIT**: Apparently we currently block this from the API
(access-service deleteRole) with a message:

![image](https://github.com/Unleash/unleash/assets/14320932/82a8e50f-8dc5-4c18-a2ba-54e2ae91b91c)
What should the correct behavior be?

### Role selector

I added a new easy-to-use role selector component that is present in:
 - Users 

![image](https://github.com/Unleash/unleash/assets/14320932/76953139-7fb6-437e-b3fa-ace1d9187674)
 - Service Accounts

![image](https://github.com/Unleash/unleash/assets/14320932/2b80bd55-9abb-4883-b715-15650ae752ea)
- Groups

![image](https://github.com/Unleash/unleash/assets/14320932/ab438f7c-2245-4779-b157-2da1689fe402)

### Role description

I also added a new role description component that you can see below the
dropdown in the selector component, but it's also used to better
describe each role in the respective tables:

![image](https://github.com/Unleash/unleash/assets/14320932/a3eecac1-2a34-4500-a68c-e3f62ebfa782)

I'm not listing all the permissions of predefined roles. Those simply
show the description in the tooltip:

![image](https://github.com/Unleash/unleash/assets/14320932/7e5b2948-45f0-4472-8311-bf533409ba6c)

### Role badge

Groups is a bit different, since it uses a list of cards, so I added yet
another component - Role badge:

![image](https://github.com/Unleash/unleash/assets/14320932/1d62c3db-072a-4c97-b86f-1d8ebdd3523e)

I'm using this same component on the profile tab:

![image](https://github.com/Unleash/unleash/assets/14320932/214272db-a828-444e-8846-4f39b9456bc6)

## Discussion points
- Are we being defensive enough with the use of the flag? Should we
cover more?
 - Are we breaking backwards compatibility in any way?
 - What should we do when removing a role? Block or demote?
- Maybe some existing permission-related issues will surface with this
change: Are we being specific enough with our permissions? A lot of
places are simply checking for `ADMIN`;
- We may want to get rid of the API roles coupling we have with the
users and SAs and instead use the new hooks (e.g. `useRoles`)
explicitly;
 - We should update the docs;
- Maybe we could allow the user to add a custom role directly from the
role selector component;

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-06-14 14:40:40 +01:00
Christopher Kolstad
b8da1ce2a9
docs: OpenAPI Client tag (#3979)
### What
Adds documentation for open api endpoints tagged with `Client`.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-06-14 12:19:00 +00:00
Mateusz Kwasniewski
6ae4fe2085
test: meta schema rules should not check description on ref (#3980) 2023-06-14 12:29:09 +02:00
Mateusz Kwasniewski
8bddbd80f6
feat: advanced playground openapi (#3972) 2023-06-14 11:05:08 +02:00
Mateusz Kwasniewski
edd67f7046
test: advanced playground (#3968) 2023-06-14 08:23:36 +02:00
Gastón Fournier
30b16bef84
chore: set unleash version to be either the enterprise version or OSS (#3974)
## About the changes
Unleash version should be the one best representing its runtime. In this
regard, enterpriseVersion trumps unleash-server version.

This version is the one that's sent as part of our metrics.
2023-06-13 19:39:49 +02:00
David Leek
98d315e062
feat: add instance stats to version check (#3835)
<!-- 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. -->

Adds feature usage info and custom strategy counters to the version
check object.

<!-- 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? -->
2023-06-13 15:54:20 +02:00
Christopher Kolstad
5f3e5729b9
docs: Instance admin (#3961)
### What
Adds the documentation for the instance admin endpoints.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-06-13 12:10:21 +00:00
Mateusz Kwasniewski
555f77463d
feat: draft branch playground evaluation (#3967) 2023-06-13 13:56:26 +02:00
Mateusz Kwasniewski
7d69750f3b
refactor: Extract playground steps (#3966) 2023-06-13 11:26:10 +02:00
Mateusz Kwasniewski
32ae15741c
refactor: read project ids in memory (#3965) 2023-06-13 10:12:14 +02:00
Gastón Fournier
818b8e7813
fix: feature not found in project yields 404 (#3958)
## About the changes
When a feature is not found in a project we should fail with a NotFound
error. If the feature belongs to a different project, it should not be a
permission issue, because the user might not be aware (lack of
permissions/visibility) of that other project, so even in this case the
error should be NotFound (this also works if we ever allow the same
feature name in different projects)

Fixes #3726

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-06-12 15:07:18 +02:00
Christopher Kolstad
7003351b35
docs: Health check endpoint (#3959)
### What
Adds documentation for the health check endpoint.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-06-12 12:56:45 +00:00
Mateusz Kwasniewski
7b8b6bceaf
feat: walking skeleton of the advanced playground (#3949) 2023-06-12 11:01:52 +02:00
Gastón Fournier
4e0678dfb1
fix: allow empty appName as it may come in the url (#3953)
## About the changes
Edit application under
https://app.unleash-hosted.com/demo/applications/test-app is currently
not working as the appName is expected to come in the request body, but
it's actually part of the url. We have two options here:
1. We change the UI to adapt to the expectations of the request by
adding appName to the request body (and eventually removing appName from
the URL, which would be a breaking change)
2. We remove the restriction of only sending the appName in the body and
take the one that comes in the URL. We have a validation that verifies
that at least one of the two sets the appName
([here](e376088668/src/lib/services/client-metrics/instance-service.ts (L208))
we validate using [this
schema](e376088668/src/lib/services/client-metrics/schema.ts (L55-L70)))

In terms of REST API, we can assume that the appName will be present in
the resource `/api/admin/metrics/applications` (an endpoint we don't
have), but when we're updating an application we should refer to that
application by its URL: `/api/admin/metrics/applications/<appName>` and
the presence of an appName in the body might indicate that we're trying
to change the name of the application (something we currently not
support)

Based on the above, I believe going with the second option is best, as
it adheres to REST principles and does not require a breaking change.
Despite that, we only support updating applications as the creation is
done from metrics ingestion

Fixes: #3580
2023-06-12 10:15:00 +02:00
Jaanus Sellin
9f0d94287e
feat: context field usage frontend (#3938) 2023-06-12 10:55:58 +03:00
Ivar Conradi Østhus
1bc130b7f0
fix: add createdAt in projects API response (#3929)
This PR adds the "createdAt" field to the /api/projects response, so
that we are compliant with the schema.
2023-06-09 14:18:38 +00:00
Jaanus Sellin
ea21c753bd
fix: fix variant metrics (#3947) 2023-06-09 12:48:32 +00:00
Mateusz Kwasniewski
0101491a83
refactor: playground in feature oriented architecture (#3942) 2023-06-09 12:55:54 +02:00
Jaanus Sellin
ec6e4d70b5
feat: context field usage backend (#3921) 2023-06-09 12:00:17 +03:00
Thomas Heartman
51d73f67a3
fix: propagate http-errors as they are (#3922)
This PR aims to handle the increased log alarm volume seen by the SREs.

It appears that we get a large number of alarms because a client
disconnects early from the front-end API. These errors are then
converted into 500s because of missing handling. These errors appear to
be caused by the `http-errors` library in a dependency.

We also introduced a log line whenever we see errors now a while back,
and I don't think we need this logging (I was also the one who
introduced it).

The changes in this PR are specifically:
- When converting from arbitrary errors, give `BadRequestError` a 400
status code, not a 500.
- Add a dependency on `http-errors` (which is already a transitive
dependency because of the body parser) and use that to check whether an
error is an http-error.
- If an error is an http error, then propagate it to the user with the
status code and message.
- Remove warning logs when an error occurs. This was introduced to make
it easier to correlate an API error and the logs, but the system hasn't
been set up for that (yet?), so it's just noise now.
- When logging errors as errors, only do that if their status code would
be 500.
2023-06-08 13:14:53 +02:00
Mateusz Kwasniewski
3d344509a8
feat: generate object combinations (#3920) 2023-06-07 15:51:44 +00:00
Thomas Heartman
03dd7b6863
chore: clarify error logs (#3915)
This change makes the logs that happen when we encounter an error a
little bit clearer. It logs the error message before the error ID and
also logs the full serialized message just in case.
2023-06-07 12:11:34 +00:00
Thomas Heartman
24aea5f00e
chore: improve joi errors (#3836)
This PR improves our handling of internal Joi errors, to make them more
sensible to the end user. It does that by providing a better description
of the errors and by telling the user what they value they provided was.

Previous conversion:
```json
{
  "id": "705a8dc0-1198-4894-9015-f1e5b9992b48",
  "name": "BadDataError",
  "message": "\"value\" must contain at least 1 items",
  "details": [
    {
      "message": "\"value\" must contain at least 1 items",
      "description": "\"value\" must contain at least 1 items"
    }
  ]
}
```

New conversion:
```json
{
  "id": "87fb4715-cbdd-48bb-b4d7-d354e7d97380",
  "name": "BadDataError",
  "message": "Request validation failed: your request body contains invalid data. Refer to the `details` list for more information.",
  "details": [
    {
      "description": "\"value\" must contain at least 1 items. You provided [].",
      "message": "\"value\" must contain at least 1 items. You provided []."
    }
  ]
}
```

## Restructuring

This PR moves some code out of `unleash-error.ts` and into a new file.
The purpose of this is twofold:
1. avoid circular dependencies (we need imports from both UnleashError
and BadDataError)
2. carve out a clearer separation of concerns, keeping `unleash-error` a
little more focused.
2023-06-07 08:29:36 +00:00
Thomas Heartman
08834a7250
chore: lower log-level for unexpected errors (#3837)
This change lowers the log level from warning to debug for when we see
unexpected error types.

Right now this triggers for Joi errors, which we still rely on pretty
heavily. Lowering this should clear up logs for most users.
2023-06-07 09:37:40 +02:00
Jaanus Sellin
0efaa346c4
feat: usage on context fields in list (#3906) 2023-06-06 13:59:41 +03:00
Mateusz Kwasniewski
5ec59c6e92
feat: change own password confirmation (#3894) 2023-06-05 11:58:25 +02:00
Mateusz Kwasniewski
b0a003ea58
feat: disable notifications flag (#3874) 2023-05-29 08:28:47 +02:00
Mateusz Kwasniewski
5534e4deeb
fix: remove consecutive slashes (#3882)
A small middleware who will rewrite potential dual slashes to a single slash.
2023-05-27 16:16:51 +00:00
Christopher Kolstad
52904ee038
fix: reject unauthorized client requests (#3881)
If apiTokens are enabled breaks middleware chain with a 401 if no token
is found for requests to client and frontend apis. Previously the
middleware allowed the chain to process.

Removes the regex search for multiple slashes, and instead configures
the apiTokenMiddleware to reject unauthorized requests.
2023-05-27 16:29:54 +02:00
Christopher Kolstad
3d872cf7a2
security: Reject multiple successive slashes in path (#3880) 2023-05-27 14:31:44 +02:00
Jaanus Sellin
f73d36fda3
feat: add usage of segment in list (#3853) 2023-05-26 14:37:00 +03:00
Ivar Conradi Østhus
49722d5c48
fix: use correct event type for maxRevisionId (#3870)
We had a small typo where we looked for `segment-update` event instead
of `segment-updated`. Changed to use the event constant.
2023-05-25 23:00:08 +02:00
Christopher Kolstad
3409b0c5a0
task: Add Unit test result check task (#3695)
After a Team Retro, one of our squads felt like we needed more data on
our test suites. This is the first effort to make our test results
easier to grab. It uses the test-reporter action to add a github check
to our main build and PR builds with our test results.

This at least should make it easier to parse which tests are failing.
However, it does not give us trends. So it does not yet make it easier
to decide which tests are flaky just from a quick view.

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-05-25 11:03:54 +00:00
Mateusz Kwasniewski
78715e3374
docs: maintanance mode impact (#3858) 2023-05-25 08:28:05 +02:00
Mateusz Kwasniewski
5ac575389e
feat: maintenance mode disables scheduler (#3854) 2023-05-24 12:26:54 +02:00
Nuno Góis
ab4ff29407
fix: hide password login when it's disabled (#3851)
https://linear.app/unleash/issue/2-1085/bug-password-based-login-still-shows-on-the-login-page-even-if

Fixes a regression introduced with the changes related with #3633 where
we still show the password login even though it's disabled.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.io>
2023-05-24 09:39:24 +01:00
Nuno Góis
c0bcc50b28
fix: add confirmation to disable password login (#3829)
https://linear.app/unleash/issue/2-1071/prevent-users-from-disabling-password-authentication-when-there-are-no

Improves the behavior of disabling password based login by adding some
relevant information and a confirmation dialog with a warning. This felt
better than trying to disable the toggle, by still allowing the end
users to make the decision, except now it should be a properly informed
decision with confirmation.


![image](https://github.com/Unleash/unleash/assets/14320932/2ca754d8-cfa2-4fda-984d-0c34b89750f3)

- **Password based administrators**: Admin accounts that have a password
set;
- **Other administrators**: Other admin users that do not have a
password. May be SSO, but may also be users that did not set a password
yet;
- **Admin service accounts**: Service accounts that have the admin root
role. Depending on how you're using the SA this may not necessarily mean
locking yourself out of an admin account, especially if you secured its
token beforehand;
- **Admin API tokens**: Similar to the above. If you secured an admin
API token beforehand, you still have access to all features through the
API;

Each one of them link to the respective page inside Unleash (e.g. users
page, service accounts page, tokens page...);

If you try to disable and press "save", and only in that scenario, you
are presented with the following confirmation dialog:


![image](https://github.com/Unleash/unleash/assets/14320932/5ad6d105-ad47-4d31-a1df-04737aed4e00)
2023-05-23 15:56:34 +01:00
Mateusz Kwasniewski
1dba9d092b
fix: move application logic to service (#3846) 2023-05-23 16:41:52 +02:00
Mateusz Kwasniewski
840ca275cf
feat: disable bulk update env var (#3828) 2023-05-22 13:12:45 +00:00
Mateusz Kwasniewski
e34c9bc0bf
feat: disable bulk toggles flag (#3827) 2023-05-22 13:31:31 +02:00
David Leek
485dab87d4
docs: openapi schema specifications for Projects tag (#3571)
<!-- 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. -->

Improves the openapi schema specifications for the schemas belonging to
the "Projects" tag.
Expected error codes/http statues, descriptions, and example data

---------

Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-05-19 09:07:23 +02:00
Mateusz Kwasniewski
f9409fc0e6
feat: transactional bulk update (#3806) 2023-05-19 08:44:17 +02:00
Nuno Góis
4adc977ba0
fix: properly handle flag resolver variants (#3808)
Variants were not being properly handled in the `flag-resolver`: The
fact that the default value of the variant is not falsy made it so we
never asked the external flag resolver for the value.

This also moves the logic from `Variant | undefined` to `Variant` where
we use the `getDefaultVariant()` helper method to return us a [default
variant](55274e4953/src/variant.ts (L37-L42)).
2023-05-18 17:04:55 +01:00
Nuno Góis
db61a8a40c
feat: message banner (variants) (#3788)
-
https://linear.app/unleash/issue/2-546/fetch-the-payload-from-a-real-feature-flag
-
https://linear.app/unleash/issue/2-547/adapt-ui-to-use-the-feature-flag-information-were-fetching

Tackles the 2 tasks above. 

Adapts our `FlagResolver` logic to support variants, so we can use them
for our message banner project but also anything else in the future.
Also adapts MessageBanner to the new logic.

 - Add support for variants in `FlagResolver`;
 - Adapt `MessageBanner` to a variants flag;
 - Adds `sticky` support for the `MessageBanner`;
- Adds our first variants flag to `uiConfig` and `experimental`:
`messageBanner`;
- Adds a `variant-flag-schema` to make it easy to represent the variant
output that we specify in `uiConfig`;
- Adapts `experimental` to be able to represent default variants while
still maintaining type safety;
- Adds helpers to make it easy to use variants in our project, such as
`getVariantValue` and the `useVariant` hook;
 - Adapts and adds new tests in `flag-resolver.test.ts`;
 
### Notes

- ~~The `as PayloadType` assertions need
https://github.com/Unleash/unleash-client-node/pull/454 since it
includes https://github.com/Unleash/unleash-client-node/pull/452~~
(50ccf60893);
 - ~~Enterprise needs a PR that will follow soon~~;
 
 

![image](https://github.com/Unleash/unleash/assets/14320932/034ff64f-3020-4ed0-863b-ed1fd9190430)
2023-05-18 09:38:59 +01:00
Mateusz Kwasniewski
6b41cf03a0
feat: Basic bulk update implementation (#3794) 2023-05-17 12:20:32 +02:00
Mateusz Kwasniewski
45505d6996
feat: create stubs for bulk toggle (#3792) 2023-05-17 10:21:08 +02:00
Simon Hornby
efbec719de
fix: block adding a root role to a group with a project role (#3775) 2023-05-16 12:11:32 +02:00
Mateusz Kwasniewski
d37bb6a790
feat: base path support for openapi (#3780) 2023-05-16 12:01:47 +02:00
Christopher Kolstad
e5e4d52219
fix: anonymise PII fields in user access if flag is set (#3773)
### What
In the demo when listing possible users to grant access to your project,
we inadvertently expose emails when listing users you can grant access
to. This PR anonymises the access list on the way out.
2023-05-15 14:12:03 +02:00
Gastón Fournier
024c6c1990
chore: add additional methods we want exposed (#3771)
## About the changes
These methods are being used externally as part of our enterprise
package
2023-05-15 10:23:28 +00:00
Thomas Heartman
741135a171
fix: add missing options parameter back in (#3770)
This PR adds the missing serialization of the AuthenticationRequired
response back in. It was mistakenly removed in #3633.

This PR also adds another test to verify that it the options property is
present.
2023-05-15 07:19:55 +00:00