RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-184903

Bleser's questions

Martin Hope
Bleser
Asked: 2024-02-16 22:14:45 +0000 UTC

开放网络分析:打开网站时不发送数据

  • 6

我用 构建了一个 docker 容器owa 1.7.8。
在文件中注册后/etc/hosts 192.168.2.100 space2.local,跟踪的页面将位于该地址。

在设置中owa,我添加了一个条目并将space2.local生成的 JS 代码添加到 html 中。

当您打开页面时,您可以看到脚本已从服务器下载owa,但没有任何反应。
我在页面上添加了几个按钮,但没有任何反应。
统计数据也不显示该页面被访问过。

在我看来,我已经按照文档中所写的那样做了所有事情,但看起来我遗漏了一些东西。

php
  • 1 个回答
  • 15 Views
Martin Hope
Bleser
Asked: 2023-12-03 21:30:06 +0000 UTC

Scala,如果操作的参数类型包含 F[_],则带有 free monad 的代码不会编译

  • 5

我了解 free monad,但如果其中一个类采用,例如fs2.Stream, ,我无法弄清楚如何正确编写代码。

示例代码:

import cats.effect.{Async, IO, IOApp}
import cats.free.Free
import cats.syntax.all._
import cats.{Monad, ~>}
import dev.free.A._

object Example extends IOApp.Simple {
  override def run: IO[Unit] = {
    val stream =
      fs2.Stream.emit[IO, String]("example").through(fs2.text.utf8.encode)
    write("/a/b/c", stream).foldMap(compiler)
  }

  private def compiler: ActionA ~> IO = new (ActionA ~> IO) {
    override def apply[A](fa: ActionA[A]): IO[A] = {
      fa match {
        case Write(path, data) => data.through(fs2.text.utf8.decode).compile.string.flatMap { s =>
          IO.println(s"$path; $s")
        }
      }
    }
  }

}

object A {
  sealed trait ActionA[A]

  case class Write(path: String, data: fs2.Stream[_, Byte]) extends ActionA[Unit]

  type Action[A] = Free[ActionA, A]

  def write(path: String, data: fs2.Stream[_, Byte]): Action[Unit] = Free.liftF[ActionA, Unit](Write(path, data))
}

编译错误:

Example.scala:35:44
_$2 takes no type parameters, expected: 1
  def write(path: String, data: fs2.Stream[_, Byte]): Action[Unit] = Free.liftF[ActionA, Unit](Write(path, data))

fs2.Stream所有问题都是由于没有指定in的效果类型而导致的Write,我不明白如何做到这一点。

scala
  • 1 个回答
  • 16 Views
Martin Hope
Bleser
Asked: 2022-05-04 02:13:33 +0000 UTC

如何在 Gtk4 中获取小部件调整大小通知?

  • 1

我正在尝试Gtk3从Gtk4. 如果早些时候可以轻松连接到信号size_allocate,那么gtk4这个信号被删除了,现在我不知道如何找出小部件何时调整大小。

gtk
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-07-24 19:24:39 +0000 UTC

Scala,将 Map[String, String] 转换为 Map[String, Any]

  • 2

需要转换:

Map(
  "a.b.c" -> "abc",
  "a.b.d" -> "abd"
)

在:

Map(
  "a" -> Map(
    "b" -> Map(
      "c"-> "abc",
      "d" -> "abd"
    )
  )
)

到目前为止,我只能实现以下结构:

List(Map("a" -> Map("b" -> Map("c" -> "abc"))), Map("a" -> Map("b" -> Map("d" -> "abd"))))

但是还没有想法如何将其展平。

UPD:
解决我的问题的答案的略微修改版本。

def go(pairs: Map[Array[String], _]): Map[String, _] = {
    if (pairs.exists(_._1.length == 1)) pairs.map(t => t._1.head -> t._2)
    else {
      pairs
        .groupBy(_._1.head.toString)
        .mapValues { grouped =>
          val woGroupedKey = grouped.map { case (key, value) => key.tail -> value }
          go(woGroupedKey)
        }
    }
  }
