GithubHelp home page GithubHelp logo

sysnajar / auth10-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from auth10/auth10-java

0.0 2.0 0.0 239 KB

WSFederation and SAML library for Java based web applications

License: Apache License 2.0

auth10-java's Introduction

This library speaks the WS-Federation protocol and SAML 1.1 and 2.0 tokens. It interops fine with Microsoft-related products like ADFS, Windows Azure Active Directory and Windows Identity Foundation.

The code is a simplified version with some improvements of the library released by Microsoft https://github.com/WindowsAzure/azure-sdk-for-java-samples.

Usage

Clone it

git clone https://github.com/auth10/auth10-java.git

Or download it as zip from https://github.com/auth10/auth10-java/zipball/master

Import the Maven that was just downloaded in your project (File -> Import -> Existing Maven Projects)

Add a reference to com.auth10.federation library from your project. Edit your project Maven file pom.xml and add this:

<dependencies>
	...
	<dependency>
		<groupId>com.auth10.federation</groupId>
		<artifactId>auth10-federation</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</dependency>
	...
</dependencies>

Add a federation.properties file under resources folder:

federation.trustedissuers.issuer=https://your_identity_provider/
federation.trustedissuers.thumbprint=CF50166CE4B....signing cert thumbprint...4DA668F96BF
federation.trustedissuers.friendlyname=My Identity Provider
federation.audienceuris=http://localhost:8080/sample-federation/
federation.realm=http://localhost:8080/sample-federation/
federation.enableManualRedirect=false

Add the WSFederationFilter to the web.xml file:

<filter>
  <filter-name>FederationFilter</filter-name>
  <filter-class>com.auth10.federation.WSFederationFilter</filter-class>
  <init-param>
    <param-name>login-page-url</param-name>
    <!-- this is used only if manual redirect is enabled. Otherwise the user will be automatically redirected to the identity provider when browsing the website -->
    <param-value>login.jsp</param-value>
  </init-param>
  <init-param>
    <param-name>exclude-urls-regex</param-name>
    <!-- e.g.: public folder won't be affected by the filter. To add more concat with pipe (|) -->
    <param-value>/public/*</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>FederationFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

Consuming user attributes

// gets the user name
String name = request.getRemoteUser();

// gets the user claims
List<Claim> claims = ((FederatedPrincipal)request.getUserPrincipal()).getClaims()

auth10-java's People

Contributors

woloski avatar

Watchers

 avatar  avatar

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.