Skip to content

Library for fast inclusion of oath2 client methods (callback and authorization to multiple providers)

Notifications You must be signed in to change notification settings

Chiyo-no-sake/RedSpringBootOAuth2Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RedSpringBoot - OAuth2 Client

Installation

First, add the github repo for oauth2 library in your pom.xml:

<repositories>
    <repository>
        <id>RedSpringBootOAuth2Client-mvn-repo</id>
        <url>https://github.com/Chiyo-no-sake/RedSpringBootOAuth2Client/raw/mvn-repo/</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

Now just define the dependency in you project pom.xml like the following:

<dependency>
    <groupId>it.redbyte</groupId>
    <artifactId>red-spring-boot-oauth2-client</artifactId>
    <version>1.0.0</version>
</dependency>

Usage

  1. Define he following provider properties in application.yml
...
oauth2:
  session-cookie:
    name: TSM_SESS_ID
  providers:
    linkedin:
      auth-url: "https://www.linkedin.com/oauth/v2/authorization"
      client-id: "---------"
      redirect-uri: "http://localhost:8080/api/login/oauth2/code/linkedin"
      scopes:
        - r_emailaddress
        - r_liteprofile
...
  1. Define you provider classes, extending OAuth2Provider:
@Component
class LinkedinOAuth2Provider: OAuth2Provider {
    override val providerName = "linkedin"

    override fun callback(code: String): ResponseEntity<Any> {
        LoggerFactory.getLogger(this.javaClass).info("CALLBACK!!!!!")
        return ResponseEntity.ok(null)
    }
}

... Auto configuration classes will do the rest 6) DONE!! Now the login endpoint should be exposed at {baseUrl}/oauth2/authentication/linkedin and the callback at /login/oauth2/code/linkedin

About

Library for fast inclusion of oath2 client methods (callback and authorization to multiple providers)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages