package kr.co.vividnext.sodalive.configs import com.google.auth.oauth2.GoogleCredentials import com.google.firebase.FirebaseApp import com.google.firebase.FirebaseOptions import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.context.annotation.Configuration import java.io.FileInputStream import javax.annotation.PostConstruct @Configuration @ConditionalOnProperty(name = ["firebase.enabled"], havingValue = "true", matchIfMissing = true) class FirebaseConfig( @Value("\${firebase.secret-key-path}") private val secretKeyPath: String ) { @PostConstruct fun initialize() { FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(FileInputStream(secretKeyPath))) .build() FirebaseApp.initializeApp() } }