Commit Graph

175 Commits

Author SHA1 Message Date
Avgustin Marinov
ade5723c8c Remove unused TenantUserPasswordAuthenticationToken (#1966)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
2024-11-08 12:29:19 +02:00
Avgustin Marinov
03baf2a4c2 Remvoe PermissionUtils class (#1965)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
2024-11-08 11:36:16 +02:00
Avgustin Marinov
c69efe65b2 Remove PermissionsUtil (#1964)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
2024-11-08 11:31:09 +02:00
Avgustin Marinov
1c16bd66d3 Code format hawkbit2 (#1949)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-11-05 11:43:54 +02:00
Avgustin Marinov
d842bc2aaa Code format hawkbit (#1948)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-11-05 11:41:56 +02:00
Avgustin Marinov
71aa00ca7c Code format - hawkbit-security-core (#1925)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-11-05 09:21:55 +02:00
Avgustin Marinov
8da475dff0 MDC hanlder refactoring (#1911)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-10-23 09:20:15 +03:00
Avgustin Marinov
12928a5939 Fix/jparolloutshandlerlogging (#1819)
Fix JpaExecutorHandler logging MDC context

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-13 09:30:09 +03:00
Avgustin Marinov
9bb61fd829 Add MDC context in SecurityContdxtTenantAware (#1818)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-13 09:06:53 +03:00
Avgustin Marinov
a99e80b41e MDCHandler - fix sonar findings (#1816)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-12 11:45:35 +03:00
Avgustin Marinov
e10542929a Small code clean-up (#1815)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-12 09:11:19 +03:00
Avgustin Marinov
e9759fecdb Fix MDCHandler unused import (#1814)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-12 08:45:27 +03:00
Avgustin Marinov
e1d928e92e Fix MDCHandler when authentication is null (#1813)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-12 08:43:01 +03:00
Avgustin Marinov
d851fa4d02 Remove hard servlet dependency from SystemSecurityContext (#1812)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-11 10:50:01 +03:00
Avgustin Marinov
e874cf5014 Feature/remove hard requirements for mdc (#1811)
* Remove hard requirements for MDCHandler dependencies

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

---------

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-09 18:12:58 +03:00
Avgustin Marinov
8c2d1037bb Fix Sonar findings (#1810)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-09 17:43:50 +03:00
Avgustin Marinov
9dd493d783 Fix MDCHandler for servlets. Config enable -> enabled (#1808)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-09 16:38:20 +03:00
Avgustin Marinov
141d167a81 Improve MDCHolder method names (#1807)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-09 14:31:14 +03:00
Avgustin Marinov
c8321fdb44 Feature/add tenant and user into mdc (#1806)
* Add MDC

* Add tenant/user into MDC in order to be possible to be used in logging

Enabled by default. Could be disabled via hawkbit.logging.mdchandler.enable=false

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

---------

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-09 14:27:07 +03:00
Avgustin Marinov
bcafdbdb86 Remove contentSecurityPolicy - UI leftover (#1805)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-08-09 08:22:41 +03:00
Avgustin Marinov
6106d3c16c Fix sonar findings (#1792)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-07-29 13:50:42 +03:00
Avgustin Marinov
9cc9b23398 Make noop default password encoder for StaticAuthenticationProvider (#1791)
if no provider is specified for the password

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-07-29 11:51:13 +03:00
Avgustin Marinov
3a34ded4f6 Support for simultaneous base and OAuth authentication (#1785)
* Remove _OidcAuthenticationSuccessHandler_:
  * _OAuth2AuthenticationToken.setDetails_ is made by jwt authentication converter
  * get tenant data (with potentially creating tenant) is done via a filter added in filterChainREST
* _filterChainREST_ uses _Customizer<OAuth2ResourceServerConfigurer<HttpSecurity>>_ as configuration for OAuth. Thus it is not bound with oauth client configuration
* _OidcUserManagementAutoConfiguration_ - now registers (if conditions are met) Customizer<OAuth2ResourceServerConfigurer<HttpSecurity>> which covers both - oauth legacy filter from filterChainREST and OidcBearerTokenAuthenticationFilter
* Since oauth clients are not related to hawkBit anymore (since removal of legacy UI) and the proper configuration would be via resource server or whatever, the _OidcUserManagementAutoConfiguration_ is DEPRECATED and for removal
* _UserAuthenticationFilter_ is removed
* Enabled sumiltaneous base and oauth authentication. Still, by default, if OAuth configured http authentication is disabled. However, if OAuth it is configured (via _Customizer<OAuth2ResourceServerConfigurer<HttpSecurity>>)_ and **hawkbit.server.security.allowHttpBasicOnOAuthEnabled** is set to **true** then http auth would be also enabled
* _OidcUserManagementAutoConfiguration_ could be disabled with **hawkbit.server.security.oAuth2OnClientsConfig.enabled=false**

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-07-26 10:59:15 +03:00
Avgustin Marinov
6b8917e229 Remove MultitenancyIndicator as not used (#1787)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-07-26 09:34:11 +03:00
Avgustin Marinov
6e6f96a0f4 Fix lastModifiedBy on modification perfomed by the JpaRolloutExecutor (#1748)
1. The auditor is got on transaction commit - so haven't used the tenant & user context until now - write system
2. The start/stop/delete are called by the user (saved in lastModifiedBy) but then executed in JpaRolloutExecutor

So the change is:
1. Fix auditor for actions taken by JpaRolloutExecutor to be the createdBy
2. for start/stop/delete the auditor is set to the lastModifiedBy for the transaction (hence all action taken)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-06-21 08:27:24 +03:00
Avgustin Marinov
8d9cfcb17b Remove PermissionService - unused (#1717)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-04-18 12:47:26 +03:00
Avgustin Marinov
1f2dd28ab6 [#1712] Fix READ_TENANT_CONFIGURATION hierarchy and add tests (#1714)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-04-12 17:39:31 +03:00
Avgustin Marinov
3611a8eccd [#1712] Introduce READ_TENANT_CONFIGURATION permission (#1713)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-04-12 14:30:29 +03: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
536bb19382 Add Roles and Hierarchies (#1673)
Adds Roles (SpRole -> TENANT_ADMIN, REPOSITORY_ADMIN, ...) and
intuitive hierarcy rules for them

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-03-01 12:35:40 +02:00
Avgustin Marinov
f45d8f0180 Fix TenantAwareUserProperies (#1672)
Fixed in order to get properties of form hawkbit.security.user.<username>.<property>

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-29 16:03:11 +02:00
Avgustin Marinov
311922c4aa Move static config based auth provider in security-core (#1671)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-29 15:18:44 +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
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
fc561c3eff REST doc / DDI - fix missed info (#1618)
When spring restdoc was replaces with swagger & open api some info was lost
This commit returns back this info for DDI API

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-07 15:36:32 +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
9631292934 Refactoring/Improving source: security core (#1599) (#1600)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 17:03:08 +02:00
Avgustin Marinov
9e31685757 Refactoring/Improving source: security core (#1599)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 16:55:55 +02:00
Avgustin Marinov
ea885d6f61 Improve Security Core with lombok (#1591)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2024-02-03 01:46:22 +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
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
e38303935b Improves address resolution (#1483)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-11-22 10:22:24 +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
Vít Holásek
6428422eed Fixed DataIntegrityViolationException with OIDC (#1348) (#1458)
Signed-off-by: Vít Holásek <xvh@seznam.cz>
2023-11-01 13:10:28 +02:00
Avgustin Marinov
9c86729a68 [#1393,#1008] Switch to Eclipse v2.0 license (#1427)
Switching license from EPL v1 to v2. Following
https://www.eclipse.org/legal/epl-2.0/faq.php#h.tci84nlsqpgw

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
2023-09-14 11:03:20 +03:00
Stanislav Trailov
f0db69473c Enforce decoding in authentication check (#1362)
* Enforce decoding in authentication check
+Enforce decoding of controllerId when authentication is performed for the reverse proxy use case
* Remove unused imports

Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io>

* Switch approach to decode retrieved values from map

Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io>

* Remove unused imports

Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io>

* Style improve

Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io>

* Move logic to separate class

Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io>

* Remove TODO comment

Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io>

* Hide public constructor in Util class

Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io>

---------

Signed-off-by: Stanislav Trailov <stanislav.trailov@bosch.io>
2023-06-01 09:11:39 +02:00
Michael Herdt
06fc4fb6d2 Make exposed CORS headers configurable (#1322)
* Prevent losing headers (like CORS related ones) when resetting the response headers due to artifact stream.

* add comment

* Extend CORS tests to verify provided header.
2023-02-23 14:16:42 +01:00