Base Auth2 Server

A Library to have a Oauth2 server using mongo db

License

License

MIT
Categories

Categories

H2 Data Databases
GroupId

GroupId

uk.co.caeldev
ArtifactId

ArtifactId

base-auth2-server
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Base Auth2 Server
A Library to have a Oauth2 server using mongo db
Project URL

Project URL

https://github.com/caelwinner/base-auth2-server
Source Code Management

Source Code Management

https://github.com/caelwinner/base-auth2-server.git

Download base-auth2-server

How to add to project

<!-- https://jarcasting.com/artifacts/uk.co.caeldev/base-auth2-server/ -->
<dependency>
    <groupId>uk.co.caeldev</groupId>
    <artifactId>base-auth2-server</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/uk.co.caeldev/base-auth2-server/
implementation 'uk.co.caeldev:base-auth2-server:1.0.0'
// https://jarcasting.com/artifacts/uk.co.caeldev/base-auth2-server/
implementation ("uk.co.caeldev:base-auth2-server:1.0.0")
'uk.co.caeldev:base-auth2-server:jar:1.0.0'
<dependency org="uk.co.caeldev" name="base-auth2-server" rev="1.0.0">
  <artifact name="base-auth2-server" type="jar" />
</dependency>
@Grapes(
@Grab(group='uk.co.caeldev', module='base-auth2-server', version='1.0.0')
)
libraryDependencies += "uk.co.caeldev" % "base-auth2-server" % "1.0.0"
[uk.co.caeldev/base-auth2-server "1.0.0"]

Dependencies

runtime (8)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar 2.0.1.RELEASE
org.springframework.boot : spring-boot-starter-security jar 2.0.1.RELEASE
org.springframework.security.oauth : spring-security-oauth2 jar
com.google.code.gson : gson jar 2.6.1
com.google.guava : guava jar 19.0
uk.co.caeldev : spring-security-mongo jar 3.0.2
uk.co.caeldev : spring-mvc-utils jar 0.1.9
org.apache.commons : commons-lang3 jar 3.7

test (9)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.0.1.RELEASE
org.assertj : assertj-core jar 3.5.2
uk.org.fyodor : fyodor-core jar 1.0.0
uk.org.fyodor : fyodor-junit jar 1.0.0
io.rest-assured : rest-assured jar 3.0.1
com.github.tomakehurst : wiremock jar 2.16.0
com.github.fakemongo : fongo jar 2.2.0-RC1
org.springframework.boot : spring-boot-starter-thymeleaf jar 2.0.1.RELEASE
org.thymeleaf.extras : thymeleaf-extras-springsecurity4 jar 3.0.2.RELEASE

Project Modules

There are no modules declared in this project.

Base Auth2 Server

Build Status Coverage Status

Overview

This projects provides you a basic auth2 server configuration powered by Spring Boot with the ability to plug custom login page and using Mongo DB as datastore.

Requierments

  • Java 1.8

Setup

  1. Add the dependency to your project, remember that it will work from Spring Boot 2.x onwards.
  2. add the yml or property file in order to configure a few things that you might want to customise.
  3. Add the @EnableBaseAuthServer annotation to your Spring Boot app.
@SpringBootApplication
@EnableBaseAuthServer
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}
  1. Customise the pages.

Here you have the pages that you can customise:

  • Log In
  • Authorise

and the following Urls:

  • Log in
  • Log out
  • Failure url

For each you will have to create the html, css and js files following the convention below:

resources
    static
        css
            app.css       
    templates
        authorize.html
        login.html
    application.yml    

Here you have an example of how your application properties will look like:

mongo:
  host: localhost
  port: 27017
  database: test
  username: dev
  password: dev

auth:
  logInUrl: /login
  logInViewName: login
  failureUrl: /login
  ignoreWebStaticResources:
    - /fonts/**

info:
  app:
    name: oauth2
    description: OAuth2 Provider

server:
  port: 9080
  servlet:
    context-path: /sso

DB User

Create in your mongo instance the user that you will use to access the database defined in the YML file.

db.createUser(
  {
    user: "dev",
    pwd: "dev",
    roles: [ { role: "readWrite", db: "test" } ]
  }
)

Versions

Version
1.0.0