This library aims to provide easy integration with OAuth2 providers based on OAuth2 RFC using sttp client. It uses circe for JSON serialization/deserialization.
Currently it supports methods (grant types) for obtaining authorization:
Each grant is implemented in an object with explicit return and error types on methods and additionally, TaglessFinal friendly *Provider
interface.
AuthorizationCode
andAuthorizationCodeProvider
- provide functionality for:- generating login and logout redirect links,
authCodeToToken
for converting authorization code to token,refreshAccessToken
for performing a token refresh request
PasswordGrant
andPasswordGrantProvider
, capable of performingrequestToken
to convert user login and password to oauth2 tokenClientCredentials
andClientCredentialsProvider
expose methods that:- Obtain token via
requestToken
introspect
the token for it's details likeUserInfo
- Obtain token via
- provide Client Credentials Backend, which is an interceptor for another backend and which can:
- fetch a token using ClientCredentialsProvider
- reuse the token multiple times using cache (default cache implementation may be overridden using appropriate constructor functions)
- fetch a new token if the previous one expires
- add an Authorization header to the intercepted request
Implementations:
module name | class name | default cache implementation | semaphore | notes |
---|---|---|---|---|
sttp-oauth2-backend-cats |
SttpOauth2ClientCredentialsCatsBackend |
cats-effect 's Ref |
cats-effect 's Semaphore |
|
sttp-oauth2-backend-future |
SttpOauth2ClientCredentialsFutureBackend |
monix-execution 's AtomicAny |
monix-execution 's AsyncSemaphore |
It only uses submodule of whole monix project |
The library is using sttp 3. The latest version which is using sttp 2 is 0.4.0
.
Feel free to submit feature requests and bug reports under Issues.
sttp-oauth2 is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
Copyright © 2020 Ocado