├── src ├── main │ ├── resources │ │ ├── saml │ │ │ └── delete-me-please.txt │ │ ├── static │ │ │ ├── img │ │ │ │ ├── favicon.ico │ │ │ │ ├── nyan-cat.png │ │ │ │ ├── saml-flow.png │ │ │ │ └── spring-boot-saml.png │ │ │ ├── screenshots │ │ │ │ ├── app_overview.png │ │ │ │ ├── saml_based_sign_on.png │ │ │ │ └── saml-signing-certificate-section.png │ │ │ ├── css │ │ │ │ └── spring-saml-sp.css │ │ │ └── js │ │ │ │ └── bootstrap.min.js │ │ ├── application.yml │ │ └── templates │ │ │ ├── pages │ │ │ ├── landing.html │ │ │ ├── discovery.html │ │ │ └── index.html │ │ │ └── layout.html │ └── java │ │ └── com │ │ └── spring │ │ └── boot │ │ └── security │ │ └── saml │ │ ├── stereotypes │ │ └── CurrentUser.java │ │ ├── Application.java │ │ ├── controllers │ │ ├── LandingController.java │ │ └── SSOController.java │ │ ├── config │ │ ├── MvcConfig.java │ │ └── WebSecurityConfig.java │ │ └── core │ │ ├── SAMLUserDetailsServiceImpl.java │ │ └── CurrentUserHandlerMethodArgumentResolver.java └── test │ └── java │ └── com │ └── spring │ └── boot │ └── security │ └── saml │ ├── TestConfig.java │ ├── core │ ├── SAMLUserDetailsServiceImplTest.java │ └── CurrentUserHandlerMethodArgumentResolverTest.java │ ├── controllers │ ├── SSOControllerTest.java │ └── LandingControllerTest.java │ └── CommonTestSupport.java ├── .gitignore ├── pom.xml └── Readme.MD /src/main/resources/saml/delete-me-please.txt: -------------------------------------------------------------------------------- 1 | delete this file. -------------------------------------------------------------------------------- /src/main/resources/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pateluday07/saml-sso-and-slo-demo-idp-azure-sp-springboot/HEAD/src/main/resources/static/img/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/static/img/nyan-cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pateluday07/saml-sso-and-slo-demo-idp-azure-sp-springboot/HEAD/src/main/resources/static/img/nyan-cat.png -------------------------------------------------------------------------------- /src/main/resources/static/img/saml-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pateluday07/saml-sso-and-slo-demo-idp-azure-sp-springboot/HEAD/src/main/resources/static/img/saml-flow.png -------------------------------------------------------------------------------- /src/main/resources/static/img/spring-boot-saml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pateluday07/saml-sso-and-slo-demo-idp-azure-sp-springboot/HEAD/src/main/resources/static/img/spring-boot-saml.png -------------------------------------------------------------------------------- /src/main/resources/static/screenshots/app_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pateluday07/saml-sso-and-slo-demo-idp-azure-sp-springboot/HEAD/src/main/resources/static/screenshots/app_overview.png -------------------------------------------------------------------------------- /src/main/resources/static/screenshots/saml_based_sign_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pateluday07/saml-sso-and-slo-demo-idp-azure-sp-springboot/HEAD/src/main/resources/static/screenshots/saml_based_sign_on.png -------------------------------------------------------------------------------- /src/main/resources/static/screenshots/saml-signing-certificate-section.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pateluday07/saml-sso-and-slo-demo-idp-azure-sp-springboot/HEAD/src/main/resources/static/screenshots/saml-signing-certificate-section.png -------------------------------------------------------------------------------- /src/main/java/com/spring/boot/security/saml/stereotypes/CurrentUser.java: -------------------------------------------------------------------------------- 1 | package com.spring.boot.security.saml.stereotypes; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Target(ElementType.PARAMETER) 6 | @Retention(RetentionPolicy.RUNTIME) 7 | @Documented 8 | public @interface CurrentUser {} 9 | -------------------------------------------------------------------------------- /src/test/java/com/spring/boot/security/saml/TestConfig.java: -------------------------------------------------------------------------------- 1 | package com.spring.boot.security.saml; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 5 | 6 | @SpringBootApplication 7 | public class TestConfig implements WebMvcConfigurer { 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | org: 4 | springframework: 5 | security: 6 | saml: DEBUG 7 | opensaml: DEBUG 8 | com: 9 | spring: 10 | boot: 11 | security: 12 | saml: DEBUG 13 | 14 | service.provider.entity.id: # put your entity id here e.g com:uday:spring:boot:sp 15 | 16 | idp.metedata.url: # put your IDP metadata URL here 17 | 18 | # you can update credentials if you want, I recommend you to keep as it is for demo purpose 19 | saml: 20 | keystore.password: nalle123 21 | private.key: 22 | alias: apollo 23 | password: nalle123 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore list 2 | 3 | # Log file 4 | *.log 5 | 6 | # Maven 7 | log/ 8 | logs/ 9 | target/ 10 | 11 | # Compiled class file 12 | *.class 13 | 14 | # Mobile Tools for Java (J2ME) 15 | .mtj.tmp/ 16 | 17 | # Package Files 18 | *.jar 19 | *.war 20 | *.nar 21 | *.ear 22 | *.zip 23 | *.tar.gz 24 | *.rar 25 | 26 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 27 | hs_err_pid* 28 | 29 | # BlueJ files 30 | *.ctxt 31 | 32 | # Eclipse 33 | .classpath 34 | .project 35 | .settings/ 36 | 37 | # Intellij 38 | .idea/ 39 | *.iml 40 | *.iws 41 | 42 | # Mac 43 | .DS_Store 44 | 45 | # Custom domain settings 46 | CNAME 47 | -------------------------------------------------------------------------------- /src/main/java/com/spring/boot/security/saml/Application.java: -------------------------------------------------------------------------------- 1 | package com.spring.boot.security.saml; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 7 | 8 | @SpringBootApplication 9 | public class Application extends SpringBootServletInitializer { 10 | 11 | @Override 12 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 13 | return application.sources(Application.class); 14 | } 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(Application.class, args); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /src/main/resources/templates/pages/landing.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |
11 | 12 |You are logged as null.
19 | 20 | 21 | Global logout 22 | 23 | 24 | Local logout 25 | 26 | 27 |16 | Select your Identity Provider (IdP) 17 | Select an Identity provider that holds your authentication data. You can either enable users to explicitly select an IdP 18 | (like in this case) or you can configure as well an automatic means of Identity Provider discovery. 19 |
20 |24 | Authenticate against the selected IdP 25 | The Service Provider (SP) generates a SAML 2.0 authentication request, which is encoded and embedded into the URL for SSO 26 | service. After being redirected, you must provide your credentials to authenticate against the selected IdP. 27 |
28 |32 | Get back and see your login data 33 | The Identity Provider returns the encoded SAML response to the browser. You will be redirected back to the Service Provider. 34 | If your identity is established by the IdP, you will be provided with app access and your profile data displayed. 35 |
36 |40 | Logout from your session 41 | You can now logout from the app. If enabled, you can also invoke the Single Logout (SLO) that invalidates client application 42 | sessions in addition to its own SSO session (IdP-side). 43 |
44 |