Code Monkey home page Code Monkey logo

codenation-java-12's Introduction

Oauth2 com Spring

Neste desafio você receberá um projeto Maven pré-configurado com Springboot, Spring-JPA, Spring-WEB, Spring-Security e banco de dados H2.

Utilize a lib Spring Security OAuth2 AutoConfigure para utilizar Oauth2 no seu projeto spring.

  1. Configure o Resource Server através da annotation @EnableResourceServer para expor o endpoint /user e bloquear todos os outros.

  2. Configure o Authentication Server através da annotation @EnableAuthorizationServer.

    • O Email dos Usuários deve ser utilizado como login
    • A aplicação deve ser configurada para utilizar o UserRepository para buscar o Usuario por e-mail
    • A senha não deve estar encriptada
  3. Utilize a propriedade do spring para setar scope password, client_id e client_secret.

     security.oauth2.client.scope=password
     security.oauth2.client.client-secret=
     security.oauth2.client.client-id=
    
  4. GET /oauth/token: recebendo client_id, client_secret, grant_type, user e password. A resposta será um JSON contendo as seguintes informações:

     {
         "access_token": "798df339-c920-4e42-9eb7-8bab168d6480",
         "token_type": "bearer",
         "refresh_token": "b0efcd1e-1459-47b6-8a55-ec09af2202b6",
         "expires_in": 85759,
         "scope": "read write trust"
     }
    
  5. GET /user: deverá ser acessado sem autenticação.

  6. GET /company: deverá ser acessado apenas com autenticação. Utilize a autenticação Bearer + token para conseguir acesso.

codenation-java-12's People

Contributors

raphaelfontoura avatar

Watchers

 avatar  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.