Add service credential visibility.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,7 +24,7 @@ import { DomainService } from './domain.service';
|
||||
import { CreateApplicationDto, UpdateApplicationDto, ScaleResourcesDto, SetCustomDomainDto, CheckDnsDto } from './dto/application.dto';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { UserRole, DatabaseType } from '../common/enums';
|
||||
import { UserRole, DatabaseType, ServiceAccessTarget } from '../common/enums';
|
||||
import { KubernetesService } from '../kubernetes/kubernetes.service';
|
||||
import { DeploymentsService } from '../deployments/deployments.service';
|
||||
import { AccessService } from '../access/access.service';
|
||||
@@ -212,6 +212,41 @@ export class ApplicationsController {
|
||||
return this.applicationsService.findAll(search);
|
||||
}
|
||||
|
||||
@Get(':id/service-credentials')
|
||||
@ApiOperation({ summary: 'Get internal credentials for enabled optional services' })
|
||||
async getServiceCredentials(@Param('id') id: string, @Request() req: any) {
|
||||
const app = await this.applicationsService.findOne(id, this.staffUserIdFilter(req));
|
||||
const credentials: Record<string, any> = {};
|
||||
|
||||
if (app.enableRedis) {
|
||||
const redis = await this.kubernetesService.readAccessCredentials(app, ServiceAccessTarget.REDIS);
|
||||
credentials.redis = {
|
||||
host: `${app.name}-redis`,
|
||||
port: 6379,
|
||||
password: redis.password,
|
||||
url: redis.password
|
||||
? `redis://:${redis.password}@${app.name}-redis:6379`
|
||||
: `redis://${app.name}-redis:6379`,
|
||||
};
|
||||
}
|
||||
|
||||
if (app.enableRabbitmq) {
|
||||
const rabbitmq = await this.kubernetesService.readAccessCredentials(app, ServiceAccessTarget.RABBITMQ_AMQP);
|
||||
const username = rabbitmq.username || 'appuser';
|
||||
credentials.rabbitmq = {
|
||||
host: `${app.name}-rabbitmq`,
|
||||
amqpPort: 5672,
|
||||
managementPort: 15672,
|
||||
username,
|
||||
password: rabbitmq.password,
|
||||
amqpUrl: `amqp://${username}:${rabbitmq.password}@${app.name}-rabbitmq:5672`,
|
||||
managementUrl: `http://${app.name}-rabbitmq:15672`,
|
||||
};
|
||||
}
|
||||
|
||||
return credentials;
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Get application details' })
|
||||
async findOne(@Param('id') id: string, @Request() req: any) {
|
||||
|
||||
Reference in New Issue
Block a user