Giter VIP home page Giter VIP logo

spring-security-oauth2-authorization-server's Introduction

spring-security-oauth2-authorization-server

Demo Authorization Server using Nimbus and Spring Security

Before using, make sure to modify your /etc/hosts file so that you don't have problems with session cookies from a client app fighting with the authorization server.

127.0.0.1   idp

This is a Spring Boot application, so to start it, you can do:

gw :bootRun

To check that it is up, you can hit the OIDC discovery endpoint:

http :8081/.well-known/openid-configuration

The server has one client whose client id and secret are client/secret.

It has one user whose username and password are user/password.

It has three scopes, profile, message:read, and message:write.

Client Configuration

Now, configure a client application to point at this authorization server:

http --from https://start.spring.io/starter.tgz \
  dependencies=web,oauth2-client baseDir=client | tar -xzvf -

Modifying the application.yml like so:

spring:
  security:
    oauth2:
      client:
        provider:
          keycloak:
            issuer-uri: http://idp:8081
        registration:
          keycloak:
            client-id: client
            client-secret: secret

Make sure to add some kind of endpoint:

@RestController
public class ClientController {

	@GetMapping("/")
	public String index(Model model,
						@RegisteredOAuth2AuthorizedClient OAuth2AuthorizedClient authorizedClient,
						@AuthenticationPrincipal OAuth2User oauth2User) {
		return oauth2User.getName();
	}
}

And you should see the name of the user: user.

spring-security-oauth2-authorization-server's People

Contributors

jzheaux avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.