Merge pull request #323 from adityachandelgit/develop
Merge Develop into Master for Release
This commit is contained in:
@@ -113,18 +113,17 @@ While the integration has been tested with **Authentik**, it should work with ot
|
||||
For detailed instructions on setting up OIDC authentication with **Authentik**, refer to the [YouTube guide on configuring OIDC in BookLore](https://www.youtube.com/watch?v=r6Ufh9ldF9M), which provides step-by-step walkthroughs.
|
||||
|
||||
|
||||
## 🔧 Configuration
|
||||
## 🔐 Remote Authentication (Trusted Header SSO, Forward Auth)
|
||||
|
||||
The following environment variables can be configured:
|
||||
If you run BookLore behind a reverse proxy with remote authentication (middleware),
|
||||
you can enable automatic login by setting `REMOTE_AUTH_ENABLED` to `true`.
|
||||
|
||||
This allows you to use your existing authentication system (e.g., OAuth, SAML) to log in to BookLore.
|
||||
|
||||
The following remote auth environment variables can be configured:
|
||||
|
||||
| Variable Name | Description | Default Value |
|
||||
|------------------------------|-----------------------------------------|---------------------------------------------------------------------|
|
||||
| DATABASE_URL | JDBC connection URL | `jdbc:mariadb://${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}` |
|
||||
| DATABASE_HOST | Database hostname | `mariadb` |
|
||||
| DATABASE_PORT | Database port | `3306` |
|
||||
| DATABASE_NAME | Database name | `booklore` |
|
||||
| DATABASE_USERNAME | Database username for app | `root` |
|
||||
| DATABASE_PASSWORD | Database password for app | **required** |
|
||||
| REMOTE_AUTH_ENABLED | Enable remote authentication | `false` |
|
||||
| REMOTE_AUTH_CREATE_NEW_USERS | Auto-create users from remote auth | `true` |
|
||||
| REMOTE_AUTH_HEADER_NAME | HTTP header containing user's name | `Remote-Name` |
|
||||
@@ -132,15 +131,6 @@ The following environment variables can be configured:
|
||||
| REMOTE_AUTH_HEADER_EMAIL | HTTP header containing user's email | `Remote-Email` |
|
||||
| REMOTE_AUTH_HEADER_GROUPS | HTTP header containing user's groups | `Remote-Groups` |
|
||||
| REMOTE_AUTH_ADMIN_GROUP | Group name that grants admin privileges | - |
|
||||
| LOG_LEVEL | Log level for the application | `INFO` |
|
||||
| ROOT_LOG_LEVEL | If you want to see all Spring logs | `INFO` |
|
||||
|
||||
### Remote Authentication (Trusted Header SSO, Forward Auth)
|
||||
|
||||
If you run BookLore behind a reverse proxy with remote authentication (middleware),
|
||||
you can enable automatic login by setting `REMOTE_AUTH_ENABLED` to `true`.
|
||||
|
||||
This allows you to use your existing authentication system (e.g., OAuth, SAML) to log in to BookLore.
|
||||
|
||||
Example implementations:
|
||||
- https://www.authelia.com/integration/trusted-header-sso/introduction/
|
||||
|
||||
+12
-1
@@ -60,6 +60,14 @@ public class DualJwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
String token = extractToken(request);
|
||||
|
||||
String path = request.getRequestURI();
|
||||
|
||||
if (path.equals("/api/v1/auth/refresh")) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (token == null) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
@@ -70,11 +78,14 @@ public class DualJwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
} else if (appSettingService.getAppSettings().isOidcEnabled()) {
|
||||
authenticateOidcUser(token, request);
|
||||
} else {
|
||||
log.debug("OIDC is disabled. Skipping OIDC authentication.");
|
||||
log.debug("OIDC is disabled and token is invalid. Rejecting request.");
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("Authentication error: {}", ex.getMessage(), ex);
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
-1
@@ -55,7 +55,6 @@ public class SecurityConfig {
|
||||
).permitAll()
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.httpBasic(customizer -> customizer.realmName("Booklore OPDS"))
|
||||
.addFilterBefore(dualJwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
return http.build();
|
||||
|
||||
@@ -33,7 +33,7 @@ public enum ApiError {
|
||||
USERNAME_ALREADY_TAKEN(HttpStatus.BAD_REQUEST, "Username already taken: %s"),
|
||||
USER_NOT_FOUND(HttpStatus.BAD_REQUEST, "User not found: %s"),
|
||||
CANNOT_DELETE_ADMIN(HttpStatus.FORBIDDEN, "Admin user cannot be deleted"),
|
||||
UNAUTHORIZED(HttpStatus.FORBIDDEN, "%s"),
|
||||
UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "%s"),
|
||||
BAD_REQUEST(HttpStatus.BAD_REQUEST, "%s"),
|
||||
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "%s"),
|
||||
PASSWORD_INCORRECT(HttpStatus.BAD_REQUEST, "Incorrect current password"),
|
||||
|
||||
@@ -16,6 +16,7 @@ public class EmailProvider {
|
||||
private Integer port;
|
||||
private String username;
|
||||
private String password;
|
||||
private String fromAddress;
|
||||
private Boolean auth;
|
||||
private Boolean startTls;
|
||||
private Boolean defaultProvider;
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ public class CreateEmailProviderRequest {
|
||||
private Integer port;
|
||||
private String username;
|
||||
private String password;
|
||||
private String fromAddress;
|
||||
private Boolean auth;
|
||||
private Boolean startTls;
|
||||
}
|
||||
|
||||
+3
@@ -31,6 +31,9 @@ public class EmailProviderEntity {
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
@Column(name = "from_address")
|
||||
private String fromAddress;
|
||||
|
||||
@Column(name = "auth", nullable = false)
|
||||
private boolean auth;
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -73,7 +74,7 @@ public class EmailService {
|
||||
JavaMailSenderImpl dynamicMailSender = setupMailSender(emailProvider);
|
||||
MimeMessage message = dynamicMailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
||||
helper.setFrom(emailProvider.getUsername());
|
||||
helper.setFrom(StringUtils.firstNonEmpty(emailProvider.getFromAddress(), emailProvider.getUsername()));
|
||||
helper.setTo(recipientEmail);
|
||||
helper.setSubject("Your Book from Booklore: " + book.getMetadata().getTitle());
|
||||
helper.setText(generateEmailBody(book.getMetadata().getTitle()));
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
${AnsiColor.BLUE}
|
||||
▀█████████▄ ▄██████▄ ▄██████▄ ▄█ ▄█▄ ▄█ ▄██████▄ ▄████████ ▄████████
|
||||
███ ███ ███ ███ ███ ███ ███ ▄███▀ ███ ███ ███ ███ ███ ███ ███
|
||||
███ ███ ███ ███ ███ ███ ███▐██▀ ███ ███ ███ ███ ███ ███ █▀
|
||||
▄███▄▄▄██▀ ███ ███ ███ ███ ▄█████▀ ███ ███ ███ ▄███▄▄▄▄██▀ ▄███▄▄▄
|
||||
▀▀███▀▀▀██▄ ███ ███ ███ ███ ▀▀█████▄ ███ ███ ███ ▀▀███▀▀▀▀▀ ▀▀███▀▀▀
|
||||
███ ██▄ ███ ███ ███ ███ ███▐██▄ ███ ███ ███ ▀███████████ ███ █▄
|
||||
███ ███ ███ ███ ███ ███ ███ ▀███▄ ███▌ ▄ ███ ███ ███ ███ ███ ███
|
||||
▄█████████▀ ▀██████▀ ▀██████▀ ███ ▀█▀ █████▄▄██ ▀██████▀ ███ ███ ██████████
|
||||
▀ ▀ ███ ███ (${app.version})
|
||||
${AnsiStyle.NORMAL}
|
||||
Powered By Spring Boot : ${spring-boot.version}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE email_provider
|
||||
ADD COLUMN from_address VARCHAR(255) NULL AFTER password;
|
||||
@@ -41,7 +41,7 @@ export class BookSenderComponent implements OnInit {
|
||||
this.emailProviderService.getEmailProviders().subscribe({
|
||||
next: (emailProviders: EmailProvider[]) => {
|
||||
this.emailProviders = emailProviders.map(provider => ({
|
||||
label: `${provider.name} | ${provider.host}`,
|
||||
label: `${provider.name} | ${provider.fromAddress || provider.host}`,
|
||||
value: provider
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
private trackProgress(): void {
|
||||
if (!this.book || !this.rendition) return;
|
||||
this.rendition.on('relocated', (location: any) => {
|
||||
const cfi = location.start.cfi;
|
||||
const cfi = location.end.cfi;
|
||||
const currentIndex = location.start.index;
|
||||
const totalSpineItems = this.book.spine.items.length;
|
||||
let percentage: number;
|
||||
|
||||
+2
@@ -42,6 +42,7 @@
|
||||
<ng-container *ngIf="metadata.amazonRating || metadata.goodreadsRating; else legacyRating">
|
||||
<p *ngIf="metadata.amazonRating" class="font-semibold">Amazon: {{ metadata.amazonRating }}</p>
|
||||
<p-rating
|
||||
*ngIf="metadata.amazonRating"
|
||||
[(ngModel)]="metadata.amazonRating"
|
||||
readonly
|
||||
stars="5"
|
||||
@@ -53,6 +54,7 @@
|
||||
|
||||
<p *ngIf="metadata.goodreadsRating" class="font-semibold">Goodreads: {{ metadata.goodreadsRating }}</p>
|
||||
<p-rating
|
||||
*ngIf="metadata.goodreadsRating"
|
||||
[(ngModel)]="metadata.goodreadsRating"
|
||||
readonly
|
||||
stars="5"
|
||||
|
||||
+5
@@ -34,6 +34,11 @@
|
||||
<input type="password" pInputText formControlName="password" placeholder="Enter password..." class="w-full md:w-80"/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="w-40 text-right font-medium">From Address:</label>
|
||||
<input type="text" pInputText formControlName="fromAddress" placeholder="Enter from address... " class="w-full md:w-80"/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="w-40 text-right font-medium">Auth:</label>
|
||||
<p-checkbox formControlName="auth" [binary]="true"></p-checkbox>
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ export class CreateEmailProviderDialogComponent implements OnInit {
|
||||
port: [null, [Validators.required, Validators.min(1)]],
|
||||
username: [''],
|
||||
password: [''],
|
||||
fromAddress: ['', [Validators.email]],
|
||||
auth: [false],
|
||||
startTls: [false]
|
||||
});
|
||||
|
||||
@@ -12,16 +12,17 @@
|
||||
<p-table [value]="emailProviders">
|
||||
<ng-template pTemplate="header">
|
||||
<tr>
|
||||
<th style="width: 5%;">Default</th>
|
||||
<th style="width: 15%;">Name</th>
|
||||
<th style="width: 6%;">Default</th>
|
||||
<th style="width: 10%;">Name</th>
|
||||
<th style="width: 15%;">Host</th>
|
||||
<th style="width: 10%;">Port</th>
|
||||
<th style="width: 15%;">Username</th>
|
||||
<th style="width: 15%;">Password</th>
|
||||
<th style="width: 6%;">Port</th>
|
||||
<th style="width: 14%;">Username</th>
|
||||
<th style="width: 12%;">Password</th>
|
||||
<th style="width: 12%;">From Address</th>
|
||||
<th style="width: 5%;">Auth</th>
|
||||
<th style="width: 5%;">StartTLS</th>
|
||||
<th style="width: 10%;">Edit</th>
|
||||
<th style="width: 10%;">Delete</th>
|
||||
<th style="width: 7%;">Edit</th>
|
||||
<th style="width: 8%;">Delete</th>
|
||||
</tr>
|
||||
</ng-template>
|
||||
|
||||
@@ -61,6 +62,11 @@
|
||||
<span *ngIf="!provider.isEditing" class="text-gray-400 italic">Hidden</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<input *ngIf="provider.isEditing" type="text" [(ngModel)]="provider.fromAddress" class="p-inputtext w-full"/>
|
||||
<span *ngIf="!provider.isEditing">{{ provider.fromAddress }}</span>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<p-checkbox
|
||||
[(ngModel)]="provider.auth"
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface EmailProvider {
|
||||
port: number;
|
||||
username: string;
|
||||
password: string;
|
||||
fromAddress: string;
|
||||
auth: boolean;
|
||||
startTls: boolean;
|
||||
defaultProvider: boolean;
|
||||
|
||||
Reference in New Issue
Block a user