scala
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-08-08 18:22:10 +0000 UTC

Scala、Quill:如何通过 DSL 实现嵌套查询

  • 1

需要对 PostgreSQL 进行查询以获取最后状态等于列出的记录之一的记录。
我试图写一个请求,infix但是在指定状态列表时,会出现一个空响应,尽管如果您从日志中获取请求并将其插入数据库控制台,则会出现几条记录。

请求本身如下所示:

SELECT t1.* from table t1
       where 
            t1.status in ('New','Done') and 
            t1.id = (select t2.id from table t2 where t2.name = t1.name order by t2.time desc limit 1)
scala
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-07-06 22:24:18 +0000 UTC

如何正确生成证书以在 nginx 上设置 https?

  • 2

我想创建自己的证书来在nginx上配置https,网上有很多生成证书的例子,我什至在这里找到了这个工具。
问题是当我尝试访问该地址时,我收到来自 Chromium 的错误。

Перейти на сайт example.net невозможно, так как его  
идентификационные данные зашифрованы, и Chrome не может их  
обработать. Это могло произойти из-за ошибки сети или атаки на сайт.  
Скорее всего, он заработает через некоторое время.

我将浏览器中的证书本身添加到“证书颁发机构”,但错误仍然存​​在。

nginx配置文件:

server {
    listen 80;
    return 301 https://$host$request_uri;
}

server {

    listen 443 ssl;
    server_name example.net;

    ssl_certificate           /ssl/cert.crt;
    ssl_certificate_key       /ssl/cert.key;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    access_log            /var/log/nginx/fines-auth.log;

    location /auth {

      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      proxy_pass          http://0.0.0.0:3000;
      proxy_read_timeout  90;

      proxy_redirect      http://0.0.0.0:3000 https://example.net;
}

}

nginx
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-07-03 00:42:04 +0000 UTC

如何在 API 21+ 上检查互联网连接

  • 0

我需要确定设备是否可以访问互联网,并在连接状态发生变化时收到通知。
我已经看到有什么ConnectivityManager.NetworkCallback可以实现通知,但我发现注册它的唯一方法是ConnectivityManager.registerDefaultNetworkCallback添加到 API24。
我怎样才能为 API21+ 实现这个。

更新

我看到ConnectivityManager.NetworkCallback你可以在帮助下注册ConnectivityManager.registerNetworkCallback,我会试试的。

android
  • 2 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-02-12 19:18:03 +0000 UTC

golang, 完成前一个函数后重启一个函数

  • 1

我需要使该功能运行,工作,并在一段时间后重新启动。
我试图像这样实现这个功能:

func timeout(t time.Duration, cmd func()) {
    c := make(chan bool, 1)
    var task = func (){
        cmd()
        time.Sleep(t)
        c <- true
    }
    go task()

    for {
        select {
        case <-c:
            go task()
        }
    }
}

我请您说出此实现的真实性,如果有更正确/最佳的选项,请举例说明。
也可能有一些库允许您实现此行为以在 CRON 上运行。

golang
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-02-08 13:13:10 +0000 UTC

去。多个嵌套函数调用

  • -1

假设有一个字符串 str := " 123455:foofoofoo "需要进行如下处理:

  1. 删除前导和尾随空格
  2. 获取字符“:”后的字符串
  3. 替换所有 foo -> bar

我现在如何执行这些操作:

st := "    123456:foofoofoo      "
repFoo := regexp.MustCompile("foo")
result := repFoo.ReplaceAllString(strings.Split(strings.TrimSpace(st), ":")[1], "bar")
log.Println(result)

我考虑了以下选项:

  1. 每个动作都在一个单独的变量中。
  2. 创建函数以涵盖程序中具有较短名称的字符串的典型操作。
  3. 保持原样

我对如何在更改字符串时更正确地构造代码感兴趣,当需要多次对字符串执行此类操作时?

golang
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-12-16 21:56:29 +0000 UTC

GitHub 和其他类似项目的工作方式

  • 6

项目如何存储在服务器上以及如何使用它们完成工作变得很有趣。
它描述了如何设置你的服务器来存储 git 项目。莫非类似于 GitHub 的服务是按照类似的方案安排的?

我希望有人有关于这个主题的信息或链接。

git
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-11-06 21:43:21 +0000 UTC

Spring Security:DelegatingFilterProxy 溢出堆栈

  • 0

我正在设置 Spring Security 并在配置指定访问某些地址以仅提供授权时遇到问题,您仍然可以在未经授权的情况下访问它们。

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter{

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
        .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and()
                .authorizeRequests()
                .anyRequest().authenticated();
    }
}

@RestController
public class TestController {

    @PostMapping(value = "/test")
    public List<String> postHello(@RequestBody ArrayList<String> strings){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return strings
                .stream()
                .map(s -> "Print "+s)
                .collect(Collectors.toList());
    }

}

使用此配置,我将在请求正文中向http://localhost:8080/test["one","two"]发送请求,我将其放入并期望请求不会通过,因为我在 Spring Security 设置中指定了所有路径必须通过授权检查anyRequest().authenticated()。

浏览谷歌后,我看到问题可能web.xml是没有过滤器设置。

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>
        org.springframework.web.filter.DelegatingFilterProxy
    </filter-class>
    <init-param>
        <param-name>targetBeanName</param-name>
        <param-value>springSecurityFilterChain</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

添加过滤器后,我收到一个错误,即没有这样的 bean springSecurityFilterChain。我要将bean添加到配置中...

<bean 
        id="springSecurityFilterChain" 
        class="org.springframework.web.filter.DelegatingFilterProxy"/>

服务器通常是stratos,但值得发送请求,因为我收到以下错误:

javax.servlet.ServletException: Filter execution threw an exception
java.lang.StackOverflowError
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
...
...

我无法弄清楚我到底做错了什么。也许根本不需要这个过滤器,你只需要调整配置。如果有人已经遇到过这样的问题,我将不胜感激。

build.gradle
application-context.xml
dispatcher-servlet.xml
web.xml

java
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-07-16 23:36:24 +0000 UTC

使用 Google Custom Search API 进行图像搜索

  • 0

我正在制作一个 JavaFX 应用程序,我需要为搜索查询获取图像。您可以通过 google-api-services-customsearch 通过 java 搜索 google,但搜索需要访问令牌和 google api 中的应用程序。

我在 google apis 中创建了一个应用程序,创建时GoogleCredential指定了客户端 ID(其长度为 72 个字符),创建时Customsearch.Builder指定了应用程序的名称appname-143932,但在尝试完成请求后我收到授权错误。

{
  "code" : 401,
  "errors" : [ {
    "domain" : "global",
    "location" : "Authorization",
    "locationType" : "header",
    "message" : "Invalid Credentials",
    "reason" : "authError"
  } ],
  "message" : "Invalid Credentials"
}

完整代码(科特林):

val credential = GoogleCredential().setAccessToken(token)

val customsearch = Customsearch.Builder(NetHttpTransport(), JacksonFactory(), credential)
                .setApplicationName(appName)
                .build()

val list = customsearch.cse().list("image name")
    list.searchType = "image"
    val search = list.execute()
    val items = search.items
    items
            .forEach {
        println(it.displayLink)
    }
java
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-05-19 03:12:08 +0000 UTC

Kotlin如何获取注解中的参数值?

  • 0

我在 Kotlin 中为一个类字段创建了一个注解,该注解将一个字符串作为参数,但我不知道如何使用反射读取该字段上注解参数的值。

рефлексия
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-02-21 00:46:37 +0000 UTC

通过Spring上传文件

  • 0

我有一个开发服务器在 localhost:4200 运行 angular 2,在 localhost:8080 运行 spring tomcat。
我正在尝试通过以下方式将文件上传到服务器:
Angular 代码:

