package com.jeeplus.auth.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

@Component
@RefreshScope
@ConfigurationProperties(prefix = "security.oidc")
public class OidcProperties {
    private boolean enabled = false;
    private String issuerUri = "http://127.0.0.1:8180/realms/xg-cloud";
    private String jwkSetUri = "http://127.0.0.1:8180/realms/xg-cloud/protocol/openid-connect/certs";
    private String audience = "xg-cloud-api";
    /**
     * Bootstrap an identity mapping on the first successful Keycloak login by
     * matching preferred_username to an exact login_name in the current tenant.
     * Keep Keycloak self-registration disabled while this option is enabled.
     */
    private boolean autoBindByLoginName = true;

    public boolean isEnabled() { return enabled; }
    public void setEnabled(boolean enabled) { this.enabled = enabled; }
    public String getIssuerUri() { return issuerUri; }
    public void setIssuerUri(String issuerUri) { this.issuerUri = issuerUri; }
    public String getJwkSetUri() { return jwkSetUri; }
    public void setJwkSetUri(String jwkSetUri) { this.jwkSetUri = jwkSetUri; }
    public String getAudience() { return audience; }
    public void setAudience(String audience) { this.audience = audience; }
    public boolean isAutoBindByLoginName() { return autoBindByLoginName; }
    public void setAutoBindByLoginName(boolean autoBindByLoginName) {
        this.autoBindByLoginName = autoBindByLoginName;
    }
}
