make it secure
This commit is contained in:
parent
809e045c0b
commit
677269d4fc
1 changed files with 15 additions and 0 deletions
|
@ -1,20 +1,35 @@
|
||||||
package eu.m724;
|
package eu.m724;
|
||||||
|
|
||||||
import eu.m724.orm.Token;
|
import eu.m724.orm.Token;
|
||||||
|
import io.quarkus.runtime.LaunchMode;
|
||||||
import io.quarkus.runtime.StartupEvent;
|
import io.quarkus.runtime.StartupEvent;
|
||||||
import jakarta.enterprise.event.Observes;
|
import jakarta.enterprise.event.Observes;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
import jakarta.inject.Singleton;
|
import jakarta.inject.Singleton;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class Startup {
|
public class Startup {
|
||||||
|
@Inject
|
||||||
|
LaunchMode launchMode;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void loadUsers(@Observes StartupEvent ignoredEvent) {
|
public void loadUsers(@Observes StartupEvent ignoredEvent) {
|
||||||
GlobalAccessLimits.initialize();
|
GlobalAccessLimits.initialize();
|
||||||
Token.deleteAll();
|
Token.deleteAll();
|
||||||
byte[] adminKey = new byte[18];
|
byte[] adminKey = new byte[18];
|
||||||
|
System.out.printf("Launch mode: %s\n", launchMode.toString());
|
||||||
|
|
||||||
|
if (launchMode == LaunchMode.NORMAL) {
|
||||||
|
System.out.println("Admin token is random");
|
||||||
|
new SecureRandom().nextBytes(adminKey);
|
||||||
|
} else {
|
||||||
|
// I don't know, but let it be
|
||||||
|
System.out.println("\n IF THIS IS RUNNING IN PRODUCTION, stop this program now and ask for help.\n");
|
||||||
|
}
|
||||||
|
|
||||||
Token token = new Token();
|
Token token = new Token();
|
||||||
token.accessLimits = GlobalAccessLimits.kilo;
|
token.accessLimits = GlobalAccessLimits.kilo;
|
||||||
|
|
Loading…
Reference in a new issue