uploadAvatar(file:File){
    let xhr = new XMLHttpRequest()
    xhr.open("POST",`http://localhost:8080/api/upload/avatar`)
    xhr.setRequestHeader("Content-Type","multipart/form-data")
    xhr.send(file)
}

弹簧控制器代码:

@RequestMapping(value = "/api/upload/avatar", method = RequestMethod.POST)
public String uploadFile(MultipartFile file){
    log.info(file);
    return file.getName();
}

但是在java控制台尝试下载文件后,出现错误:

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; 
nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

如何修复此错误?
谢谢你。

java
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-01-22 01:29:26 +0000 UTC

在 Linux 中为 SSD 启用 TRIM 时,文件系统是只读的

  • 0

我在 SSD 上安装了 KDE-neon,在重启后添加选项时discard,fstab系统进入紧急模式。当尝试fstab通过 nano 进行编辑时,它说系统是只读的。
Ubuntu的帮助说discard不再需要添加新的内核版本,TRIM自动启动,是这样吗?
固态硬盘 - 创见 360S [TS128GSSD360S]

linux
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-01-07 23:10:49 +0000 UTC

Spring Security 用户授权

  • 0

我试图弄清楚如何实现授权,我设法做到了,但它只能在浏览器重新启动之前起作用。

我在谷歌上搜索了在单独的服务器上为客户端实现授权的示例,但到处都是与 JSP 相同的文章,最终决定尝试为我自己采用其中一个并实现以下类 UserDetailsService和AuthenticationManager一个授权类AuthenticateService。然后我决定添加rememberm-me功能,在config中添加设置,在数据库中添加了一个表,但是在授权时,没有添加cookie和数据库条目。也许在使用 rememberm-me 时你需要不使用UsernamePasswordAuthenticationToken或添加某种过滤器?所以我想知道应该使用哪些接口\类通过令牌进行授权。

@Component
public class CustomUserDetails implements UserDetailsService {

    @Autowired
    private UserRepo userRepo;


    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        EntityUser user = userRepo.findByUsername(username);
        List<GrantedAuthority> grantedAuthorities =new ArrayList<>();

        for (EntityRole entityRole : user.getRoles()) {
            grantedAuthorities.add(new SimpleGrantedAuthority(entityRole.getRoleName()));
        }

        return new User(user.getUsername(),user.getPassword(),grantedAuthorities);
    }
 }

@Component
public class CustomAuthentivationManager implements AuthenticationManager {

    @Autowired
    private UserRepo userRepo;

    @Autowired
    private CustomUserDetails customUserDetails;


    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        UserDetails userDetails =  (UserDetails) authentication.getPrincipal();
        if (userDetails.getPassword().equals(authentication.getPrincipal())){
            authentication.setAuthenticated(true);
    }
        return authentication;
    }
}

@Service
public class AuthenticateService implements IAuthentivateService {

    @Autowired
    private CustomAuthentivationManager authenticationManager;

    @Autowired
    private CustomUserDetails customUserDetails;


    @Override
    public String findLigInUsername() {
        Object userDetails = SecurityContextHolder.getContext().getAuthentication().getDetails();
        if (userDetails instanceof UserDetails){
            return ((UserDetails) userDetails).getUsername();
        }
        return null;
    }

    @Override
    public boolean autologin(String username, String password) {
        UserDetails userDetails = customUserDetails.loadUserByUsername(username);
        UsernamePasswordAuthenticationToken token
            = new UsernamePasswordAuthenticationToken(userDetails,password,userDetails.getAuthorities());

        authenticationManager.authenticate(token);

        if (token.isAuthenticated()){
            SecurityContextHolder.getContext().setAuthentication(token);
            return true;
        }
        return false;
    }
}
java
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-12-02 15:02:39 +0000 UTC

Angular2+Spring Security CORS 和 CSRF

  • 0

有两台服务器,第一个是 angular url: http://localhost:4200,第二个是带有 Spring Boot url: 的 tomcat http:localhost:8080。

