Coder Social home page Coder Social logo

Comments (5)

TommyYehCool avatar TommyYehCool commented on August 21, 2024 2

I think that I missed the setting, thanks for your help!

from line-bot-sdk-java.

kazuki-ma avatar kazuki-ma commented on August 21, 2024

Thank you for your feedback.
First, could you give me more detail about your propose?

I think you have to hosting "event callback endpoint" and "public resources" in same server
and want to protect your public resources by Spring Security.

Is it right?

from line-bot-sdk-java.

TommyYehCool avatar TommyYehCool commented on August 21, 2024

Yea it is right

from line-bot-sdk-java.

kazuki-ma avatar kazuki-ma commented on August 21, 2024

OK but sorry I can't reproduce your issue.

Please be careful you should security.ignored: /callback.

Could you give me the code to reproduces?

Below is the code for my test.

My java

package com.example.bot.spring.echo;

import java.security.Principal;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.linecorp.bot.model.event.Event;
import com.linecorp.bot.model.event.MessageEvent;
import com.linecorp.bot.model.event.message.TextMessageContent;
import com.linecorp.bot.model.message.TextMessage;
import com.linecorp.bot.spring.boot.annotation.EventMapping;
import com.linecorp.bot.spring.boot.annotation.LineMessageHandler;

import lombok.extern.slf4j.Slf4j;

@SpringBootApplication
@LineMessageHandler
@RestController
@Slf4j
public class EchoApplication extends WebSecurityConfigurerAdapter {
    public static void main(String[] args) {
        SpringApplication.run(EchoApplication.class, args);
    }

    @GetMapping("/")
    public Object whoami(final Principal principal)  {
        return principal;
    }

    @EventMapping
    public TextMessage handleTextMessageEvent(
            final MessageEvent<TextMessageContent> event) {
        return new TextMessage(event.getMessage().getText());
    }

    @EventMapping
    public void handleDefaultMessageEvent(final Event event) {
        log.info("Event: {}", event);
    }
}

application.yml

line.bot:
  channel-secret: MY SECRET
  channel-token: MY TOKEN

security:
  ignored: /callback

from line-bot-sdk-java.

kazuki-ma avatar kazuki-ma commented on August 21, 2024

You are welcome~

from line-bot-sdk-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.