CodeNewbie Community 🌱

Sharon428931
Sharon428931

Posted on

How to Integrate Keycloak Login into SafeLine WAF with OIDC

Safeline supports integration with various identity providers through the OIDC (OpenID Connect) protocol, allowing users to securely log in to applications or websites using existing identity systems. Supported identity providers include but are not limited to Keycloak, Auth0, Okta, Azure AD, etc.
{.is-info}

OIDC Protocol Introduction

OpenID Connect (OIDC) is an identity authentication layer based on the OAuth 2.0 protocol that allows client applications to verify end-user identities based on authentication results from an authorization server and obtain basic user information. OIDC enables third-party applications to securely access user information without directly managing user credentials.

Preparation

1. Select and Configure OIDC Identity Provider

Using Keycloak, a common OIDC provider, as an example, here's how to obtain the required parameters for configuration:

Keycloak Configuration

  1. Log in to the Keycloak admin console.

  2. Select or create a Realm.

  3. In the left menu, click "Clients" → "Create" to create a new client.

  4. Fill in the following information:

    • Client ID: Specify a unique identifier for the client
  5. In the "Settings" tab, configure:

    • Valid Redirect URIs: Add the application's callback address, e.g., https://example.com/.safeline/auth/api/callback/oidc
    • Web Origins: Add the application address, e.g., https://example.com

For the callback domain field, you need to append /auth/api/callback/oidc to your application URL
{.is-warning}

  1. Save the configuration.

  2. Switch to the "Credentials" tab and obtain the "Client Secret".

  3. Record the following information:

    • OIDC discovery URL: https://{keycloak-host}/realms/{realm-name}
    • Client ID: The client ID you created
    • Client Secret: The key obtained from the Credentials tab

2. Obtain OIDC Configuration Parameters

Regardless of which OIDC provider you use, you'll need to obtain the following information for Safeline WAF configuration:

  • OIDC Discovery URL: The provider's OpenID Connect configuration information address
  • Client ID: The client ID registered with the OIDC provider
  • Client Secret: The client secret generated by the OIDC provider

Safeline WAF Configuration

1. Access Auth Configuration

  1. Go to the Safeline console "Auth" → "Settings" page.

  2. Click "Third-party Login" and select "OIDC".

Image description

2. Fill in Configuration Information

Fill in the following information in the configuration form:

Field Description
OIDC Server URL The configuration discovery URL of the OIDC provider; Safeline will automatically append .well-known/openid-configuration at the end
Client ID The client ID obtained from the OIDC provider
Client Secret The client secret obtained from the OIDC provider
  1. After completing the configuration, click the "Submit" button to complete the binding.

3. Configure Auth Application

  1. On the "Applications" select the application for which you want to enable OIDC login.

  2. In the application's "AUTH - Login Methods" configuration, enable the "OIDC" option.

  3. Save.

User Authentication Process

After enabling the "AUTH" feature and selecting OIDC login method for an application:

  1. When users access the application, the OIDC login option will be displayed.

  2. After clicking to log in, users will be redirected to the OIDC provider's login page.

  3. After completing authentication on the OIDC provider's page, users will be redirected back to Safeline WAF.

  4. New users authenticating for the first time will need to be approved by a Safeline administrator in the console.

    • Users who pass the review will be authorized for this application and will not require further review for subsequent access.
    • Users who are not approved will be blocked and unable to access the application.

User Management

On the "AUTH" → "User Management" page, you can:

  1. View the list of users who have been authenticated through OIDC.
  2. Review new users for approval.
  3. Manage user access permissions, including authorization and revocation.

Frequently Asked Questions

Q: Cannot redirect to OIDC provider after integration

A: Please check if the OIDC discovery URL is correct and ensure it can be accessed via a browser and returns valid JSON configuration.

Q: Callback fails after user authentication with OIDC provider

A: Please confirm that the callback address is configured correctly, including protocol (http/https), domain, and path.

Q: What scopes does Safeline request by default?

A: openid


Join the SafeLine Community

Top comments (0)