Thursday, January 23, 2020

SSO OAuth2 Spring Boot2 Security JDBC Authentication

I share example how to integration OAuth2 - Spring Boot2 - Security - JDBC Authentication.

Technologies used:

1. Spring Boot 2.0.3.RELEASE
2. Maven 4
3. Java 8
4. OAuth2
5. Eclipse: Oxygen.1.a Release (4.7.1a)
6. Spring Tools Suite (STS) 4
7. MySql

Code on GitHub:


Step 1:

Create tables on mysql:

     username VARCHAR(50) NOT NULL PRIMARY KEY, 
     password VARCHAR(100) NOT NULL, 
     enabled  BOOLEAN NOT NULL 

CREATE TABLE authorities 
     username  VARCHAR(50) NOT NULL, 
     authority VARCHAR(50) NOT NULL, 
     CONSTRAINT fk_authorities_users FOREIGN KEY(username) REFERENCES users( 

CREATE UNIQUE INDEX ix_auth_username ON authorities (username, authority); 

Step 2: Insert your user, example:

For insert password on Databases you need to passwordEncoder, for example use for generate passwordEncoder:

Resul is : $2a$08$sqfU5.UM.oEqgzVniREsvOsQ9eDtSD/xX8RXT2Bc4AmXWHo4fcchG

VALUES      ('henry', 

INSERT INTO authorities 
VALUES     ('henry', 

Step 3:

On the proyect spring-security-sso-auth-server change the configuration in application.yml

Step 4:

Run 2 proyects on Eclipse or if you prefer use command line on console:

First: auth server

Righ click on proyect -> Run As -> Spring Boot App

Expose on port: 8081

Second: sso-ui

Expose on port: 8082

Step 5:



Saturday, January 18, 2020

Permission Denied (publickey) error when I push (GitHub)

I share solution next error:

Permission Denied (publickey)' error when I push!


Step 1:

Search de folder .ssh, you find the folder on your user:  (if the folder doesn´t exist then you need to create the folder with the command mkdir inside on your_user)

Linux:  /home/my_user/.ssh
Windows: C:\Users/my_user/.ssh

Step 2: Run the next command and press enter: (Leave blank what they ask)


Step 3:

Before command generate the file, open the file by command or any editor and copy of content.

Step 4:

Go to your profile on  GitHub:

Choose Settings --> SSH and GPG Keys --> New SSH Key --> Copy content from file

And try to git push again.


Multiple Data Sources in Spring Boot 3 with Java 21

  In this blog post, we'll explore the configuration and setup for a Spring Boot 3 application with Java 21 that uses multiple data sour...