Urgent.News

What's breaking now, across thousands of outlets.

Tech

Getting Started with Keycloak - Building a Simple Login Page with Docker

Introduction Recently, it seems Keycloak is being used quite frequently. (According to my colleague) I hadn't tried it yet myself, so I decided to give it a simple try to see what it's all about. Getting Started with Keycloak 1. Pull the Docker image and start Keycloak docker run --rm -p 8080:8080 \ -e KEYCLOAK_ADMIN = admin \ -e KEYCLOAK_ADMIN_PASSWORD = admin \ quay.io/keycloak/keycloak:24.0.3…

Keycloak has become quite popular lately. Following the example of a colleague, I decided to try it out and assess its capabilities. Here's how I got started with Keycloak and built a basic login page using Docker:

1. Begin by pulling the Keycloak Docker image and initiate the container with the command:

```

docker run --rm -p 8080:8080 \

-e KEYCLOAK_ADMIN=admin \

-e KEYCLOAK_ADMIN_PASSWORD=admin \

quay.io/keycloak/keycloak:24.0.3 start-dev

```

2. Access the Keycloak admin console by visiting the URL: http://localhost:8080. You'll be greeted with the Keycloak login page.

3. Log in to the admin console using the default username and password: admin/admin. Upon successful login, you'll have access to the Keycloak interface.

4. To create a test user, navigate to the left menu and select Users > Add user. Create a new user named "test" for testing purposes.

5. Next, create a test client by going to Clients > Create client in the admin console. Enter the following details:

- Client ID: my-html-client

- Home URL: / (where you'll host your HTML file)

- Valid redirect URIs: http://localhost:8000 (this is where your HTML page will reside)

- Web origins: http://localhost:8000

6. Now, create a simple login page using HTML. Create a file named "index.html" with the following code:

```html

<!DOCTYPE html>

html>

<head>

<title>Keycloak Demo</title>

<script src="https://cdn.jsdelivr.net/npm/keycloak-js@24.0.3/dist/keycloak.min.js"></script>

</head>

<body>

<h1>Keycloak Test Page</h1>

<button onclick="login()">Login</button>

<pre id="output"></pre>

<script>

const keycloak = new Keycloak({

url: "http://localhost:8080/",

realm: "master",

clientId: "my-html-client"

});

function login() {

keycloak.init({ onLoad: "login-required" }).then(authenticated => {

document.getElementById("output").textContent =

authenticated ? "Authenticated\n" + JSON.stringify(keycloak.tokenParsed, null, 2) : "Not Authenticated";

});

}

</script>

</body>

</html>

```

7. To view your login page, start a simple web server. Navigate to the folder containing your "index.html" file and run the command:

```

python -m http.server 8000

```

8. Open your web browser and visit http://localhost:8000. You'll see the Keycloak test page with a login button.

9. Click the "Login" button. You'll be redirected to the Keycloak authentication screen. Enter the credentials: username: test, password: password. Upon successful authentication, you'll be redirected back to the login page, indicating a successful login process.

Throughout the setup, Keycloak's configuration can be conveniently managed via the user-friendly GUI, making it approachable for beginners. The authentication flow was verified quickly, demonstrating its potential usefulness for future development projects. As you become more familiar with Keycloak, you can delve into more advanced configuration settings and explore its additional features.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

One night, one team, countless discussions and a lot of learning. This is definitely a night we will remember.

An overnight journey of brainstorming, building, learning, snacks, last-minute changes and memories that we will probably talk about for a long time.

  • Overnight hackathon commenced at 4:00, marking first overnight hackathon together
  • Team worked on decentralized trust network for open-source contributions
  • Numerous discussions and learning took place amid building and snacks

A Project Skill Can Change APX Behavior With One Name

A skill name is a boundary, not just a label. In APX, a project-local skill with the same slug as a user-global or built-in skill wins. That is useful when a repository needs its own operating rules.

  • Project-local skill overrides user-global or built-in skill in APX
  • Create SKILL.md file in .apc/skills/ directory to customize workflow
  • Project-specific skill replaces global version, not merging with it

Why I Stopped Letting One Turn Give an Agent Two Orders

Why I Stopped Letting One Turn Give an Agent Two Orders I used to think duplicate delegation was a small prompting problem.

  • One turn should command only one action from an agent.
  • Guard records target agent and instruction per turn.
  • Follow-up flag corrects or extends instructions explicitly.

Twelve Hours, Four Friends, and a Whole Lot of Coffee: Our Hack Day Journey

There’s a unique kind of chaos that only hits you at 3:00 AM in a room full of glowing screens and buzzing energy. That was us—Team CodeSins—deep into Hack Day Sonipat, wondering why on earth we…

  • Team CodeSins built puzzle in 12 hours
  • Pulkit led team through challenges
  • Camaraderie highlighted over final product

WARN Act and Non-Compete Agreements: What a Layoff Does (and Doesn't Do) to Your Non-Compete

When a WARN notice lands, most workers focus on the urgent questions: when does the job end, when does the last paycheck arrive, and what happens to health coverage.

  • WARN notice informs of impending layoff but doesn't release worker from non-compete.
  • Non-compete enforceability depends on agreement wording, state laws, termination circumstances.
  • State laws govern non-competes, often restricting earnings, length, scope.

More from Sunday 1 November →