Skip to content

Latest commit

 

History

History
106 lines (74 loc) · 2.74 KB

README.md

File metadata and controls

106 lines (74 loc) · 2.74 KB

OpenID Connect JVM client

codecov MavenCentral License: Apache-2.0

OpenId Connect Client written in Kotlin.

OpenID in a nutshell

A Gist of OpenID Connect

This client is implemented with reference to OpenID Connect Basic Client Implementer's Guide

OpenID connect Basic Flow

OpenID basic flow

Installation

Gradle

compile 'io.github.shyamz-22:oidc-jvm-client:$version'

Maven

<dependency>
    <groupId>io.github.shyamz-22</groupId>
    <artifactId>oidc-jvm-client</artifactId>
    <version>${version}</version>
</dependency>

How to use the library

Kotlin

  • Step 1: Load Client Configuration
 ClientConfiguration.
               .with()
               .client("<your-client-id>",
               "<your-redirect-uri>",
               "<your-secret>")
               .issuer("<issuer-url>")
  • Step 2: Make an Authentication Request
AuthenticationRequestBuilder()
                        .basic()
                        .build()
                        .andRedirect(response);
  • Step 3: Exchange Code for access token and id token
val user = OpenIdConnectCallBackInterceptor(httpServletRequest)
                .extractCode()
                .exchangeCodeForTokens()
                .extractAuthenticatedUserInfo();

Java

  • Step 1: Load Client Configuration
 ClientConfiguration.INSTANCE
               .with()
               .client("<your-client-id>",
               "<your-redirect-uri>",
               "<your-secret>")
               .issuer("<issuer-url>")
  • Step 2: Make an Authentication Request
new AuthenticationRequestBuilder()
                        .basic()
                        .build()
                        .andRedirect(response);
  • Step 3: Exchange Code for access token and id token
AuthenticatedUser user = new OpenIdConnectCallBackInterceptor(httpServletRequest)
                .extractCode(null)
                .exchangeCodeForTokens()
                .extractAuthenticatedUserInfo(null);

References

  1. OpenID Connect Specification
  2. OpenID connect playground
  3. JWT