Skip to content

Conversation

kkartunov
Copy link
Contributor

No description provided.


# Gitea Webhook Configuration
GITEA_WEBHOOK_SECRET="your_webhook_secret_here"
GITEA_WEBHOOK_AUTH="your_webhook_secret_here"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming the environment variable GITEA_WEBHOOK_AUTH to something more descriptive if it is intended to store an authentication header value, as AUTH might be too generic and could lead to confusion.

import { WebhookController } from './webhook/webhook.controller';
import { WebhookService } from './webhook/webhook.service';
import { GiteaSignatureGuard } from '../shared/guards/gitea-signature.guard';
import { GiteaWebhookAuthGuard } from '../shared/guards/gitea-webhook-auth.guard';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement has been updated to use GiteaWebhookAuthGuard instead of GiteaSignatureGuard. Ensure that the new guard GiteaWebhookAuthGuard is correctly implemented and provides the necessary functionality that was previously handled by GiteaSignatureGuard. Also, verify that all references to GiteaSignatureGuard in the codebase have been updated accordingly.

WebhookResponseDto,
} from '../../dto/webhook-event.dto';
import { GiteaSignatureGuard } from '../../shared/guards/gitea-signature.guard';
import { GiteaWebhookAuthGuard } from '../../shared/guards/gitea-webhook-auth.guard';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement has been updated to use GiteaWebhookAuthGuard instead of GiteaSignatureGuard. Ensure that the new guard GiteaWebhookAuthGuard is correctly implemented and that all necessary changes in the codebase have been made to accommodate this switch. Verify that the new guard provides the required authentication functionality and that any dependencies or configurations have been updated accordingly.

@kkartunov kkartunov merged commit 963081a into develop Aug 4, 2025
1 check passed

@Injectable()
export class GiteaWebhookAuthGuard implements CanActivate {
private readonly logger = LoggerService.forRoot('GiteaWebhookAuthGuard');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using dependency injection for the LoggerService instead of calling forRoot. This will make the service easier to test and mock.

const authHeader = request.headers['authorization'] as string;

// Check if GITEA_WEBHOOK_AUTH is configured
const auth = process.env.GITEA_WEBHOOK_AUTH;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more secure to use a configuration service or a secrets manager to handle sensitive environment variables like GITEA_WEBHOOK_AUTH instead of accessing them directly from process.env.

throw new BadRequestException('Missing authorization header');
}

if (authHeader !== `Bearer ${auth}`) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more secure method for comparing the authorization header, such as a constant-time comparison function, to prevent timing attacks.

@kkartunov kkartunov deleted the feat/github-webhook branch August 6, 2025 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant