小编Man*_*ani的帖子

Spring Security with session get online users 返回空

有多个版本的相同问题,但似乎没有一个可以解决这个问题。我想从 Spring Security 获得在线用户。我知道我们需要自动装配SessionRegistry并使用它。但是,它仍然不起作用。这是代码。不确定是由于自定义用户名、密码身份验证还是由于自定义密码编码器或其他原因。一切似乎都是正确的。即使获取当前登录用户的数据也能正常工作,但未登录用户列表。

会话安全配置文件

@EnableJpaRepositories(basePackageClasses = UsersRepository.class)
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true)
public class SessionSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private PasswordEncoder passwordencoder;

    @Autowired
    private UserDetailsService userDetailsService;

    @Autowired
    private UsernamePasswordAuthProvider usernamepasswdauth;

    @Bean
    SessionRegistry sessionRegistry() {
        return new SessionRegistryImpl();
    }

    @Override
    protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(usernamepasswdauth).userDetailsService(userDetailsService)
                .passwordEncoder(passwordencoder);
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);
        http.csrf().disable();
        http.authorizeRequests() //
                .antMatchers("/ua/*").permitAll() //
                .antMatchers("/auth/*").authenticated() //
                .and().requestCache() //
                .requestCache(new NullRequestCache());
        http.httpBasic().disable(); …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot

5
推荐指数
1
解决办法
615
查看次数

Rundeck 未为使用不同 ssh 端口的远程执行设置环境变量

Rundeck 将传递给作业的所有选项$RD_OPTION_*设置为环境变量,但当在具有不同 ssh 端口的远程节点中执行作业时,它不会设置这些变量。脚本成功登录到远程节点,但没有环境变量。请帮我解决。

示例作业定义:

<joblist>
  <job>
    <context>
      <options preserveOrder='true'>
        <option name='option1' required='true' />
      </options>
    </context>
    <description>job description</description>
    <dispatch>
      <excludePrecedence>true</excludePrecedence>
      <keepgoing>false</keepgoing>
      <rankOrder>ascending</rankOrder>
      <threadcount>1</threadcount>
    </dispatch>
    <executionEnabled>true</executionEnabled>
    <id>id</id>
    <loglevel>DEBUG</loglevel>
    <name>job name</name>
    <nodefilters>
      <filter>name: remote_node</filter>
    </nodefilters>
    <nodesSelectedByDefault>true</nodesSelectedByDefault>
    <notification>
      <onfailure>
        <email attachLog='true' recipients='abcdef@xyz.com' subject='job failure :(' />
      </onfailure>
      <onsuccess>
        <email recipients='abcdef@xyz.com' subject='job succes' />
      </onsuccess>
    </notification>
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='step-first'>
      <command>
        <exec>python path/to/script.py $RD_OPTION_OPTION1 > /path/to/logfile_$RD_JOB_EXECID.log 2>&1</exec>
      </command>
      <command>
        <exec>java -jar path/to/jarfile.jar ${option.option1} >> "/path/to/logfile_${job.execid}.log" 2>&1</exec>
      </command>
    </sequence>
    <uuid>job-uuid</uuid>
  </job>
</joblist>

<!-- …
Run Code Online (Sandbox Code Playgroud)

automation rundeck

1
推荐指数
1
解决办法
5385
查看次数