/ktor-full-jwt

Ktor Authentication by JWT.

Primary LanguageKotlinApache License 2.0Apache-2.0

JWT authentication (access and refresh tokens) in Ktor

This project was created as an example of a full-fledged implementation of JWT(with access and refresh tokens) in Ktor. Project contains registration by credentials, JWT authentication, refreshing expired token and auth-provided endpoints.

Capabilities

  • User authentication by the email and password;
  • JSON forms validation;
  • Registration of users;
  • Issuing a pair of a refresh and access tokens;
  • Automatic creation of missing tables in the database;
  • Refreshing a pair of tokens using a refresh token.

Dependencies

Running

Clone the repository:

$ git clone https://github.com/Slenkis/ktor-full-jwt.git

Navigate to the repository folder:

$ cd ktor-full-jwt

Run application:

$ ./gradlew run

Documentation

Method Endpoint Wiki page
POST /api/registration User registration
POST /api/login User authentication
POST /api/refresh Refresh token
GET /users/me Get user info

Read about configuration, table schemes and more in Wiki

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

License

Project is licensing under Apache-2.0