Commit Graph

288 Commits

Author SHA1 Message Date
Antti Peltonen
7638946508 work started on adc implementation 2021-11-21 09:57:06 +01:00
James Hinshelwood
be86791762 Add token deserialization workaround
This fixes token deserialization when the
serde_json/arbitrary_precision feature is enabled.

See https://github.com/serde-rs/json/issues/559 for details.

Co-authored-by: James Hinshelwood <james.hinshelwood@bigpayme.com>
2021-09-15 15:58:09 +01:00
Simonas Kazlauskas
469f045247 Use a test matrix to test feature combinations 2021-06-29 14:07:53 +03:00
Simonas Kazlauskas
dd004fed3c Implement an ability to work without default client 2021-06-29 13:30:40 +03:00
Simonas Kazlauskas
d385601433 --all-features and --no-default-features
This adjusts the code and documentation for `--all-features` and
`--no-default-features` to work correctly. With `--no-default-features`
no `DefaultAuthenticator` is made available. Users are in control of
picking the `Connector` they want to use, and are not forced to stomach
a dependency on `rustls` or `hyper-tls` if their TLS implementation of
choice doesn't happen to match one of the two.

To indicate this, the unstable `doc_cfg` feature is used to build
documentation on docs.rs. That way the generated documentation has
notices on these types that look as such:

> This is supported on crate features hyper-rustls or hyper-tls only.

Additionally this functionality is tested via additional coverage in the
Actions' CI.
2021-06-29 12:57:57 +03:00
Lewin Bormann
e63aa4b843 Merge pull request #146 from djrodgerspryor/custom_storage_options
Custom token storage
2021-04-01 22:53:36 +02:00
Daniel Rodgers-Pryor
e9facaef5d Remove now irrelevant comment about ScopeSets 2021-03-26 20:48:06 +11:00
Daniel Rodgers-Pryor
6e4503f55e Simplify with_storage interface
By only allowing a custom storage. To use one of the built-in storage mechanism, there is already a special-purpose `persist_tokens_to_disk` method available.
2021-03-25 21:20:21 +11:00
Daniel Rodgers-Pryor
089543f6c9 Remove unnecessary deref 2021-03-25 21:13:35 +11:00
Daniel Rodgers-Pryor
fbf6c17916 Expose TokenInfo fields publically
For easier debugging, and for implementing custom storage solutions which might not use serde.
2021-03-25 21:11:26 +11:00
Daniel Rodgers-Pryor
98ee92f8b2 Don't publish the ScopeSet struct
Just pass `&[&str]` into custom storage providers. The scopeset struct has a range of unnecessary internal features.

It's now also part of the interface for custom storage providers that the given scopes will be both unique and sorted.

The only slightly awkward thing is that there's no conventient way to expose a `scopes_covered_by` helper method (which almost all custom storage engines will need), but it's still included in the example code.
2021-03-25 21:08:12 +11:00
Lewin Bormann
0079473374 Merge pull request #151 from dermesser/feature/authenticator-clone
Make Authenticator Clone
2021-03-06 10:22:20 +01:00
Lewin Bormann
68dba11408 Run rustfmt 2021-03-06 10:20:32 +01:00
Lewin Bormann
83296afc83 Run rustfmt on authenticator.rs 2021-03-04 19:33:08 +01:00
Lewin Bormann
9a29525cd7 Move to literal string in panic! macro 2021-03-04 19:32:31 +01:00
Lewin Bormann
010668cc62 Make Authenticator Clone 2021-03-04 19:32:20 +01:00
Daniel Rodgers-Pryor
384963e091 Revert mutable authenticator interface change
Instead, suggest using interior mutability (and RwLock in the example) to manage storage of token states. This makes it easier to share authenticators between threads.
2021-02-06 22:59:00 +11:00
Daniel Rodgers-Pryor
5ef498f801 Custom token storage
Allow users to build their own token storage system by implementing the `TokenStorage` trait. This allows use of more secure storage mechanisms like OS keychains, encrypted files, or secret-management tools.

Custom storage providers are Box-ed to avoid adding more generics to the API — the indirection cost will only apply if using a custom store.

I've added `anyhow` to allow easy handling of a wide range of errors from custom storage providers.
2021-02-06 22:59:00 +11:00
Lyon Beckers
5b1facf7a0 Merge branch 'master' of https://github.com/lyonbeckers/yup-oauth2 into option_hyper_tls 2021-02-01 07:18:48 -07:00
Lyon Beckers
26db4b6efc introduced a feature which allows the use of hyper-tls instead of hyper-rustls 2021-01-29 16:58:06 -07:00
Michael Bryant
3ca0164908 fix lint 2021-01-25 14:13:42 -08:00
Michael Bryant
6c433a6fb5 installed flow: support urls with existing query params 2021-01-25 09:53:22 -08:00
Lewin Bormann
864f918496 Merge pull request #138 from maximebedard/bump-tokio-0-3
Bump to tokio 1.0 and hyper 0.14
2020-12-27 09:05:14 +01:00
Maxime Bedard
07bc4803c0 update hyper-rustls to 0.22 2020-12-26 19:30:43 -05:00
Maxime Bedard
ec28689080 bump hyper=0.14, tokio=1.0, hyper-rustls, httptest 2020-12-24 09:31:18 -05:00
Lewin Bormann
b59c617027 Doc: Remove reference to DeviceFlowHelper to fix #140.
Oh boy, that was removed in 2015...
2020-12-03 21:27:30 +01:00
Maxime Bedard
4026d92cf6 Bump to tokio 0.3 and hyper 0.14 2020-11-12 20:31:19 -05:00
Lewin Bormann
9bf40bef5b Authenticator: Switch from keep_alive to pool_max_idle_per_host 2020-10-27 11:10:57 +01:00
Lewin Bormann
d193431465 Make two more application secret types Debug 2020-10-27 11:10:30 +01:00
Lewin Bormann
4660676073 Revert "Upgrade tokio -> 0.3: Bump version to v5.0.0"
This reverts commit e07bc6f471.

