Coder Social home page Coder Social logo

michaelarshinov / dropwizardopenid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gary-rowe/dropwizardopenid

0.0 1.0 0.0 271 KB

Template project demonstrating Dropwizard with OpenID authentication against a few providers (Google, Yahoo etc) and User/Authority annotation support.

License: Other

dropwizardopenid's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.