Skip to content
aanganes edited this page Jun 21, 2012 · 21 revisions

This project (OIDC-JSS) is intended to be a standalone OpenID Connect Server. Extension and customization of this server can be accomplished by configuration through Spring configuration files, injected functionality through new Beans, and overlay of views and static resources (using Maven War Overlay or similar functionality). We currently support the Authorization Code flow, and intend to eventually support others.

OIDC-JSS is built on Spring 3.1 and Spring Security 3.1, making heavy use of the OAuth2 module of Spring Security OAuth (SECOAUTH)*. Wherever sensible, we have tried to make use of existing functionality in SECOAUTH, Spring, and Spring Security. Because of this, much of the functionality of OIDC-JSS is hidden in Spring context configuration files and may not be readily apparent when examining the codebase. This architecture document will attempt to lay out which portions of the server implementation reside in our own code, and which portions are delegated to the SECOAUTH library.

In addition, we have written a JWT library (which eventually should be moved outside of this project as a standalone library of its own). We are using this library extensively throughout our code such that all of our Access Tokens and ID Tokens are (optionally signed) JWTs.

We are using JPA with Eclipselink and external MySQL databases for token, client, and user data persistence.

Modules

The project uses a multi-level Maven and git repository structure. The main project is split into the following modules:

  • openid-connect-common: common classes, service and repository interfaces, and JPA-annotated model code. The JWT library is currently included here, but will eventually be moved out as a separate, external library.
  • openid-connect-server: IdP/server implementation, includes implementations of services and repositories for use by server.
  • openid-connect-client: RP/client implementation, built around spring security filters.
  • spring-security-oauth: Git submodule that points to the Spring Security OAuth Git repository. Will be removed once a reliable milestone is reached upstream (see note above).

Spring Configuration

We are using the SECOAUTH 'authorization-server' element in our spring-servlet.xml (Spring configuration file, in openid-connect-server src/main/webapp/WEB-INF). This element stands up several SECOAUTH beans, and allows customization by injecting replacements for some of their default beans.

<oauth:authorization-server client-details-service-ref="defaultOAuth2ClientDetailsEntityService" 
	token-services-ref="defaultOAuth2ProviderTokenService" token-granter-ref="authCodeTokenGranter"
	user-approval-handler-ref="userApprovalHandler" authorization-endpoint-url="/openidconnect/auth" token-endpoint-url="/openidconnect/token">
    <oauth:authorization-code authorization-code-services-ref="authCodeServices" />
</oauth:authorization-server>
<bean id="authCodeTokenGranter" class="org.springframework.security.oauth2.provider.code.AuthorizationCodeTokenGranter">
    <constructor-arg name="tokenServices" ref="defaultOAuth2ProviderTokenService"/>
    <constructor-arg name="authorizationRequestFactory" ref="authorizationRequestFactory"/>
<constructor-arg name="authorizationCodeServices" ref="authCodeServices"/>
</bean>

Following is a list of the important SECOAUTH beans we are using out-of-the-box. This is not an exhaustive list; but these beans contain most of the functionality that we care about:

  • org.springframework.security.oauth2.endpoint.AuthorizationEndpoint
  • org.springframework.security.oauth2.endpoint.TokenEndpoint
  • org.springframework.security.oauth2.code.AuthorizationCodeTokenGranter
  • org.springframework.security.oauth2.provider.code.InMemoryAuthorizationCodeServices

Following is a list of the custom beans we are injecting:

  • org.mitre.oauth2.service.impl.DefaultOAuth2ProviderTokenService
  • org.mitre.oauth2.service.impl.DefaultOAuth2ClientDetailsEntityService
  • org.mitre.openid.connect.token.ConnectTokenEnhancer
  • org.mitre.openid.connect.token.JdbcUserApprovalHandler [TODO, not fully implemented yet]
  • JpaUserInfoRepository
  • OAuth2ClientRepository
  • JwtSigningAndValidationServiceDefault

The diagram below shows how all of these pieces fit together. Architecture Diagram

Tokens

//using SECOAUTH token endpoint, with custom token services and token enhancer, etc

User Management

UserDetailsService - used by Spring Security's AuthenticationProvider to represent the current user (loads a user from a given user id) AuthenticationUserDetailsService - Used by Spring Security to load a user from an authentication token UserInfoRepository - repository of user information that is fed into the UserInfoEndpoint's service

//Which of these have we implemented and which are straight SECOAUTH?

Token Management

AuthorizationServerTokenServices - provide tokens for the authorization server

Client Management

ClientDetailsService - provide OAuth client information (used for OpenID Connect Clients)

Maven War Overlay

//TODO: Steve needs to write this

One of the best ways to build a custom deployment of this system is to use the Maven War Overlay mechanism. In essence, you make a new Maven project with a "war" disposition and make it depend on the openid-connect-server module with the Maven Overlay plugin configured. Any files in your new project will be built and injected into the war from the other project. This action will also overwrite any existing files.

For instance, to overwrite the data source configuration in the main server war file, create a file named src/main/webapp/WEB-INF/data-context.xml that contains the dataSource bean. This file will completely replace the one that's in the originally built war.


*We are currently tracking against the development version of SECOAUTH, which is included in the build directories as a Git submodule. This submodule must be initialized before the main project can be built (see Build Instructions for details). Once SECOAUTH stabilizes to sufficient point, we will instead use a Maven dependency against a specific milestone / release version.


[old]

There is a JWT library that handles serialization/deserialization and manipulation of JWTs. We have our own implementation of OAuth2AccessToken called OAuth2AccessTokenEntity which is backed by a JWT object and returns the serialized version of the JWT as the token's Value field.

Clone this wiki locally