Integrate Vapor with Keycloak

Hi!

I am new to Swift on Server and I want to mirgrate a Spring boot application to Swift Vapor. Everything works find, for now, but I want to add the last missing feature: Authentication via Keycloak.

In the frontend, we use Bearer tokens and keykloak-js (keycloak-js - npm).

Keyckloak-Js uses OpenID Connect under the hood

keykloak-js is used like this:

const buildHeaders = (contentType: string): any => {
  if (defaultKeycloak.isTokenExpired()) {
    defaultKeycloak.updateToken();
  }

  return {
    'Content-Type': contentType,
    'Authorization': `Bearer ${defaultKeycloak.token!}`,
  };
};

Can anyone give me some pointers?

Imperial supports Keycloak so you should be able to use that to do most of the heavy lifting

2 Likes