Commit 0a57fe6
BasicAuth: Tutorial Refactoring (#2735)
* Add security enhancements and improve utility handling in authentication workflow
- Introduced `AlgoSalt` record for streamlined password hashing and salt handling.
- Refactored `JdbcUserDataProvider` and `StaticUserDataProvider` to utilize enhanced hashing mechanisms.
- Added comprehensive unit tests for new password hashing, salt extraction, and validation logic in `SecurityUtilsTest`.
- Included a new tutorial class `BasicAuthenticationTutorialTest` for basic authentication scenarios with YAML configuration.
* Refactor `JdbcUserDataProvider`: streamline SQL handling and improve logging
* Add tests for `FileUserDataProvider` and refine user verification logic
- Introduced comprehensive unit tests for `FileUserDataProvider` covering initialization, malformed inputs, empty files, and user verification.
- Refactored user splitting logic to limit splits, fixing issues with passwords containing colons.
- Improved exception handling for invalid file paths and malformed user entries.
- Documented current behavior for handling colon usage in hashed passwords.
* Enhance authentication handling: refine input sanitization, fix hash splitting, and add tests
- Improved sanitization logic in `JdbcUserDataProvider` for table/column names using regex validation.
- Fixed hash handling in `SecurityUtils` to enforce correct format and refine error messages.
- Resolved colon splitting issue in `FileUserDataProviderTest` for hashed passwords.
- Added extensive unit tests for `JdbcUserDataProvider` to verify initialization, input sanitization, and user verification scenarios.
- Refactored `StaticUserDataProvider` to prevent redundant map population in `init` method.
* Remove redundant `throws SQLException` declarations and streamline SQL handling in `JdbcUserDataProviderTest`.
* Enhance authentication workflow: add `BasicAuthenticationUtil`, streamline user attribute filtering, and improve test coverage
- Introduced `BasicAuthenticationUtil` for extracting and handling Basic authentication credentials.
- Refactored `StaticUserDataProvider` to use a common `filterPassword` method for secure user attribute handling.
- Enhanced `JdbcUserDataProvider` for safer bean initialization with null checks and better error messages.
- Expanded test coverage with detailed tests for `BasicAuthenticationUtil` and user attribute filtering.
- Improved robustness and maintainability of authentication components.
* Refactor authentication workflow: replace `User` with `UserConfig`, centralize user attribute handling, and update tests
* Refactor authentication workflow: remove redundant code, improve initialization and error handling, and update tests
* Enhance `BasicAuthenticationInterceptor`: remove `Authorization` header by default after authentication, add configurability, and update tests
* Refactor `StaticUserDataProvider`: simplify `usersByName` population logic and remove redundant `getUsersByName` calls
* Fix JavaDoc formatting in `BasicAuthenticationInterceptor`: close `<p>` tag correctly
* Enhance `BasicAuthenticationInterceptor`: improve logging, update user count display, and refine response headers for compliance
* Enhance `BasicAuthenticationInterceptor`: improve logging, update user count display, and refine response headers for compliance
* Update `BasicAuthenticationUtilTest`: mask sensitive information in `toString` and add assertion to verify it's not exposed
* Refactor OAuth2 and authentication session logic: improve code readability by using `var`, remove unnecessary password filtering, update test methods, and streamline imports.
* Remove redundant password assertion in `FileUserDataProviderTest`
* resolved a few comments
* add comment
* added support for argon2id
* fixed merge error
* Refactor `FileUserDataProvider` to rename `htpasswdPath` methods to `location`. Update related test cases accordingly.
* Rename `location` methods to `htpasswdPath` in `FileUserDataProviderElement` and update test case.
* fix
---------
Co-authored-by: Tobias Polley <mail@tobias-polley.de>
Co-authored-by: Tobias Polley <polley@predic8.de>
Co-authored-by: Christian Gördes <christian.goerdes@outlook.de>
Co-authored-by: Christian Gördes <118011644+christiangoerdes@users.noreply.github.com>1 parent 789e26c commit 0a57fe6
30 files changed
Lines changed: 2723 additions & 372 deletions
File tree
- annot/src/main/java/com/predic8/membrane/annot/generator
- core/src
- main/java/com/predic8/membrane/core
- cli
- exceptions
- http
- interceptor/authentication
- session
- util
- security
- test/java/com/predic8/membrane
- core
- interceptor
- authentication
- session
- oauth2
- kubernetes
- openapi/validators/security
- util
- security
- integration/withoutinternet/interceptor/oauth2
- distribution
- src/test/java/com/predic8/membrane/tutorials/security
- tutorials/security
- docs
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
72 | 81 | | |
73 | 82 | | |
74 | 83 | | |
| |||
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
81 | 91 | | |
82 | 92 | | |
83 | 93 | | |
| |||
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
98 | 141 | | |
99 | 142 | | |
100 | 143 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
380 | 384 | | |
381 | 385 | | |
382 | 386 | | |
| |||
0 commit comments