am working on a nest project and am trying to handle authentication using keycloack and i did connect my app to keycloack service
KeycloakConnectModule.register({
authServerUrl: 'http://localhost:8080/auth',
realm: 'demo',
clientId: 'nest-app',
secret: 'c3e273bc-3286-44a6-bc21-82195718f0fb',
// Secret key of the client taken from keycloak server
}),
and i did use the decorators and they did work fine
@Controller()
export class UserController {
constructor(private readonly userService: UserService) {}
@Get('/public')
@Unprotected()
getpublic(): string {
return `${this.userService.getHello()} from public`;
}
@Get('/user')
@Roles('user')
getUser(): string {
return `${this.userService.getHello()} from user`;
}
@Get('/admin')
@Roles('admin')
getAdmin(): string {
return `${this.userService.getHello()} from admin`;
}
@Get('/all')
@AllowAnyRole()
getAll(): string {
return `${this.userService.getHello()} from all`;
}
}
now am wondering how to login and register a user from the nestjs server i did look and i did find that i can inject the
constructor(
@Inject(KEYCLOAK_INSTANCE) private keycloak: any,
) {}
now how am suppose to use that because theres no documentation on how to use the service and theres no autocomplete when i do
this.keycloack.login() // for example
can you help please ?