Skip to content
aanganes edited this page Jul 17, 2012 · 17 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

Endpoints

The OAuth2 and OpenID Connect endpoints are currently set to the following values:

  • Authorization endpoint: /openidconnect/auth
  • Token endpoint: /openidconnect/token
  • Check ID (deprecated): /checkid
  • JWK: /jwk
  • SWD: /swd
  • User info: /userinfo
  • Provider configuration: /.well-known/openid-configuration

These endpoints are compliant with the OpenID Connect family of specifications. For instructions regarding how to interact with these endpoints, please see the specifications at openid.net/connect.

Tokens

We are using the SECOAUTH TokenEndpoint, with several custom beans injected that allow us to customize the tokens we produce and consume. We are using structured JWT (JSON Web Token) Bearer tokens. These tokens can be optionally signed using the JWE / JWK specifications.

The JWT library, currently in openid-connect-common, handles serialization/deserialization and manipulation of JWTs. Our implementation of the SECOAUTH OAuth2AccessToken interface, OAuth2AccessTokenEntity, implements our JWT interface and returns the serialized version of the JWT from its Value field.

For more information:

Users

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

An in-memory Authentication Manager is configured in user-context.xml.

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

Clients

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

Maven War Overlay

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.

How to set up an Overlay Project


*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.

Clone this wiki locally