Commit 71653881 authored by Jasha Joachimsthal's avatar Jasha Joachimsthal Committed by 陈健

OAUTH-3116 Rename packages

parent 97e210fa
The MIT License (MIT)
Copyright (c) 2018 Onegini B.V.
Copyright (c) 2014 Romain Fromi
Permission is hereby granted, free of charge, to any person obtaining a copy
......
......@@ -55,11 +55,11 @@ returned to a page where you see user information and the claims from the ID tok
## How it works
### OAuth2Client
[OAuth2Client.java](src/main/java/com/github/fromi/openidconnect/security/OAuth2Client.java) configures the OAuth flow for Spring Security. It uses discovery
[OAuth2Client.java](src/main/java/com/onegini/oidc/security/OAuth2Client.java) configures the OAuth flow for Spring Security. It uses discovery
to find the endpoints used by the OAuth flow. By default the scopes "openid" and "profile" are requested.
### OpenIdConnectAuthenticationFilter
[OpenIdConnectAuthenticationFilter.java](src/main/java/com/github/fromi/openidconnect/security/OpenIdConnectAuthenticationFilter.java) is the filter used during
[OpenIdConnectAuthenticationFilter.java](src/main/java/com/onegini/oidc/security/OpenIdConnectAuthenticationFilter.java) is the filter used during
authentication. It adds user information during authentication Depending on your environment this could be different. There are mainly two ways to do this:
In the code we show both ways. The second way is commented out. The first one also covers the ID token validation.
......@@ -69,27 +69,27 @@ Depending on the scope and configuration used in your environment the user data
In this example we use the `sub` and the `name` value, but you can use any value configured for your environment.
### OpenIdTokenValidationWrapper
[OpenIdTokenValidationWrapper.java](src/main/java/com/github/fromi/openidconnect/security/OpenIdTokenValidatorWrapper.java) validates the ID token. It validates
[OpenIdTokenValidationWrapper.java](src/main/java/com/onegini/oidc/security/OpenIdTokenValidatorWrapper.java) validates the ID token. It validates
its signature against the keys that are returned by the JWKS endpoint of the OP. It verifies that the claims are from the issuer, intended for the correct
audience and that they have not expired.
### UserInfo
The [UserInfo.java](src/main/java/com/github/fromi/openidconnect/model/UserInfo.java) is a POJO for user information. It is used as user principal in Spring
The [UserInfo.java](src/main/java/com/onegini/oidc/model/UserInfo.java) is a POJO for user information. It is used as user principal in Spring
Security.
### TokenDetails
The [TokenDetails.java](src/main/java/com/github/fromi/openidconnect/model/TokenDetails.java) is a POJO for additional details about the token used during
The [TokenDetails.java](src/main/java/com/onegini/oidc/model/TokenDetails.java) is a POJO for additional details about the token used during
authentication. In this project it contains the claims of the JWT.
### Security configuration
In [SecurityConfiguration.java](src/main/java/com/github/fromi/openidconnect/security/SecurityConfiguration.java) we configure the Spring Security filters used
In [SecurityConfiguration.java](src/main/java/com/onegini/oidc/security/SecurityConfiguration.java) we configure the Spring Security filters used
to authenticate the user and authorize the controllers of our application.
### SampleSecuredController
The [SampleSecuredController.java](src/main/java/com/github/fromi/openidconnect/SampleSecuredController.java) has a protected endpoint `/secured`. It populates
The [SampleSecuredController.java](src/main/java/com/onegini/oidc/SampleSecuredController.java) has a protected endpoint `/secured`. It populates
the modelMap for the template that shows the user information, ID token and the claims.
### LogoutController
Thie [LogoutController.java](src/main/java/com/github/fromi/openidconnect/LogoutController.java) contains the logic to end the session. The user first comes to
Thie [LogoutController.java](src/main/java/com/onegini/oidc/LogoutController.java) contains the logic to end the session. The user first comes to
the `/logout` endpoint. If the user was logged in via an ID token, they are redirected to the end session endpoint of the OP. The OP ends the session of the
user and redirects it back to `http://localhost:8080/signout-callback-oidc`. Then the user is logged out in Spring Security and redirected to the home page.
\ No newline at end of file
package com.github.fromi.openidconnect;
package com.onegini.oidc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
......
package com.github.fromi.openidconnect;
package com.onegini.oidc;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
......
package com.github.fromi.openidconnect;
package com.onegini.oidc;
import java.security.Principal;
import java.util.Map;
......@@ -22,8 +22,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import org.springframework.web.util.UriComponentsBuilder;
import com.github.fromi.openidconnect.config.ApplicationProperties;
import com.github.fromi.openidconnect.model.UserInfo;
import com.onegini.oidc.config.ApplicationProperties;
import com.onegini.oidc.model.UserInfo;
@Controller
public class LogoutController {
......
package com.github.fromi.openidconnect;
package com.onegini.oidc;
import java.security.Principal;
......@@ -7,7 +7,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import com.github.fromi.openidconnect.model.TokenDetails;
import com.onegini.oidc.model.TokenDetails;
@Controller
public class SampleSecuredController {
......
package com.github.fromi.openidconnect.config;
package com.onegini.oidc.config;
import javax.validation.constraints.NotBlank;
......
package com.github.fromi.openidconnect.config;
package com.onegini.oidc.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......
package com.github.fromi.openidconnect.model;
package com.onegini.oidc.model;
import com.nimbusds.jwt.JWTClaimsSet;
......
package com.github.fromi.openidconnect.model;
package com.onegini.oidc.model;
public class UserInfo {
......
package com.github.fromi.openidconnect.security;
package com.onegini.oidc.security;
import static org.springframework.security.oauth2.common.AuthenticationScheme.header;
......
package com.github.fromi.openidconnect.security;
package com.onegini.oidc.security;
import static java.util.Optional.empty;
import static org.springframework.security.core.authority.AuthorityUtils.NO_AUTHORITIES;
......@@ -19,8 +19,8 @@ import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
import com.github.fromi.openidconnect.model.TokenDetails;
import com.github.fromi.openidconnect.model.UserInfo;
import com.onegini.oidc.model.TokenDetails;
import com.onegini.oidc.model.UserInfo;
import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.JWTParser;
......
package com.github.fromi.openidconnect.security;
package com.onegini.oidc.security;
import javax.annotation.Resource;
......
package com.github.fromi.openidconnect.security;
import static com.github.fromi.openidconnect.IndexController.PAGE_INDEX;
import static com.github.fromi.openidconnect.LogoutController.PAGE_LOGOUT;
import static com.github.fromi.openidconnect.SampleSecuredController.PAGE_SECURED;
package com.onegini.oidc.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -15,6 +11,10 @@ import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
import com.onegini.oidc.IndexController;
import com.onegini.oidc.LogoutController;
import com.onegini.oidc.SampleSecuredController;
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
......@@ -52,11 +52,11 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.authorizeRequests()
.antMatchers("/", "/logout", "/signout-callback-oidc").permitAll()
.antMatchers("/static/**", "/favicon.ico").permitAll()
.antMatchers(PAGE_SECURED).authenticated()
.antMatchers(SampleSecuredController.PAGE_SECURED).authenticated()
.and()
.logout()
.logoutUrl(PAGE_LOGOUT)
.logoutSuccessUrl(PAGE_INDEX);
.logoutUrl(LogoutController.PAGE_LOGOUT)
.logoutSuccessUrl(IndexController.PAGE_INDEX);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment