|
1 | | -This project is a sample app showing how to do various things with |
2 | | -https://tools.ietf.org/html/rfc6749[OAuth2] and |
3 | | -http://projects.spring.io/spring-boot/[Spring Boot], starting with a |
4 | | -simple, single-provider single-sign on, and working up to a |
5 | | -self-hosted OAuth2 Authorization Server with a choice of social |
6 | | -authentication providers (https://developers.facebook.com[Facebook] or |
7 | | -https://developer.github.com/[Github]). The samples are all |
8 | | -single-page apps using Spring Boot and Spring OAuth on the back |
9 | | -end. They also all use https://angularjs.org/[AngularJS] on the front |
10 | | -end, but the changes needed to convert to a different JavaScript |
11 | | -framework or to use server side rendering would be minimal. |
12 | | - |
13 | | -There are several samples building on each other adding new features: |
14 | | - |
15 | | -* **simple**: a very basic static app with just a home page and |
16 | | -unconditional login through via Spring Boot's `@EnableOAuth2Sso` (if |
17 | | -you visit the home page you will be automatically redirected to |
18 | | -Facebook). |
19 | | -
|
20 | | -* **click**: adds an explicit link that the user has to click to |
21 | | -login. |
22 | | -
|
23 | | -* **logout**: adds a logout link as well for authenticated users. |
24 | | -
|
25 | | -* **manual**: shows how the `@EnableOAuth2Sso` works by unpicking it |
26 | | -and configuring all its pieces manually. |
27 | | -
|
28 | | -* **gitub**: adds a second login provider in Github, so the user can |
29 | | -choose on the home page which one to use. |
30 | | -
|
31 | | -* **auth-server**: turns the app into a fully-fledged OAuth2 |
32 | | -Authorization Server, able to issue its own tokens, but still using |
33 | | -the external OAuth2 providers for authentication. |
34 | | -
|
35 | | -Each of them can be imported into an IDE and there is a main class |
36 | | -`SocialApplication` that you can run there to start the apps. They all |
37 | | -come up with a home page on http://localhost:8080 (and all require |
38 | | -that you have at least a Facebook account if you want to log in and |
39 | | -see the content). You can also run all the apps on the command line |
40 | | -using `mvn spring-boot:run` or by building the jar file and running it |
41 | | -with `mvn package` and `java -jar ...`. There is no need to install |
42 | | -Maven if you use the https://github.com/takari/maven-wrapper[wrapper] |
43 | | -at the top level, e.g. |
44 | | - |
45 | | -``` |
46 | | -$ cd simple |
47 | | -$ ../mvnw package |
48 | | -$ java -jar target/*.jar |
49 | | -``` |
50 | | -
|
51 | | -NOTE: The apps all work on `localhost:8080` because they use OAuth2 |
52 | | -clients registered with Facebook and Github for that address. To run |
53 | | -them on a different host or port, you need to register your own apps |
54 | | -and put the credentials in the config files. There is no danger of |
55 | | -leaking your Facebook or Github credentials beyond localhost if you |
56 | | -use the default values, but be careful what you expose on the |
57 | | -internet, and don't put your own app registrations in public source |
58 | | -control. |
| 1 | +--- |
| 2 | +tags: [security,angular,rest,oauth] |
| 3 | +projects: [spring-security,spring-security-oauth,spring-boot] |
| 4 | +--- |
| 5 | +:toc: left |
| 6 | +:icons: font |
| 7 | +:source-highlighter: prettify |
| 8 | +:image-width: 500 |
| 9 | +:doctype: book |
| 10 | +:star: {asterisk} |
| 11 | +:all: {asterisk}{asterisk} |
| 12 | + |
| 13 | += Social Login with Spring Boot and OAuth2 |
| 14 | + |
| 15 | +include::overview.adoc[] |
| 16 | + |
| 17 | +include::simple/README.adoc[leveloffset=+1] |
| 18 | +include::click/README.adoc[leveloffset=+1] |
| 19 | +include::logout/README.adoc[leveloffset=+1] |
| 20 | +include::manual/README.adoc[leveloffset=+1] |
| 21 | +include::github/README.adoc[leveloffset=+1] |
| 22 | +include::auth-server/README.adoc[leveloffset=+1] |
| 23 | + |
| 24 | +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/footer.adoc[] |
0 commit comments