Implementing OAuth Resource Server with Spring Boot
How to use a Spring Boot backend as an OAuth resource server.
How to use a Spring Boot backend as an OAuth resource server.
What is jOOQ ? jOOQ is a Java library that lets you to generate Java code from the database and lets you write type-safe SQL queries. jOOQ transforms tables in a database into Java classes, which we can use to retrieve or update data. Using jOOQ Library Inititalize Database Tables Execute the SQL statements in src/resources/initial_table.sql file on a Postgres server to create users, categories, transacations tables. initial_table.sql content 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 DROP TABLE IF EXISTS users CASCADE; DROP TABLE IF EXISTS categories CASCADE; DROP TABLE IF EXISTS transactions CASCADE; CREATE TABLE IF NOT EXISTS users ( id BIGINT NOT NULL PRIMARY KEY, username TEXT, email TEXT, updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE TABLE IF NOT EXISTS categories ( id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY(START WITH 200000000) , user_id BIGINT REFERENCES users(id), name TEXT, active BOOLEAN NOT NULL DEFAULT TRUE, type TEXT, updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE TABLE IF NOT EXISTS transactions ( id BIGINT NOT NULL PRIMARY KEY, user_id BIGINT REFERENCES users(id), category_id BIGINT REFERENCES categories(id), amount BIGINT, transaction_date DATE NOT NULL DEFAULT CURRENT_DATE, note TEXT, updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); Add jOOQ Dependency To use jOOQ in Spring Boot, we declare a dependency to spring-boot-starter-jooq:...
Repository The repository for the backend implementation of Tabunganku is available here. Technology I develop the backend using Java 17 with Spring Boot, and Postgres 15.3 as the data store. Other Java libraries that I use in this project: spring-dotenv: a library to load environment variables from .env file. I use it to load database information and others. MapStruct: a library to create mapping between two Java Beans. I use it to transform entity objects into DTO objects....
Background When building a web application, we eventually have to connect to a database to retrieve data and to update data. One thing we don’t want to experience is having our database password leaked. Cloud providers solve this issue by providing a service to store sensitive information (e.g., AWS Secrets Manager). We need to explore an alternative solution to avoid reliance on external services. I researched two Java libraries that allow us to store sensitive data: Jasypt and dotenv....