Skip to content

Commit

Permalink
Rebrand to polyvariant (polyvariant#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
majk-p authored May 7, 2024
1 parent 303633e commit 058f999
Show file tree
Hide file tree
Showing 86 changed files with 402 additions and 392 deletions.
6 changes: 6 additions & 0 deletions .jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-Dfile.encoding=UTF8
-Xms1G
-Xmx5G
-XX:ReservedCodeCacheSize=500M
-XX:+TieredCompilation
-XX:+UseParallelGC
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[release]: https://github.com/ocadotechnology/sttp-oauth2/releases/latest
[release-badge]: https://img.shields.io/github/release/ocadotechnology/sttp-oauth2.svg
[release]: https://github.com/polyvariant/sttp-oauth2/releases/latest
[release-badge]: https://img.shields.io/github/release/polyvariant/sttp-oauth2.svg

# sttp-oauth2 - OAuth2 client library for Scala

Expand All @@ -14,6 +14,14 @@ Currently it supports methods (grant types) for obtaining authorization:

To use this library add the following dependency to your `build.sbt`

Versions 0.19.0 and newer

```scala
"org.polyvariant" %% "sttp-oauth2" % "x.y.z"
```

Versions up to 0.18.0

```scala
"com.ocadotechnology" %% "sttp-oauth2" % "x.y.z"
```
Expand All @@ -22,7 +30,7 @@ The latest release is: [![release-badge][]][release]

## Documentation

Visit the documentation at [https://ocadotechnology.github.io/sttp-oauth2](https://ocadotechnology.github.io/sttp-oauth2/) for usage instructions.
Visit the documentation at [https://polyvariant.github.io/sttp-oauth2](https://polyvariant.github.io/sttp-oauth2/) for usage instructions.

## Contributing

Expand All @@ -32,4 +40,6 @@ Feel free to submit feature requests and bug reports under Issues.

sttp-oauth2 is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) (the "License"); you may not use this software except in compliance with the License.

Copyright © 2022 Ocado
## Honorable mentions

sttp-oauth2 was initially created by [Ocado Technology](https://github.com/ocadotechnology)
18 changes: 3 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,15 @@ import sbtghactions.UseRef

inThisBuild(
List(
organization := "com.ocadotechnology",
homepage := Some(url("https://github.com/ocadotechnology/sttp-oauth2")),
organization := "com.ocadotechnology", // intentionally left intact just for publishing, will be replaced for 0.19.0
homepage := Some(url("https://github.com/polyvariant/sttp-oauth2")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"majk-p",
"Michał Pawlik",
"[email protected]",
"[email protected]",
url("https://michalp.net")
),
Developer(
"tplaskowski",
"Tomek Pląskowski",
"[email protected]",
url("https://github.com/tplaskowski")
),
Developer(
"matwojcik",
"Mateusz Wójcik",
"[email protected]",
url("https://github.com/matwojcik")
)
),
versionScheme := Some("early-semver")
Expand Down
8 changes: 4 additions & 4 deletions docs/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ As the user of the library you can either choose to implement your own cache mec

| Class |Description | Import module |
|---------------------------|-------------------------------------------------------------|-------------------|
| `CatsRefExpiringCache` | Simple Cats Effect 3 Ref based implementation. Good enough for `CachingAccessTokenProvider`, but for `CachingTokenIntrospection` it's recommended to use an instance which better handles memory (this instance does not periodically remove expired entries) | `"com.ocadotechnology" %% "sttp-oauth2-cache-cats" % "@VERSION@"` |
| `CatsRefExpiringCache` | Simple Cats Effect 2 Ref based implementation. Good enough for `CachingAccessTokenProvider`, but for `CachingTokenIntrospection` it's recommended to use an instance which better handles memory (this instance does not periodically remove expired entries) | `"com.ocadotechnology" %% "sttp-oauth2-cache-ce2" % "@VERSION@"` |
| `ScalacacheExpiringCache` | Implementation based on https://github.com/cb372/scalacache | `"com.ocadotechnology" %% "sttp-oauth2-cache-scalacache" % "@VERSION@"` |
| `MonixFutureCache` | Future based implementation powered by [Monix](https://monix.io/) | `"com.ocadotechnology" %% "sttp-oauth2-cache-future" % "@VERSION@"` |
| `CatsRefExpiringCache` | Simple Cats Effect 3 Ref based implementation. Good enough for `CachingAccessTokenProvider`, but for `CachingTokenIntrospection` it's recommended to use an instance which better handles memory (this instance does not periodically remove expired entries) | `"org.polyvariant" %% "sttp-oauth2-cache-cats" % "@VERSION@"` |
| `CatsRefExpiringCache` | Simple Cats Effect 2 Ref based implementation. Good enough for `CachingAccessTokenProvider`, but for `CachingTokenIntrospection` it's recommended to use an instance which better handles memory (this instance does not periodically remove expired entries) | `"org.polyvariant" %% "sttp-oauth2-cache-ce2" % "@VERSION@"` |
| `ScalacacheExpiringCache` | Implementation based on https://github.com/cb372/scalacache | `"org.polyvariant" %% "sttp-oauth2-cache-scalacache" % "@VERSION@"` |
| `MonixFutureCache` | Future based implementation powered by [Monix](https://monix.io/) | `"org.polyvariant" %% "sttp-oauth2-cache-future" % "@VERSION@"` |

2 changes: 1 addition & 1 deletion docs/client-credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: Client credentials grant documentation
- `introspect` the token for its details like `UserInfo`

```scala
import com.ocadotechnology.sttp.oauth2.json.circe.instances._ // Or your favorite JSON implementation
import org.polyvariant.sttp.oauth2.json.circe.instances._ // Or your favorite JSON implementation

val accessTokenProvider = AccessTokenProvider[IO](tokenUrl, clientId, clientSecret)(backend)
val tokenIntrospection = TokenIntrospection[IO](tokenIntrospectionUrl, clientId, clientSecret)(backend)
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ The raw documentation goes through a few steps process before the final website
## Adding JSON implementations
When adding a JSON implementation please follow the subsequent guidelines:
1. Each JSON implementation should exist in a separate module, not to introduce unwanted dependencies.
2. It should expose all necessary `JsonDecoder`s via a single import following the `import com.ocadotechnology.sttp.oauth2.json.<insert-json-library-name-here>.instances._` convention.
3. It should make use of `com.ocadotechnology.sttp.oauth2.json.JsonSpec` test suite to ensure correctness.
2. It should expose all necessary `JsonDecoder`s via a single import following the `import org.polyvariant.sttp.oauth2.json.<insert-json-library-name-here>.instances._` convention.
3. It should make use of `org.polyvariant.sttp.oauth2.json.JsonSpec` test suite to ensure correctness.
4. It should be included in the documentation ([JSON Deserialisation](json-deserialisation.md)).
6 changes: 3 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ There are multiple JSON implementations, see [JSON deserialisation](json-deseria

To use this library add following dependency to your `build.sbt` file
```scala
"com.ocadotechnology" %% "sttp-oauth2" % "@VERSION@"
"com.ocadotechnology" %% "sttp-oauth2-circe" % "@VERSION@" // Or other, see JSON support
"org.polyvariant" %% "sttp-oauth2" % "@VERSION@"
"org.polyvariant" %% "sttp-oauth2-circe" % "@VERSION@" // Or other, see JSON support
```
## Usage

Expand All @@ -25,7 +25,7 @@ Each grant is implemented in an object with explicit return and error types on m

All grant implementations require a set of implicit `JsonDecoder`s, e.g.:
```scala
import com.ocadotechnology.sttp.oauth2.json.circe.instances._
import org.polyvariant.sttp.oauth2.json.circe.instances._
```

See [JSON deserialisation](json-deserialisation.md) for details.
8 changes: 4 additions & 4 deletions docs/json-deserialisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ To use [circe](https://github.com/circe/circe) implementation
add the following module to your dependencies:

```scala
"com.ocadotechnology" %% "sttp-oauth2-circe" % "@VERSION@"
"org.polyvariant" %% "sttp-oauth2-circe" % "@VERSION@"
```

Then import appropriate set of implicit instances:

```scala
import com.ocadotechnology.sttp.oauth2.json.circe.instances._
import org.polyvariant.sttp.oauth2.json.circe.instances._
```

## jsoniter-scala
To use [jsoniter-scala](https://github.com/plokhotnyuk/jsoniter-scala) implementation
add the following module to your dependencies:

```scala
"com.ocadotechnology" %% "sttp-oauth2-jsoniter" % "@VERSION@"
"org.polyvariant" %% "sttp-oauth2-jsoniter" % "@VERSION@"
```

Then import appropriate set of implicit instances:

```scala
import com.ocadotechnology.sttp.oauth2.json.jsoniter.instances._
import org.polyvariant.sttp.oauth2.json.jsoniter.instances._
```
28 changes: 14 additions & 14 deletions docs/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,48 @@ description: Migrations

Some releases introduce breaking changes. This page aims to list those and provide migration guide.

## [v0.17.0-RC-1](https://github.com/ocadotechnology/sttp-oauth2/releases/tag/v0.17.0)
## [v0.17.0-RC-1](https://github.com/polyvariant/sttp-oauth2/releases/tag/v0.17.0)

Significant changes were introduced due to separation of JSON deserialisation from the core. Adding a module
with chosen JSON implementation is now required, as is importing an associated set of `JsonDecoder`s.

For backwards compatibility just add `circe` module:

```scala
"com.ocadotechnology" %% "sttp-oauth2-circe" % "0.16.0"
"org.polyvariant" %% "sttp-oauth2-circe" % "0.16.0"
```

and a following import where you were using `sttp-oauth2`:

```scala
import com.ocadotechnology.sttp.oauth2.json.circe.instances._
import org.polyvariant.sttp.oauth2.json.circe.instances._
```

## [v0.16.0](https://github.com/ocadotechnology/sttp-oauth2/releases/tag/v0.16.0)
## [v0.16.0](https://github.com/polyvariant/sttp-oauth2/releases/tag/v0.16.0)

Minor change [#336](https://github.com/ocadotechnology/sttp-oauth2/pull/336) removed implicit parameter
Minor change [#336](https://github.com/polyvariant/sttp-oauth2/pull/336) removed implicit parameter
of `cats.MonadThrow` in some methods. As long as your code just uses these methods (doesn't override or mock
interfaces), you have to only solve warnings suggesting that there are unused parameters. Otherwise,
remove `: MonadError` from inherited implementations.

Affected classes: `PasswordGrant`, `PasswordGrantProvider`, `SttpOauth2ClientCredentialsBackend`, `UserInfoProvider`

## [v0.15.0](https://github.com/ocadotechnology/sttp-oauth2/releases/tag/v0.15.0)
## [v0.15.0](https://github.com/polyvariant/sttp-oauth2/releases/tag/v0.15.0)

### Breaking change in authorization code grant

In [#273](https://github.com/ocadotechnology/sttp-oauth2/pull/273) we have switched from using `withPath` to `addPath` in `AuthorizationCode` and `AuthorizationCodeProvider`.
In [#273](https://github.com/polyvariant/sttp-oauth2/pull/273) we have switched from using `withPath` to `addPath` in `AuthorizationCode` and `AuthorizationCodeProvider`.

If you were instantiating `AuthorizationCodeProvider` or using `AuthorizationCode` providing `baseUri` with path included, this would strip the path. Since `0.15.0` this is no longer the case. If you relied on this behavior, please remove the path from the provided URL before creating the instance.

## [v0.14.0](https://github.com/ocadotechnology/sttp-oauth2/releases/tag/v0.14.0)
## [v0.14.0](https://github.com/polyvariant/sttp-oauth2/releases/tag/v0.14.0)

Due to Scala 3 support `Scope.refine` Refined macro has been removed. Scope object now extends `RefinedTypeOps[Scope, String]`.
To parse `Scope` use `Scope.of` or other functions provided by `RefinedTypeOps` - `from`, `unsafeFrom` or `unapply`.

Since this version, scope is also made optional in [#199](https://github.com/ocadotechnology/sttp-oauth2/pull/199) to match the [spec](https://datatracker.ietf.org/doc/html/rfc6749#section-3.3).
Since this version, scope is also made optional in [#199](https://github.com/polyvariant/sttp-oauth2/pull/199) to match the [spec](https://datatracker.ietf.org/doc/html/rfc6749#section-3.3).

## [v0.12.0](https://github.com/ocadotechnology/sttp-oauth2/releases/tag/v0.12.0)
## [v0.12.0](https://github.com/polyvariant/sttp-oauth2/releases/tag/v0.12.0)

### `SttpBackend` no more passed as implicit param

Expand Down Expand Up @@ -89,7 +89,7 @@ CachingAccessTokenProvider.refCacheInstance[IO](accessTokenProvider).map { cachi
}
```

For details please see [PR](https://github.com/ocadotechnology/sttp-oauth2/pull/149).
For details please see [PR](https://github.com/polyvariant/sttp-oauth2/pull/149).

### Apply

Expand All @@ -106,14 +106,14 @@ ClientCredentialsProvider[IO](tokenUrl, tokenIntrospectionUrl, clientId, clientS
```


## [v0.10.0](https://github.com/ocadotechnology/sttp-oauth2/releases/tag/v0.5.0)
## [v0.10.0](https://github.com/polyvariant/sttp-oauth2/releases/tag/v0.5.0)

`authCodeToToken` and `refreshAccessToken` no longer return fixed token response type. Instead, they require `RT <: OAuth2TokenResponse.Basic: Decoder` type parameter, that describes desired. response structure.

There are two matching pre-defined types provided:
- `OAuth2TokenResponse` - minimal response as described by [rfc6749](https://datatracker.ietf.org/doc/html/rfc6749#section-5.1)
- `ExtendedOAuth2TokenResponse` - previously known as `Oauth2TokenResponse`, the previously fixed response type. Use this for backward compatiblity.

## [v0.5.0](https://github.com/ocadotechnology/sttp-oauth2/releases/tag/v0.5.0)
## [v0.5.0](https://github.com/polyvariant/sttp-oauth2/releases/tag/v0.5.0)

This version introduces [sttp3](https://github.com/ocadotechnology/sttp-oauth2/pull/39). Please see [sttp v3.0.0 release](https://github.com/softwaremill/sttp/releases/tag/v3.0.0) for migration guide.
This version introduces [sttp3](https://github.com/polyvariant/sttp-oauth2/pull/39). Please see [sttp v3.0.0 release](https://github.com/softwaremill/sttp/releases/tag/v3.0.0) for migration guide.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.ocadotechnology.sttp.oauth2.cache.cats
package org.polyvariant.sttp.oauth2.cache.cats

import cats.data.OptionT
import cats.effect.kernel.Clock
import cats.effect.kernel.Concurrent
import cats.effect.kernel.MonadCancelThrow
import cats.effect.std.Semaphore
import cats.syntax.all._
import com.ocadotechnology.sttp.oauth2.AccessTokenProvider
import com.ocadotechnology.sttp.oauth2.ClientCredentialsToken
import com.ocadotechnology.sttp.oauth2.Secret
import com.ocadotechnology.sttp.oauth2.cache.ExpiringCache
import com.ocadotechnology.sttp.oauth2.cache.cats.CachingAccessTokenProvider.TokenWithExpirationTime
import com.ocadotechnology.sttp.oauth2.common.Scope
import org.polyvariant.sttp.oauth2.AccessTokenProvider
import org.polyvariant.sttp.oauth2.ClientCredentialsToken
import org.polyvariant.sttp.oauth2.Secret
import org.polyvariant.sttp.oauth2.cache.ExpiringCache
import org.polyvariant.sttp.oauth2.cache.cats.CachingAccessTokenProvider.TokenWithExpirationTime
import org.polyvariant.sttp.oauth2.common.Scope

import java.time.Instant
import scala.concurrent.duration.Duration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.ocadotechnology.sttp.oauth2.cache.cats
package org.polyvariant.sttp.oauth2.cache.cats

import cats.data.OptionT
import cats.effect.kernel.Clock
import cats.effect.kernel.MonadCancelThrow
import cats.implicits._
import com.ocadotechnology.sttp.oauth2.Introspection.TokenIntrospectionResponse
import com.ocadotechnology.sttp.oauth2.Secret
import com.ocadotechnology.sttp.oauth2.TokenIntrospection
import com.ocadotechnology.sttp.oauth2.cache.ExpiringCache
import org.polyvariant.sttp.oauth2.Introspection.TokenIntrospectionResponse
import org.polyvariant.sttp.oauth2.Secret
import org.polyvariant.sttp.oauth2.TokenIntrospection
import org.polyvariant.sttp.oauth2.cache.ExpiringCache

import java.time.Instant
import scala.concurrent.duration._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.ocadotechnology.sttp.oauth2.cache.cats
package org.polyvariant.sttp.oauth2.cache.cats

import cats.Monad
import cats.data.OptionT
import cats.effect.kernel.Clock
import cats.effect.kernel.Ref
import cats.implicits._
import com.ocadotechnology.sttp.oauth2.cache.ExpiringCache
import com.ocadotechnology.sttp.oauth2.cache.cats.CatsRefExpiringCache.Entry
import org.polyvariant.sttp.oauth2.cache.ExpiringCache
import org.polyvariant.sttp.oauth2.cache.cats.CatsRefExpiringCache.Entry

import java.time.Instant

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.ocadotechnology.sttp.oauth2.cache.cats
package org.polyvariant.sttp.oauth2.cache.cats

import cats.effect.IO
import cats.effect.Ref
import cats.effect.Temporal
import cats.effect.unsafe.implicits.global
import cats.syntax.all._
import com.ocadotechnology.sttp.oauth2.ClientCredentialsToken.AccessTokenResponse
import com.ocadotechnology.sttp.oauth2.AccessTokenProvider
import com.ocadotechnology.sttp.oauth2.Secret
import com.ocadotechnology.sttp.oauth2.cache.ExpiringCache
import com.ocadotechnology.sttp.oauth2.cache.cats.CachingAccessTokenProvider.TokenWithExpirationTime
import com.ocadotechnology.sttp.oauth2.common.Scope
import org.polyvariant.sttp.oauth2.ClientCredentialsToken.AccessTokenResponse
import org.polyvariant.sttp.oauth2.AccessTokenProvider
import org.polyvariant.sttp.oauth2.Secret
import org.polyvariant.sttp.oauth2.cache.ExpiringCache
import org.polyvariant.sttp.oauth2.cache.cats.CachingAccessTokenProvider.TokenWithExpirationTime
import org.polyvariant.sttp.oauth2.common.Scope
import org.scalatest.Assertion
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.ocadotechnology.sttp.oauth2.cache.cats
package org.polyvariant.sttp.oauth2.cache.cats

import cats.effect.IO
import cats.effect.Ref
import cats.effect.kernel.Outcome.Succeeded
import cats.effect.testkit.TestContext
import cats.effect.testkit.TestInstances
import com.ocadotechnology.sttp.oauth2.AccessTokenProvider
import com.ocadotechnology.sttp.oauth2.ClientCredentialsToken.AccessTokenResponse
import com.ocadotechnology.sttp.oauth2.Secret
import com.ocadotechnology.sttp.oauth2.cache.cats.CachingAccessTokenProvider.TokenWithExpirationTime
import com.ocadotechnology.sttp.oauth2.common.Scope
import org.polyvariant.sttp.oauth2.AccessTokenProvider
import org.polyvariant.sttp.oauth2.ClientCredentialsToken.AccessTokenResponse
import org.polyvariant.sttp.oauth2.Secret
import org.polyvariant.sttp.oauth2.cache.cats.CachingAccessTokenProvider.TokenWithExpirationTime
import org.polyvariant.sttp.oauth2.common.Scope
import org.scalatest.Assertion
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ocadotechnology.sttp.oauth2.cache.cats
package org.polyvariant.sttp.oauth2.cache.cats

import cats.Functor
import cats.effect.IO
Expand All @@ -8,9 +8,9 @@ import cats.effect.kernel.Outcome.Succeeded
import cats.effect.testkit.TestContext
import cats.effect.testkit.TestInstances
import cats.implicits._
import com.ocadotechnology.sttp.oauth2.Introspection.TokenIntrospectionResponse
import com.ocadotechnology.sttp.oauth2.Secret
import com.ocadotechnology.sttp.oauth2.TokenIntrospection
import org.polyvariant.sttp.oauth2.Introspection.TokenIntrospectionResponse
import org.polyvariant.sttp.oauth2.Secret
import org.polyvariant.sttp.oauth2.TokenIntrospection
import org.scalatest.Assertion
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.ocadotechnology.sttp.oauth2.cache.cats
package org.polyvariant.sttp.oauth2.cache.cats

import cats.effect.IO
import cats.effect.kernel.Outcome.Succeeded
import cats.effect.testkit.TestContext
import cats.effect.testkit.TestInstances
import com.ocadotechnology.sttp.oauth2.cache.cats.CatsRefExpiringCache.Entry
import org.polyvariant.sttp.oauth2.cache.cats.CatsRefExpiringCache.Entry
import org.scalatest.Assertion
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down
Loading

0 comments on commit 058f999

Please sign in to comment.