Hyper and tokio 0.3 don't work together yet.
2020-10-20 17:47:39 +02:00
Lewin Bormann
e07bc6f471 Upgrade tokio -> 0.3: Bump version to v5.0.0 2020-10-20 16:28:46 +02:00
Elmar Athmer
43c8a3d77d fix 'subject' name in service-account claim
As indicated by
https://developers.google.com/identity/protocols/oauth2/service-account#httprest
the name for the subject-field inside the JWT claim needs to be named
'sub' (instead of 'subject').
This is relevant e.g. for the GSuite Admin Directory API.
2020-05-28 17:23:15 +02:00
George Hahn
b891e9e670 Expose default authenticator type
This allows downstream users to avoid a dependency on hyper
2020-05-01 11:25:25 -05:00
Abdul Rehman
09d1f05a00 feat: Use futures-aware mutex 2020-04-06 15:31:49 +05:00
Lewin Bormann
35157400ad chore(rustfmt): Run rustfmt 2020-03-16 19:15:14 +01:00
Lewin Bormann
1e492c7393 feat(refresh): Allow forcing Authenticator to refresh a token
On #125
2020-03-16 18:33:15 +01:00
Lewin Bormann
c70956269b chore(lint): Run rustfmt 2020-02-16 20:57:20 +01:00
Simonas Kazlauskas
05ee4a4cee chore(*): update the dependencies 2020-02-06 23:20:26 +02:00
Steven 'Steve' Kendall
76ecfea853 Merge remote-tracking branch 'upstream/master' into two-steps-docfix 2020-01-17 14:45:16 -05:00
Steven 'Steve' Kendall
aedac1b423 fixup // to /// for DeviceFlow doc 2020-01-14 15:05:26 -05:00
Glenn Griffin
9238153723 Move to hyper 0.13.1!!!! 2019-12-18 09:07:45 -08:00
Glenn Griffin
348a59d96e Create the token file with more secure permissions on unix.
This creates files with 0600 permissions on unix. Still the default
permissions on non-unix platforms.
2019-12-18 09:07:45 -08:00
Glenn Griffin
5c0334ee6f Add debug logging.
Could be helpful when troubleshooting issues with various providers if
the user is able to turn on debug logging. The most critical logging
provided is the request and responses sent and received from the oauth
servers.
2019-12-18 09:07:45 -08:00
Glenn Griffin
36d186deb4 Authenticator now returns an AccessToken.
What was previously called Token is now TokenInfo and is merely an
internal implementation detail. The publicly visible type is now called
AccessToken and differs from TokenInfo by not including the refresh
token. This makes it a smaller type for users to pass around as well as
reducing the ways that a refresh token may be leaked. Since the
Authenticator is responsible for refreshing the tokens there isn't any
reason users should need to concern themselves with refresh tokens.
2019-12-18 09:07:45 -08:00
Glenn Griffin
045c3e7735 Move all the end to end tests into an integration test
All the same functionality can be tested through the publicly exposed
API providing more extensive coverage.
2019-12-18 09:07:45 -08:00
Glenn Griffin
5e39a81894 Go back to waiting for disk writes on every token set.
Defering disk writes is still probably a good idea, but unfortunately
there are some tradeoffs with rust's async story that make it non-ideal.
Ideally we would defer writes, but have a Drop impl on DiskStorage that
waited for all the deferred writes to complete. While it's trival to
create a future that waits for all deferred writes to finish it's not
currently possible to write a Drop impl that waits on a future.

It would be possible to write an inherent async fn that takes self by
value and waits for the writes, but that method would need to be
propogated up all the way to users of the library and they would need to
remember to invoke it before dropping the Authenticator.
2019-12-18 09:07:45 -08:00
Glenn Griffin
1b39ce4413 Refactor storage to only use a BTreeMap.
Keeping the same tokens in a Vec and BTreeMap created more overhead than
was warranted. It makes much more sense to simply iterator over the
BTreeMap than keep a separate Vec.
2019-12-18 09:07:45 -08:00
Glenn Griffin
497ebf61c5 Add a test to ensure that Authenticator is Send+Sync 2019-12-18 09:07:45 -08:00
Glenn Griffin
c829fb453d cargo fmt 2019-12-18 09:07:45 -08:00
Glenn Griffin
50824c7777 Use Arc<Mutex<T>> rather than Rc<RefCell<T>> in DiskStorage.
This keeps DiskStorage Sync + Send and therefore Authenticator Sync +
Send. The DiskStorage was threadsafe because JSONTokens contains a Mutex
around all the Rc<RefCell<T>> objects, but there's no way to prove to
the type system that none of the Rc's get cloned to an alias used
outside the Mutex so it's not provably safe. I'll probably reevaluate
the design here, but in the meantime the double locking is fine.
2019-12-18 09:07:45 -08:00