当我尝试发送POST请求时,浏览器说

Запрос из постороннего источника заблокирован: Политика одного источника
запрещает чтение удаленного ресурса на http://localhost:8080/.
(Причина:    отсутствует заголовок CORS «Access-Control-Allow-Origin»).

日志Tomcat

2016-12-02 06:51:10.134 DEBUG 8380 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing OPTIONS request for [/]
2016-12-02 06:51:10.136 DEBUG 8380 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /
2016-12-02 06:51:10.140 DEBUG 8380 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public void org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$EmptyHandler.handle()]
2016-12-02 06:51:10.149 DEBUG 8380 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2016-12-02 06:51:10.149 DEBUG 8380 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2016-12-02 06:51:10.149 DEBUG 8380 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'delegatingApplicationListener'
2016-12-02 06:51:10.150 DEBUG 8380 --- [nio-8080-exec-1] o.s.s.w.a.ExceptionTranslationFilter     : Chain processed normally
2016-12-02 06:51:10.150 DEBUG 8380 --- [nio-8080-exec-1] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@329e259c
2016-12-02 06:51:10.150 DEBUG 8380 --- [nio-8080-exec-1] w.c.HttpSessionSecurityContextRepository : SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
2016-12-02 06:51:10.150 DEBUG 8380 --- [nio-8080-exec-1] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2016-12-02 06:51:10.150 DEBUG 8380 --- [nio-8080-exec-1] o.s.b.w.f.OrderedRequestContextFilter    : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@5dd5a01e
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.b.w.f.OrderedRequestContextFilter    : Bound request context to thread: org.apache.catalina.connector.RequestFacade@5dd5a01e
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/'; against '/css/**'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/'; against '/js/**'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/'; against '/images/**'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/'; against '/webjars/**'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/'; against '/**/favicon.ico'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/'; against '/error'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.security.web.FilterChainProxy        : / at position 1 of 10 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.security.web.FilterChainProxy        : / at position 2 of 10 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] w.c.HttpSessionSecurityContextRepository : No HttpSession currently exists
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] w.c.HttpSessionSecurityContextRepository : No SecurityContext was available from the HttpSession: null. A new one will be created.
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.security.web.FilterChainProxy        : / at position 3 of 10 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2016-12-02 06:51:10.159 DEBUG 8380 --- [nio-8080-exec-2] o.s.security.web.FilterChainProxy        : / at position 4 of 10 in additional filter chain; firing Filter: 'CsrfFilter'
2016-12-02 06:51:10.167 DEBUG 8380 --- [nio-8080-exec-2] o.s.security.web.csrf.CsrfFilter         : Invalid CSRF token found for http://localhost:8080/
2016-12-02 06:51:10.167 DEBUG 8380 --- [nio-8080-exec-2] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@329e259c
2016-12-02 06:51:10.167 DEBUG 8380 --- [nio-8080-exec-2] w.c.HttpSessionSecurityContextRepository : SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
2016-12-02 06:51:10.167 DEBUG 8380 --- [nio-8080-exec-2] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2016-12-02 06:51:10.167 DEBUG 8380 --- [nio-8080-exec-2] o.s.b.w.f.OrderedRequestContextFilter    : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@5dd5a01e
2016-12-02 06:51:10.170 DEBUG 8380 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing POST request for [/error]
2016-12-02 06:51:10.170 DEBUG 8380 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
2016-12-02 06:51:10.171 DEBUG 8380 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)]
2016-12-02 06:51:10.171 DEBUG 8380 --- [nio-8080-exec-2] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'basicErrorController'
2016-12-02 06:51:10.181 DEBUG 8380 --- [nio-8080-exec-2] o.s.c.e.PropertySourcesPropertyResolver  : Found key 'spring.template.provider.cache' in [refresh] with type [String]
2016-12-02 06:51:10.185 DEBUG 8380 --- [nio-8080-exec-2] o.s.c.e.PropertySourcesPropertyResolver  : Found key 'spring.template.provider.cache' in [refresh] with type [String]
2016-12-02 06:51:10.190 DEBUG 8380 --- [nio-8080-exec-2] o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, text/html;q=0.8] based on Accept header types and producible media types [text/html])
2016-12-02 06:51:10.190 DEBUG 8380 --- [nio-8080-exec-2] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'error'
2016-12-02 06:51:10.192 DEBUG 8380 --- [nio-8080-exec-2] o.s.b.f.s.DefaultListableBeanFactory     : Invoking afterPropertiesSet() on bean with name 'error'
2016-12-02 06:51:10.192 DEBUG 8380 --- [nio-8080-exec-2] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView@1fba2013] based on requested media type 'text/html'
2016-12-02 06:51:10.192 DEBUG 8380 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet        : Rendering view [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView@1fba2013] in DispatcherServlet with name 'dispatcherServlet'
2016-12-02 06:51:10.197 DEBUG 8380 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet        : Successfully completed request

