feat: make rp id configurable

This commit is contained in:
MiniDigger | Martin 2023-04-08 13:54:32 +02:00
parent b8b322d737
commit 807f5e776c
5 changed files with 13 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package io.papermc.hangar.components.auth.config;
import com.yubico.webauthn.RelyingParty;
import com.yubico.webauthn.data.RelyingPartyIdentity;
import io.papermc.hangar.components.auth.service.WebAuthNService;
import io.papermc.hangar.config.hangar.HangarConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -10,17 +11,18 @@ import org.springframework.context.annotation.Configuration;
public class WebAuthNConfig {
private final WebAuthNService webAuthNService;
private final HangarConfig config;
public WebAuthNConfig(final WebAuthNService webAuthNService) {
public WebAuthNConfig(final WebAuthNService webAuthNService, final HangarConfig config) {
this.webAuthNService = webAuthNService;
this.config = config;
}
@Bean
public RelyingPartyIdentity relyingPartyIdentity() {
// TODO get from config
return RelyingPartyIdentity.builder()
.id("localhost")
.name("Hangar")
.id(this.config.security.rpId())
.name(this.config.security.rpName())
.build();
}

View File

@ -17,7 +17,9 @@ public record HangarSecurityConfig(
String tokenIssuer,
String tokenSecret,
@DurationUnit(ChronoUnit.SECONDS) Duration tokenExpiry,
@DurationUnit(ChronoUnit.DAYS) Duration refreshTokenExpiry
@DurationUnit(ChronoUnit.DAYS) Duration refreshTokenExpiry,
String rpName,
String rpId
) {
public boolean checkSafe(final String url) {

View File

@ -153,6 +153,8 @@ hangar:
token-secret: "secret!"
token-expiry: 300 # seconds
refresh-token-expiry: 30 # days
rp-name: "Hangar"
rp-id: "localhost"
safe-download-hosts:
- "github.com"
- "githubusercontent.com"

View File

@ -52,6 +52,7 @@ stringData:
security:
token-secret: "{{ .Values.backend.config.tokenSecret }}"
rp-id: "{{ .Values.backend.config.rpId }}"
storage:
plugin-upload-dir: "/hangar/uploads"

View File

@ -179,6 +179,7 @@ backend:
database: "hangarauth"
options: "?currentSchema=hangar"
tokenSecret: "secret"
rpId: "localhost"
storage:
type: "local"
accessKey: "todo"