mongo-realm-api

MongoDB-backed Realm for Glassfish

License

License

Categories

Categories

GlassFish Container Application Servers Realm Data Databases
GroupId

GroupId

com.tadamski.glassfish
ArtifactId

ArtifactId

mongo-realm-api
Last Version

Last Version

1.0.0-beta-2
Release Date

Release Date

Type

Type

jar
Description

Description

mongo-realm-api
MongoDB-backed Realm for Glassfish

Download mongo-realm-api

How to add to project

<!-- https://jarcasting.com/artifacts/com.tadamski.glassfish/mongo-realm-api/ -->
<dependency>
    <groupId>com.tadamski.glassfish</groupId>
    <artifactId>mongo-realm-api</artifactId>
    <version>1.0.0-beta-2</version>
</dependency>
// https://jarcasting.com/artifacts/com.tadamski.glassfish/mongo-realm-api/
implementation 'com.tadamski.glassfish:mongo-realm-api:1.0.0-beta-2'
// https://jarcasting.com/artifacts/com.tadamski.glassfish/mongo-realm-api/
implementation ("com.tadamski.glassfish:mongo-realm-api:1.0.0-beta-2")
'com.tadamski.glassfish:mongo-realm-api:jar:1.0.0-beta-2'
<dependency org="com.tadamski.glassfish" name="mongo-realm-api" rev="1.0.0-beta-2">
  <artifact name="mongo-realm-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.tadamski.glassfish', module='mongo-realm-api', version='1.0.0-beta-2')
)
libraryDependencies += "com.tadamski.glassfish" % "mongo-realm-api" % "1.0.0-beta-2"
[com.tadamski.glassfish/mongo-realm-api "1.0.0-beta-2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.mongodb : mongo-java-driver jar 2.12.2

provided (1)

Group / Artifact Type Version
org.glassfish.security : security jar 3.1

Project Modules

There are no modules declared in this project.

MongoDB-backed realm for Glassfish

With Mongo-Realm you can store your users credentials directly in MongoDB with other data of your applicaton. Forget about setting up separate MySQL or LDAP server only for storing users data.

Setup

  1. download mongo-realm jar and put it in your glassfish domains lib folder (i.e. $GLASSFISH_HOME/glassfish/domains/$DOMAINNAME/lib/)
  2. at the end of $GLASSFISH_HOME/glassfish/domains/$DOMAINNAME/config/login.conf file paste:
mongoRealm { 
  com.tadamski.glassfish.mongo.realm.MongoLoginModule required; 
};
  1. create realm in glassfish using asadmin tool
asadmin create-auth-realm --classname com.tadamski.glassfish.mongo.realm.MongoRealm --property jaas-context=mongoRealm $REALM_NAME
  1. configure your applicaton to use newly created realm (in most cases few lines in web.xml will be enough)

Configuration

By default:

Mongo-Realm connects to localhost on 27017 and looks for data in users database in users collection. Informations about users are stored in separate documents [one user = one document]. Each document contains login, password simple string properties and groups with array of group names user belongs to. All passwords are hashed using SHA-512 function.

Salt property is appended to the password before hashing. For users without salt, it will be generated on the first login.

Custom configuration:

Of course defaults can be overriden. Simply add properties to realm created in 3rd step of Setup.

Property name Default value
mongo.hostname localhost
mongo.port 27017
mongo.db.name users
mongo.collection.name users
login.property login
salt.property salt
password.property password
groups.property groups
hash.function SHA-512

Versions

Version
1.0.0-beta-2
1.0.0-beta-1