如果您需要更多信息,我随时准备提供。


更新 1

CORS原来在config中配置如下:

@Configuration
@EnableWebMvc
public class WebMvcConfigure extends WebMvcConfigurerAdapter {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry
                .addMapping("/**")
                    .allowedOrigins("*");
    }
}

CSRF 的问题可以通过禁用它来部分解决,但在我看来这仍然不是最佳选择。我设法设置了 spring,以便将会话保存到 spring 自动创建的表中,并且为该会话分配了一个 csrf 令牌,该令牌也保存到表中,但只有一个关于添加带有会话 ID 的 cookie 的标题是发送给客户端,并且 csrf 令牌不会发送到任何地方。
以下是清除 cookie 时来自服务器的内容:

Access-Control-Allow-Origin: http://localhost:4200
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Language: ru-RU
Content-Length: 362
Content-Type: text/html;charset=ISO-8859-1
Date: Sat, 24 Dec 2016 20:11:44 GMT
Expires: 0
Pragma: no-cache
Set-Cookie: SESSION=7b4d0509-4cfb-40e0-9484-72abcdfe2375;path=/;Secure;HttpOnly
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
access-control-allow-credentials: true

这是客户端在下一个请求中发送的内容:

Host: localhost:8080
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0)   Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Referer: http://localhost:4200/registration
Content-Length: 69
Origin: http://localhost:4200
Cookie: SESSION=7b4d0509-4cfb-40e0-9484-72abcdfe2375
DNT: 1
Connection: keep-alive

是否值得扩展该类HttpSessionCsrfTokenRepository,以便令牌不仅保存到数据库中,而且还发送到客户端进行保存,或者是否有其他方法可以做到这一点?

typescript
  • 2 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-10-30 18:28:19 +0000 UTC

KDE 5 中用户和 root 的共同主题

  • 1

如何使它在安装主题时适用于所有用户,包括 root?如果您以普通用户身份选择一个主题并打开,例如文件管理器,则不会应用该主题,如果您通过 root 安装该主题,其他用户将看不到它。我试图将主题文件夹放在本地文件夹和系统文件夹中,但它对我没有帮助。

linux
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-10-29 20:46:44 +0000 UTC

Spring Security 中的授权持续时间

  • 0

我在哪里以及如何设置用户在网站上获得授权的时间?现在我的应用程序的工作方式是,如果您登录、关闭浏览器并返回该站点,授权就会消失。

java
  • 1 个回答
  • 10 Views
Martin Hope
Bleser
Asked: 2020-10-16 23:20:15 +0000 UTC

休眠,无法提取结果集

  • 1

出于教育目的,我想编写一个Spring + Hibernate能够授权和发送消息的应用程序。我创建了实体、服务和控制器,但是当我转到选择注册用户列表的起始页时,弹出错误could not extract ResultSet。我的意思是某处有门框,但由于缺乏经验,无法找到它,谷歌也没有提供帮助。

链接到 GitHub
错误日志

java
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5