Last active
August 29, 2015 14:24
-
-
Save spencergibb/616cbdb5fa8abd9d74a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.spring.oscon.authserver; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.authentication.AuthenticationManager; | |
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; | |
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; | |
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; | |
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; | |
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import java.security.Principal; | |
@SpringBootApplication | |
@RestController | |
@EnableResourceServer | |
public class AuthserverApp { | |
@RequestMapping("/user") | |
public Principal user(Principal user) { | |
return user; | |
} | |
@Configuration | |
@EnableAuthorizationServer | |
protected static class OAuth2Config extends AuthorizationServerConfigurerAdapter { | |
@Autowired | |
private AuthenticationManager authenticationManager; | |
@Override | |
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { | |
endpoints.authenticationManager(authenticationManager); | |
} | |
@Override | |
public void configure(ClientDetailsServiceConfigurer clients) throws Exception { | |
clients.inMemory() | |
.withClient("acme") | |
.secret("acmesecret") | |
.authorizedGrantTypes("authorization_code", "refresh_token", | |
"password").scopes("openid"); | |
} | |
} | |
public static void main(String[] args) { | |
SpringApplication.run(AuthserverApp.class, args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment