mirror of
https://github.com/immich-app/immich
synced 2026-08-29 13:15:45 +00:00
feat: yucca integration
This commit is contained in:
parent
8454cb2631
commit
77f9e87bd3
102 changed files with 11198 additions and 164 deletions
23
server/src/middleware/yucca-admin.guard.ts
Normal file
23
server/src/middleware/yucca-admin.guard.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
|
||||
import { AuthRequest } from 'src/middleware/auth.guard';
|
||||
import { AuthService } from 'src/services/auth.service';
|
||||
|
||||
@Injectable()
|
||||
export class YuccaAdminGuard implements CanActivate {
|
||||
constructor(private authService: AuthService) {}
|
||||
|
||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
const request = context.switchToHttp().getRequest<AuthRequest>();
|
||||
if (!request.path.startsWith('/api/yucca')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
request.user = await this.authService.authenticate({
|
||||
headers: request.headers,
|
||||
queryParams: request.query as Record<string, string>,
|
||||
metadata: { adminRoute: true, sharedLinkRoute: false, uri: request.path },
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue