solinftec-auth-lib

Library to helper auth-api use.


Keywords
solinftec, solinftec-auth-lib, auth-api
License
ISC
Install
npm install solinftec-auth-lib@0.0.15

Documentation

auth-lib

Library to helper auth-api use.
You can see more details of using this library in demo-auth-lib, but basically you can implement it in three steps:

Step 1

Add the dependencies in your pom.xml file

    <!--kotlin-jdk-->
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib-jdk8</artifactId>
    </dependency>

    <!--auth-lib-->
    <dependency>
        <groupId>com.github.solinftec</groupId>
        <artifactId>auth-lib</artifactId>
        <version>v1.1.4</version>
    </dependency>

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
Step 2

Start the AuthBuilder class

   private AuthBuilder auth = new AuthBuilder("app-name-owner");
Step 3

Use

create
   Token token = auth.authenticate("username", "password", "owner")
                     .generateToken();
check
   Boolean isValid = auth.check("hash-token");
clarify
   Optional<User> user = auth.clarify("hash-token");
refresh
   Token token = auth.refresh("hash-token");
update
   TokenValue tokenValue = new TokenValue();
   
   //all these are optional
   tokenValue.setUnit(1);
   tokenValue.setTime(500);
   tokenValue.setEnvironment(AuthEnvironment.BROWSER);
   tokenValue.setLanguage(AuthLanguage.ENGLISH);
   
   Token newToken = auth.update("hash-token", tokenValue);