Skip to content

Commit

Permalink
Added spring-lnurl-auth-starter & spring-boot-starter-security libs
Browse files Browse the repository at this point in the history
  • Loading branch information
straumat committed Jan 14, 2024
1 parent ca6ca84 commit 90579ad
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
9 changes: 9 additions & 0 deletions backend/servers/explorer-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.github.theborakompanioni</groupId>
<artifactId>spring-lnurl-auth-starter</artifactId>
<version>${bitcoin-spring-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.royllo.explorer.web.configuration;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.stereotype.Controller;
import org.tbk.lnurl.auth.SimpleK1Manager;

/**
* Security configuration.
*/
@Controller
@EnableWebSecurity
@RequiredArgsConstructor
@SuppressWarnings({"checkstyle:DesignForExtension"})
public class SecurityConfiguration {

@Bean
public UserDetailsService userDetailsService() {
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
manager.createUser(User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build());
return manager;
}

@Bean
public SecurityFilterChain filterChain(final HttpSecurity http) throws Exception {
http.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests((authorize) -> authorize
.anyRequest().permitAll()
);
return http.build();
}

/**
* K1 manager.
*
* @return k1 manager
*/
@Bean
SimpleK1Manager k1Manager() {
return new SimpleK1Manager();
}

}
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@

<thymeleaf-layout-dialect.version>3.3.0</thymeleaf-layout-dialect.version>
<htmx-spring-boot-thymeleaf.version>3.2.0</htmx-spring-boot-thymeleaf.version>
<bitcoin-spring-boot-starter.version>0.11.0</bitcoin-spring-boot-starter.version>

<webjars-locator.version>0.50</webjars-locator.version>
<htmx.version>1.9.10</htmx.version>
<alpinejs.version>3.13.3</alpinejs.version>
Expand Down

0 comments on commit 90579ad

Please sign in to comment.