Skip to content

⚠️ OBSOLETE. DO NOT USE! Template project demonstrating Dropwizard with OpenID authentication against a few providers (Google, Yahoo etc) and User/Authority annotation support.

Notifications You must be signed in to change notification settings

gary-rowe/DropwizardOpenID

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenId Demo

This project demonstrates the following

  • Dropwizard - Serves HTML
  • OpenId - Provides integration with OpenId providers (Google, Facebook etc) see this blog post
  • Authorization - Security annotation supporting different levels of access
  • Session token cookie - Demonstrates stateless operation (but uses an in-memory cache so not horizontally scalable)
  • Markdown - see this blog post

Bug fixes

1.1.0

  • Fixed major bug with DiscoveryInformation getting lost between requests.
  • Added some Markdown demo code.
  • Designed for Dropwizard 0.6.2.

1.0.0

  • Initial release.
  • Designed for Dropwizard 0.6.1.

Getting started

From an IDE, just run the OpenIDDemoService.main() with a runtime configuration that passes application parameters of server openid-demo.yml.

From the console, just build with Maven and run it up:

mvn clean install
java -jar target/dropwizard-openid-1.1.0.jar server openid-demo.yml

Proxy settings

If you are behind a firewall you will need to set the proxy. This is configured in PublicOpenIDResource.

Authorization

Here is an example of the authorization annotation as used in PrivateInfoResource.

/**
 * @return The private home view if authenticated
 */
@GET
@Path("/home")
@Timed
@CacheControl(noCache = true)
public PublicFreemarkerView viewHome(
@RestrictedTo(Authority.ROLE_PUBLIC)
User publicUser) {

  BaseModel model = newBaseModel();
  return new PublicFreemarkerView<BaseModel>("private/home.ftl", model);

}

Adding yourself as an "admin"

The code supports different levels of authority (PUBLIC and ADMIN). To add yourself as an admin, simply edit the following code in PublicOpenIDResource to be the email address you use in your selected OpenID provider:

// Promote to admin if they have a specific email address
// (not a good way, but this is only a demo)
if ("[email protected]".equals(user.getEmailAddress())) {
  authorities.add(Authority.ROLE_ADMIN);
  log.info("Granted admin rights");
}

Where does the ASCII art come from?

The ASCII art for the startup banner was created using the online tool available at Webestools with a font of Tiza

About

⚠️ OBSOLETE. DO NOT USE! Template project demonstrating Dropwizard with OpenID authentication against a few providers (Google, Yahoo etc) and User/Authority annotation support.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages