[Java] Introduction of Basic authentication to Heroku [Spring Framework]

less than 1 minute read

Artifacts

Screenshots 2020-06-28 17.22.18.png

Preparation

Heroku Official Documentation

Prepare for Heroku deployment according to the official Heroku documentation in ↑.

pom.xml


...
<packaging>war</packaging>
...
<dependencies>
...
</dependencies>
<build>
    ...
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals><goal>copy</goal></goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.heroku</groupId>
                                <artifactId>webapp-runner</artifactId>
                                <version>9.0.30.0</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

*The project is compiled with war

Procfile


web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT --enable-basic-auth --basic-auth-user [username] --basic-auth-pw [password] target /*.war