Skip to content

Spring Boot - CSRF headers #495

@Oddisey

Description

@Oddisey

I am receiving a CSRF token from my backend, putting the CSRF in local storage and then adding that CSRF manually to the headers in the "watch" when I am trying to subscribe to a topic (see below)

        this.authenticationService.csrf().pipe(
            tap((csrf: Csrf) => {
                const connectHeaders = {};
                connectHeaders[csrf.headerName] = csrf.token;
                this.rxStompService.watch("/topic/notify", connectHeaders).subscribe((message: Message) => {
                    console.log(JSON.parse(message.body));
                });
            })
        );

My issue is that I am not seeing the CSRF token in the headers. How do I add the CSRF token to the socket connection so that it is sent over in the handshake headers the same way that it is sent over in the an http call.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions