Commit Graph

820 Commits

Author SHA1 Message Date
Avgustin Marinov
ce9918ce00 [#1651] Add SoftwareModule and DistributionSet unlock (REST) (#1677)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-03-08 11:28:24 +02:00
Avgustin Marinov
4d104873de [#1651] Add SoftwareModule and DistributionSet unlock (Mgmt) (#1676)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-03-08 09:19:11 +02:00
Avgustin Marinov
1640025a25 Apply role hierarchy in hasPermission checks (#1675)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-03-07 18:52:50 +02:00
Avgustin Marinov
a0db5ff70e Rename UserTenantAware to TenantAwareUser (#1668)
in order to be compatible with other TenantAware entities

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-27 08:43:40 +02:00
Avgustin Marinov
24d70827b7 Improve hawkBit user management (#1666)
1. Definded with properties users (static) are configured using property map (no need of indexes)
2. AuthenticationProvider that authenticates them is always registered (if not needed - don't configure them)
3. UserDetailsService (in case of missing - won't be registered)
4. Spring security user (spring.security.username) will be registered together with other users (if any). If any - it will be system-wide, otherwise tenant-scoped.
5. UserPrincipal renamed to TenantAwareUser in order to match its purpose.
6. Some if its fields are removes as not needed - to be closer to spring security user
7. DefaultRolloutApprovalStrategy now use UserAuthoritiesResolver instead of UserDetailsService as the central point of truth

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-26 16:56:37 +02:00
Avgustin Marinov
ab61b168bd [#1650] Expose externalRef via search filters (#1657)
add option to filter actions using _externalref_ property

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-19 17:23:56 +02:00
Avgustin Marinov
1d981802f4 Remove TestHelper (#1654)
in favor of placing implicitLock helpers into AbstractJpaIntegrationTest
as it is done in rest tests

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-19 14:57:53 +02:00
Avgustin Marinov
9e76223a91 [#1580] Software Module & Distribution Set lock: implicit (#1649)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-18 23:01:55 +02:00
Avgustin Marinov
94576bd6fe [#1580] Software Module & Distribution Set lock: apply (#1648)
forbid software modules / artifacts modification for locked distribution
sets / software modules respectively

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-15 15:56:01 +02:00
Avgustin Marinov
850fa3507f [#1580] Software Module & Distribution Set lock: add lock at rest level (#1646)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-15 11:46:06 +02:00
Avgustin Marinov
e535420065 [#1580] Software Module & Distribution Set lock: add lock at mgmt level (2) (#1645)
* Added to management intefaces (+ tests)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-15 10:35:25 +02:00
Avgustin Marinov
23ad6a140f [#1580] Software Module & Distribution Set lock: add lock at mgmt level (#1644)
Additionally,

* removed DistributionSet.getAutoAssignFilters and
* removed SoftwareModule.getAssignedTo both are not used and exposed via Mgmt API.

Maybe, if needed, they could be returned back along with exposing them via Mgmt API.

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-15 09:20:48 +02:00
Avgustin Marinov
9bc0e74f47 [#1580] Software Module & Distribution Set lock: add lock at db level (#1643)
1. add _locked_ column in the tables
2. add _locked_ field to the JPA entities
3. add lock set/get at JPA level (with lock DS checking for complete)
4. along with that little reordering of code is made to make it more structured

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-14 20:59:34 +02:00
Avgustin Marinov
ab10b67d4e Fix lombok toString to call super where needed (#1634)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-09 13:00:12 +02:00
Avgustin Marinov
c320a45b55 Refactoring/Improving source: dmf 2 (#1612)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-04 11:46:43 +02:00
Avgustin Marinov
f8b1910d02 Refactoring/Improving source: repository 5 (slf4j) (#1605)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 17:58:54 +02:00
Avgustin Marinov
990d1a7545 Refactoring/Improving source: repository 4 (slf4j) (#1604)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 17:50:06 +02:00
Avgustin Marinov
5821c2543c Refactoring/Improving source: repository 3 (slf4j) (#1603)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 17:43:36 +02:00
Avgustin Marinov
ba685ef429 Refactoring/Improving source: repository & fix log() (#1601) (#1602)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 17:25:30 +02:00
Avgustin Marinov
a7f7b0fea8 Refactoring/Improving source: repository & fix log() (#1601)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 17:09:07 +02:00
Avgustin Marinov
24c4cde84e Fix SystemManagementTest.systemUsageReportCollectsActionsOfAllTenants:123 (#1597)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 06:31:26 +02:00
Avgustin Marinov
abbf484fc3 Fix RemoteTenantAwareEventTest (#1596)
* Improve Security Core with lombok 4

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Fix RemoteTenantAwareEventTest

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

---------

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 06:05:30 +02:00
Avgustin Marinov
6d43327e38 Improve Security Core with lombok 4 (#1595)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 05:00:49 +02:00
Avgustin Marinov
f69d386613 Lombok/apply to security repo3 (#1594)
* Improve Security Core with lombok (#1592)

Add lombok to repository modules

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Improve Security Core with lombok 3

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

---------

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 04:46:24 +02:00
Avgustin Marinov
1c5a7bbeb3 Improve Security Core with lombok 2 (#1593)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 03:32:53 +02:00
Avgustin Marinov
d2a740823d Improve Security Core with lombok (#1592)
Add lombok to repository modules

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 02:47:28 +02:00
Avgustin Marinov
791b87b27b Reduce dependency on Guava 2 (#1590)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 00:43:10 +02:00
Avgustin Marinov
bce69676d2 Reduce dependency on Guava (#1589)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-02 22:21:46 +02:00
Avgustin Marinov
fec4c36847 Fix sonar finding (#1578)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-01 08:54:44 +02:00
Avgustin Marinov
537a942021 Made implicit tenant meta data creation configurable (#1575)
In hawkBit up to 0.4.1 it was true - getTenantMetadate created implicitly a tenant metadata.  It was disable in latest commits - but now it is made optional - disabled by default

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-01-30 15:46:39 +02:00
Avgustin Marinov
015bbe7007 Fix flaky RolloutManagementTest (#1570)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-01-27 18:38:37 +02:00
Avgustin Marinov
5592689b62 Add debug log to flaky RolloutManagementFlowTest (#1569)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-01-27 16:08:04 +02:00
Avgustin Marinov
274d0b01fb Fix flaky actions auto cleanup test (#1561)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com
2024-01-23 10:17:36 +02:00
charvadzo
49a5509e89 Enable specifying target type when created using DMF API (#1472)
Extension of DMF API with possibility of setting target
type name when creating target. If a target type with the
provided name is found (was created beforehand) then it
is associated with the new target.

Signed-off-by: Ondrej Charvat <ondrej.charvat@proton.me>
2024-01-22 15:01:00 +02:00
Avgustin Marinov
7440d90f59 [#1383] Spring Boot 3 migration Step 2 (#1559)
* [#1383] Spring Boot 3 migration Step 2

Some of the steps:

1. Change spring version parent and versions in root pom.xml
2. update eclipselink versions
3. javax.annotation -> jakarta.annotation (*.java)
4. javax.persistence -> jakarta.persistence (*.java)
5. javax.servlet -> jakarta.servlet (*.java, pom.xml)
6. javax.validation:validation-api -> jakarta.validation:jakarta.validation-api (pom.xml)
7. javax.validation -> jakarta.validation (*.java)
8. javax.transaction -> jakarta.transaction (*.java)
9. replace spring-cloud-stream-binder-test (hawkbit-repository-test) with
```
<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-stream-test-binder</artifactId>
</dependency>
```
, TestSupportBinderAutoConfiguration.class }) -> })
@Import(TestChannelBinderConfiguration.class)
10. Set to Simple UI standard parent
11. requestMatchers to securityMatcher
12. @SpringBootApplication(scanBasePackages = "org.eclipse.hawkbit") (otherwise for instance flyway doesn't work - suffix is default ".sql", not H2.sql and don't differentiate dbs? strange is there a change?)
13. @NonEmpty for Long leads to validation exception - replaced with @NotNull
14. RSQLUtilityTest.correctRsqlBuildsPredicate - fixed - mock query builder add method
15. https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#spring-mvc-and-webflux-url-matching-changes - aliases as targers/ return 404 - remove trailing slash
16. firewall tests (allowedHostNameWithNotAllowedHost) doesn't throw 'rejected exception' but return 400 instead (as probably is expected anyway)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com

* Fix tenant listing to do not mix with multitenancy

Tenant metadata is not multitenancy aware while depend on distribution set type
which is. Thus querying all tenant metadata (in non tenant context) sometimes leads to
resolution of distribution set type which is tenant scoped and leads to problems.

So, now listing tenant lists just their ids - not fill entities.

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

---------

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-01-20 15:57:17 +02:00
Avgustin Marinov
7768e543fd [#1548] Add support for dynamic rollouts (#1533)
* [#1548] Add support for dynamic rollouts

-- Current status --

Initial draft only !!!, to be improved

TODO:
 * evaluate the target count - if update group/rollout total count fails dynamic updates could (?), actually, contain more targets
 * is it needed to break handler on group creating?
 * if dynamic group schedulers occur to be heavy - maybe a handler per tenant will ensure that one tenant won't break all

*Concept for dynamic groups*:

Rollouts are static and dynamic.
Static rollouts consist of static groups only while dynamic rollouts have a number of static groups (first groups) and then an unlimited number of dynamic groups.

Group targets assignments:
* static groups include ALL matching targets created at the time the rollout was created, nevertheless they have active actions with bigger weight or not. Actions for the rollout and included targeets however are created at the start time.
* dynamic groups however are filled in when started and consider the action weight. The targets included in a dynamic group are:
  * matching (filter and distribution set compatible)
  * not included in this or following rollout static groups (if already included in any of the following rollouts - it's intended to be overridden)
  * not in active actions of any rollouts with equal or bigger weight

In general, when you create a rollout it contains all matching targets available at create time overriding any previous rollouts, actions, and so on. If the rollout is dynamic when its dynamic group becomes running it gets only matching targets that doesn't belong to static groups or have actions with great or equal weight

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* [#1548] Add 1000 weight for actions, rollouts and auto assignments without weight

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

---------

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-01-18 11:37:01 +02:00
Avgustin Marinov
ff015fd0e9 Remove unused test configs (#1540)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-01-11 17:19:35 +02:00
Avgustin Marinov
1ae913e30d Fix Simple UI deploy (#1537)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-01-11 12:25:31 +02:00
Avgustin Marinov
8f8dbb4fa2 Fix sonar finding (#1518)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-12-14 11:06:14 +02:00
Avgustin Marinov
d951cee6b2 [#1509] Sync Target type with SW and DS types / getByKey (Mgmt Layer) (#1516)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-12-13 16:42:10 +02:00
Avgustin Marinov
4ac42c80d7 [#1509] Sync Target type with SW and DS types (targettype.key search) (#1515)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-12-13 16:29:56 +02:00
Avgustin Marinov
767a7e6b11 [#1509] Sync Target type with SW and DS types (REST Layer) (#1514)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-12-13 14:33:32 +02:00
Avgustin Marinov
4b5a7d6e7d [#1509] Sync Target type with SW and DS types (Mgmt Layer) (#1513)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-12-13 11:48:51 +02:00
Avgustin Marinov
71a5319019 [#1509] Sync Target type with SW and DS types (#1512)
Unifies Target type with the other types
* _TargetType_ made to inhert type, thus
* _TargetType_ now has immutable _key_
* add _AbstractJpaTypeEntity_ abstraction that implement the common 'type' JPA functionallity

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-12-12 15:24:57 +02:00
Avgustin Marinov
1ae72d4ead Remove WithSpringContextRule (#1505)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-12-07 23:52:23 +02:00
Avgustin Marinov
aa1bad91e1 Add @PreAuthorize enabled check for applications (#1503)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-12-07 22:23:40 +02:00
Michael Herdt
960ab6872d Extend access control management (#1493)
* Fix ACM related executions.

* Introduce access controller for actions. Resolve some todos and fix distribution set invalidation strategy.

* Do only check for access if returned values are access controlled.

* Fix review findings.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.com>

---------

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.com>
2023-12-01 08:50:41 +02:00
Michael Herdt
178b193162 Do not send DistributionSetDeletedEvent twice (#1478) 2023-11-17 11:40:16 +02:00
Avgustin Marinov
0021b03c9a CI friendly maven poms - use $revision for version (#1477)
https://maven.apache.org/maven-ci-friendly.html

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-11-16 17:23:01 +02:00
Avgustin Marinov
b982039a74 Feature/ctx aware and access controller2 (#1456)
* Introduce the AccessControlManager and use if for the TargetManagement and TargetTypeManagement.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Extend the access control manager by an API to serialize the current active context and persist it for scheduled background operations like auto-assignment.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Verify modification is permitted before performing automatic assignment

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Start with controlling distribution set type access. Perform some refactoring.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Support distribution set access control. Increase character limit to 512 chars for access control context. Refactor default implementations.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Introduce ContextRunner and define admin execution to check for duplicates before creating/updating entities.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Introduce Software Module, Module Type and Artifact control management. Fix tests.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Introduce access controlling test base. Add first test verifying the read operations for target types.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Finalize target type access controlling test.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Introduce ContextRunnerTest and TargetAccessControllingTest.
Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Introduce DistributionSetAccessControllingTest and fix missing access control specifications.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Extend test cases. Include only updatable targets into rollout.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Fix action visibility.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Modifiable->Updatable & UPDATE check where needed

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* ContextRunner superseded by ContextAware

+ ContextRunner remaned to ContextAware (move as a cenral entry/concept).
  It now extends (and replace) TenantAware
+ SecurityContextTenantAware becomes ContextAware
+ Pluggable serialization mechanism
  (default Java serialization of contexts) for SecurityContextTenantAware
  (using SecurityContextSerializer)
+ AccessControl methods are added to ensure no entities fill be retrieved
  just to call access control - so, if all permitted - no additional db
  queries will be made
+ &lt;repo type&gt;AccessControl classes removed and replaced with
  AccessControl &lt;repo type&gt; generics
+ AccessControlService removed - every AccessControl is registered and
  overiden independently
+ access_control_context in DB increased to 4k (in order to support java
  security context serialization)
+ needed adaptaion of implemtation and tests done

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Refactor SoftModules & DistSets

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Refactoring of the Repositories

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Repostiotory level permissions

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Improvements

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Simplification of AccessControl interface

* Simplifications & management package

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

* Implementation improvements

+ Artifact management & repo reviewed and tuned
+ Action(Status) management & repo reviewed and tuned
+ SoftwareModule(Type/Meta) management & repo reviewed and tuned
+ DistributionSet(Type/Tag/Meta) management(+Invalidation) & repo reviewed and tuned
+ Target(Tag/Type/Meta) management & repo reviewed and tuned
+ TargetQueryFilter management & repo reviewed and tuned

* Apply suggestions from code review

Suggestions accepted. Thanks @herdt-michael

Co-authored-by: Michael Herdt <michael.herdt@bosch.com>

* Apply suggestions from code review 2

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>

---------

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
Co-authored-by: Michael Herdt <Michael.Herdt@bosch.com>
2023-11-16 11:07:06 +02:00