You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Kószó Patrick 90935bf78b Merge remote-tracking branch 'origin/main' into main 2 hours ago
gradle/wrapper Moving files to the root directory 1 day ago
src README.md edited 4 hours ago
.gitignore META-661 Add some Ops steps to README.md 4 hours ago
README.md Merge remote-tracking branch 'origin/main' into main 2 hours ago
build.gradle.kts Fixed the issue when we don't have the .json file 7 hours ago
gradle.properties Moving files to the root directory 1 day ago
gradlew Moving files to the root directory 1 day ago
gradlew.bat Moving files to the root directory 1 day ago
settings.gradle.kts Moving files to the root directory 1 day ago
user_backup.json README.md edited 4 hours ago

README.md

Needed Applications

  • Keycloak: Have a Keycloak installed on your computer
  • IntelliJ: Have an IDEA on your computer which can run .kt programs like IntelliJ

Keycloak installation

The official Keycloak guide helps for setting it up.

wget https://github.com/keycloak/keycloak/releases/download/15.0.2/keycloak-15.0.2.tar.gz
tar -xzvf keycloak-15.0.2.tar.gz
mv keycloak-15.0.2 keycloak
echo "keycloak" >> .gitignore
cd keycloak/bin && ./standalone.sh

Then open Keycloak homepage at http://localhost:8080/auth.

Create an admin account.

Create a new realm named test, enable User-Managed Access.

Create a new user in the test realm. The username should be testuser, set Email Verified to true.

In credentials add a new password: 123, disable Temporary.

  • import realm from a file

Needed Plugins:

Download the plugin here: Keycloak-event-listener-plugin git clone git@codeberg.org:ride2go/keycloak-event-listener-plugin.git

Steps

  • Setup the Keycloak server

    • Launch your server
    • Go to the http://localhost:8080/auth/ page
    • Create an admin account
    • Login with your admin account
    • When you are on the admin panel create your first realm:
      • Select realm -> Add realm
      • Here you just need to set the realm name
  • Open the Keycloak-event-listener-plugin in IntelliJ:

    • Open the EventFileWriter.java (../keycloak-event-listener-plugin/src/main/java/ride2go.events.userevents/Actions/EventFileWriter.java).
    • Rewrite the following part of the code -> String PATH_TO_EVENTS_FOLDER = ""; Write your ../Keycloak-log-files/Unprocessed_Files/ full path between the quotation marks.
    • Click into the terminal panel and write mvn clean install (Documentation if you don't have maven installed on your computer).
    • Copy the keycloak-event-listener-spi-plugin.jar file from the keycloak-event-listener-spi-plugin/target folder and paste it into your ../Keycloak/standalone/deployments folder.
    • Now if we open the events -> configtab on your Keycloak server you can pick the plugin. Make sure that you save the changes.
  • Enable the user registration and user account delete

    • On your Keycloak admin panel go to Realm settings -> Login
    • Set the User Registration ON (make sure that you save the changes)
    • Now go to the a Roles -> Default Roles -> Client Roles
    • Select the account -> delete-accountand add the selected role
  • Open the application in IntelliJ:

    • Open the GlobalValues.kt (../src/main/kotlin/GlobalValues.kt) file and rewrite the following code:
    • const val AdminUsername = "admin"delete the admin text and type there your Keycloak admin client username
    • const val AdminPassword = "admin"delete the admin text and type there your Keycloak admin client password
    • const val Realm = "test"delete the test text and type there your created realm name
  • Run the application.

    • Open the Main.kt(../src/main/kotlin/Main.kt) file
    • Press the run button
    • Now if you register a new user to your created account it will be append to the user_backup.json file. Also if login with that user and updated it or delete it the .json file will be updated.

Registration, update, delete

Now you can start to register new users to your realm. Go to your realm login page: http://localhost:8080/auth/realms/your_realm_name/account/#/. Replace the your_realm_name part of the link. Click on the Sign In button and there you can register your first user. When you successfully register your user go to the Personal Info and update your user. At the same page you can delete your user but you will need to confirm the delete process. For that, you need to login with the user and press the confirm button.