SMART COSMOS Sample User Details Service

Devkit implementation of user details service for OAuth

License

License

Categories

Categories

Net
GroupId

GroupId

net.smartcosmos
ArtifactId

ArtifactId

smartcosmos-user-details-devkit
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

SMART COSMOS Sample User Details Service
Devkit implementation of user details service for OAuth
Project URL

Project URL

http://smartcosmos.net/smartcosmos-user-details-devkit
Project Organization

Project Organization

Smartrac Technology Fletcher, Inc.
Source Code Management

Source Code Management

https://github.com/SMARTRACTECHNOLOGY/smartcosmos-user-details-devkit/tree/master/

Download smartcosmos-user-details-devkit

How to add to project

<!-- https://jarcasting.com/artifacts/net.smartcosmos/smartcosmos-user-details-devkit/ -->
<dependency>
    <groupId>net.smartcosmos</groupId>
    <artifactId>smartcosmos-user-details-devkit</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.smartcosmos/smartcosmos-user-details-devkit/
implementation 'net.smartcosmos:smartcosmos-user-details-devkit:3.0.0'
// https://jarcasting.com/artifacts/net.smartcosmos/smartcosmos-user-details-devkit/
implementation ("net.smartcosmos:smartcosmos-user-details-devkit:3.0.0")
'net.smartcosmos:smartcosmos-user-details-devkit:jar:3.0.0'
<dependency org="net.smartcosmos" name="smartcosmos-user-details-devkit" rev="3.0.0">
  <artifact name="smartcosmos-user-details-devkit" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.smartcosmos', module='smartcosmos-user-details-devkit', version='3.0.0')
)
libraryDependencies += "net.smartcosmos" % "smartcosmos-user-details-devkit" % "3.0.0"
[net.smartcosmos/smartcosmos-user-details-devkit "3.0.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.commons : commons-collections4 jar 4.1
org.mariadb.jdbc : mariadb-java-client jar 1.4.3
net.smartcosmos : smartcosmos-framework jar 3.0.0
net.smartcosmos : smartcosmos-user-entity-devkit jar 3.0.0

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.6

test (10)

Group / Artifact Type Version
com.h2database : h2 jar
org.hamcrest : hamcrest-core jar
org.hamcrest : hamcrest-library jar
org.json : json jar
com.jayway.jsonpath : json-path jar
com.jayway.jsonpath : json-path-assert jar
org.mapstruct : mapstruct jar 1.0.0.Final
net.smartcosmos : smartcosmos-framework-test jar 3.0.0
org.springframework.boot : spring-boot-starter-test jar
com.jayway.restassured : spring-mock-mvc jar

Project Modules

There are no modules declared in this project.

SMART COSMOS DevKit User Details Service

Build Status

Microservice which provides user authorties for OAuth token generation.

It uses the same database as the edge-user-devkit service for user, tenant, role and authority management, see user-entity-devkit.

Code and documentation copyright 2016 Smartrac Technology Fletcher, Inc. Code released under Apache 2.0 License.

REST API

Available methods

Authenticate - POST /authenticate

POST /authenticate
{
    "details": {
        "grant_type": "password",
        "scope": "read",
        "username": "bob"
    },
    "authorities": [],
    "authenticated": false,
    "principal": "bob",
    "credentials": "xyz1234567",
    "name": "bob"
}
Response
200 OK
{
    "userUrn": "urn:user:uuid:68a76616-3748-4bc2-93c1-3940b47abb7f",
    "username": "bob",
    "passwordHash": "",
    "authorities": [
        "https://authorities.smartcosmos.net/things/read",
        "https://authorities.smartcosmos.net/things/create"
    ],
    "tenantUrn": "urn:tenant:uuid:69bb7c6a-a43b-493d-8e9d-e5a3ed65728a"
}
400 Bad Request
{
    "code": 1,
    "message": "Invalid username or password"
}

Active (used for Token Refresh) - GET /active/{username}

This endpoint requires HTTP Basic Authentication.

GET /active/[email protected]
Response
200 OK
{
   "authorities" : [
      "https://authorities.smartcosmos.net/things/read"
   ],
   "tenantUrn" : "urn:account:uuid:53f452c2-5a01-44fd-9956-3ecff7c32b30",
   "userUrn" : "urn:user:uuid:53f452c2-5a01-44fd-9956-3ecff7c32b30",
   "name" : "[email protected]",
   "passwordHash" : ""
}
400 Bad Request
{
   "code" : 1,
   "message" : "Invalid username or password"
}
401 Unauthorized

Configuration

The user details service needs to be properly configured for the following purposes:

  • accessing the user database

  • getting called by the auth server for authority provision

server:
  port: 5555

spring:
  datasource:
    url: jdbc:mysql://localhost/{dbName}?autoReconnect=true
    username: {dbUser}
    password: {dbPassword}
    driver-class-name: org.mariadb.jdbc.Driver
  jpa:
    hibernate:
      # Edge User DevKit and User Details DevKit share the database scheme, but the details service just reads
      ddl-auto: verify
      naming_strategy: org.hibernate.cfg.EJB3NamingStrategy

smartcosmos:
  security:
    enabled: true
    resource:
      user-details:
        name: {authClientName}
        password: {authClientPassword}
net.smartcosmos

Smart Cosmos Solutions Inc.

Versions

Version
3.0.0