Commit Graph

361 Commits

Author SHA1 Message Date
Lewin Bormann
ac4bebe54b Merge pull request #105 from ggriffiniii/builder-pattern
Use the builder pattern to create authenticators.
2019-08-30 08:37:55 +02:00
Glenn Griffin
fbb8c69efb Change the name of TokenGetterBuilder to AuthFlow.
I believe AuthFlow more succinctly describes the purpose of the type to
users reading documentation.
2019-08-29 11:48:29 -07:00
Glenn Griffin
ccc6601ff3 Use the builder pattern to create authenticators.
Beyond simply moving to the builder pattern for intialization this has a
few other effects.

The DeviceFlow and InstalledFlow can no longer be used without an
associated Authenticator. This is becaus they no longer have any
publicly accessible constructor. All initialization goes through the
Authenticator. This also means that the flows are always initialized
with a clone of the hyper client used by the Authenticator.

The authenticator uses the builder pattern which allows omitting
optional fields. This means that if users simply want a default hyper
client, they don't need to create one explicitly. One will be created
automatically. If users want to specify a hyper client (maybe to allow
sharing a single client between different libraries) they can still do so
by using the hyper_client method on the builder. Additionally for both
AuthenticatorDelegate's and FlowDelegate's if the user does not specify
an override the default ones will be used.

The builders are now exposed publicly with the names of Authenicator,
InstalledFlow, and DeviceFlow. The structs that actually implement those
behaviors are now hidden and only expose the GetToken trait. This means
some methods that were previously publicly accessible are no longer
available, but the methods appeared to be implementation details that
probably shouldn't have been exposed anyway.
2019-08-29 11:47:15 -07:00
Lewin Bormann
3dec512fa5 Merge pull request #103 from ggriffiniii/master
Have the installed flow http server always listen on an ephemeral port.
2019-08-29 20:06:16 +02:00
Glenn Griffin
eb2a82f685 Make listening on an ephemeral port an option rather than the default. 2019-08-29 09:59:10 -07:00
Glenn Griffin
e83ec7e25e Have the installed flow http server always listen on an ephemeral port.
Specifying a port of zero has the server listen on an ephemeral port.
Many users may not be aware of that unless they have a background in
networking where that's common practice. I'm also not able to think of
any use cases where listening on a hardcoded port would be beneficial,
so with this change I've opted to remove the ability entirely rather
than simply documenting that almost everybody should specify zero.
2019-08-09 13:59:03 -07:00
Lewin Bormann
4b4d832d91 Merge pull request #102 from ggriffiniii/master
Modify GetToken::token.
2019-08-09 10:56:24 +02:00
Glenn Griffin
e0e955b2f6 Make fixes to support rust 1.35.0
Apparently 1.36.0 added From<&String> for String.
2019-08-08 15:01:01 -07:00
Glenn Griffin
2b18f3679e Modify GetToken::token.
Change it to accept an iterator of items that can be converted to
`String`s rather than an iterator of items that can be referenced as
`&str`s.

Primarily this allows it to be called with a larger variety of inputs.
For example ::std::env::args().skip(1) can now be passed directly to
token, where before it would first need to be collected into a vector.

Since all implementations unconditionally collected the iterator into a
vector this shouldn't have any negative impact on performance and should
actually reduce the number of allocations in some uses.

It simplifies the signature since the lifetime bounds are no longer
required.
2019-08-08 14:32:24 -07:00
Lewin Bormann
460af32922 chore(version): v3.0.3-beta 2019-08-03 16:42:54 +02:00
Lewin Bormann
096981d3c4 Merge pull request #101 from andreycizov/master
newly refreshed tokens forget to remove previous ones
2019-08-02 17:08:48 +02:00
Andrey Cizov
4ad59897c3 newly refreshed tokens forget to remove previous ones 2019-08-02 15:27:49 +01:00
Lewin Bormann
97d5355927 Merge branch '#100' 2019-08-01 21:38:17 +02:00
Lewin Bormann
58af9fc36b refactor(deps): Remove dependency on openssl. 2019-08-01 21:32:22 +02:00
Andrey Cizov
9b4a3ad3f4 rustfmt not passing 2019-08-01 19:56:28 +01:00
Andrey Cizov
6cac8f5a06 enable storage to only partially reference namespaces available for tokens 2019-08-01 17:52:42 +01:00
Lewin Bormann
080df3fc77 chore(version): 3.0.2 2019-07-10 14:06:46 +02:00
Lewin Bormann
ac08ac2da2 chore(fmt): rustfmt 2019-07-10 14:06:30 +02:00
Lewin Bormann
b6ed5c812e Merge pull request #97 from markcatley/salesforce-device-flow-updates
Updates to allow retrieving a token using the device flow on Salesforce.
2019-07-10 14:05:37 +02:00
Lewin Bormann
52e02ebb00 Merge pull request #98 from markcatley/spelling
Fixing typos and spelling in comments.
2019-06-27 23:53:04 +02:00
Mark Catley
2ee218be55 Adding error logging to the Device Flow. 2019-06-28 09:49:56 +12:00
Mark Catley
ff8b3ede30 Updates to allow retrieving a token using the device flow on Salesforce. 2019-06-28 09:49:52 +12:00
Mark Catley
7459f167c5 Fixing typos and spelling in comments. 2019-06-28 09:46:59 +12:00
Lewin Bormann
57c84263c0 chore(syntax): Run rustfmt. 2019-06-22 22:49:39 +02:00
Lewin Bormann
b064129f77 fix(ServiceAccount): Fix left-over Box<Error> 2019-06-22 22:30:54 +02:00
Lewin Bormann
e108c75b48 test(coverage): Add manual coverage script. 2019-06-22 22:21:23 +02:00
Lewin Bormann
9a334e2d21 chore(version): Release v3.0.2-beta 2019-06-22 22:14:14 +02:00
Lewin Bormann
4beb0e68e2 Merge branch 'futures'
This is #94.
2019-06-22 22:13:26 +02:00
Lewin Bormann
2d94e043d8 doc(misc): Add some small missing pieces. 2019-06-22 22:03:26 +02:00
Lewin Bormann
602ea1565d refactor(errors): Move almost everything to RequestError.
This is nicer than stupid Box<dyn Error+Send> everywhere.
2019-06-22 21:53:55 +02:00
Lewin Bormann
8d6085375f doc(Installed): More documentation about InstalledFlow and new example 2019-06-22 20:25:47 +02:00
Lewin Bormann
ff015daf2d chore(fmt): Make rustfmt on Travis happy. 2019-06-22 12:33:38 +02:00
Lewin Bormann
d1952e9d67 test(Refresh): Properly process panics in RefreshFlow test. 2019-06-22 12:17:42 +02:00
Lewin Bormann
45431d83ff test(Device): Add tests for Device flow 2019-06-22 12:17:23 +02:00
Lewin Bormann
bfe481c93b test(RefreshFlow): Add end-to-end test.
This flow is not very complex, but now we have appropriate coverage.
2019-06-22 00:06:11 +02:00
Lewin Bormann
16b76b8726 test(Installed): Add end-to-end test for Installed flow.
Also using mockito. We test both the interactive and the
local-HTTP-redirect paths, as well as the interaction with the token
provider.
2019-06-21 21:47:35 +02:00
Lewin Bormann
33babd3d53 test(ServiceAccount): Add tests for error paths. 2019-06-21 19:32:49 +02:00
Lewin Bormann
c321f6d2e6 fix(ServiceAccount): Make cache behavior more intuitive.
Now the cache is only checked for a token when the future is polled, not
at future creation time.

This also allows for reverting c2b41c3.
2019-06-21 18:41:17 +02:00
Lewin Bormann
e0f3298904 test(ServiceAccount): Add test with internal mockito web server. 2019-06-21 11:22:24 +02:00
Lewin Bormann
c2b41c3da2 fix(test-svc-acct): Non-lazy cache lookup resulted in two requests. 2019-06-21 11:12:59 +02:00
Lewin Bormann
5e76c2258f docs(README): Update README about provider specificity. 2019-06-19 18:24:27 +02:00
Lewin Bormann
534d5edc12 refactor(google): Make some things less google-specific. 2019-06-19 18:22:03 +02:00
Lewin Bormann
d631c259e8 refactor(StringError): Take more comfortable types in StringError::new
Follow up to #77.
2019-06-14 10:49:43 +02:00
Lewin Bormann
9e4a7e6d49 refactor(StringError): Take more comfortable types in StringError::new 2019-06-14 10:44:44 +02:00
Lewin Bormann
d3f1f87760 chore(version): Mark 3.0.0 as -alpha for publishing. 2019-06-13 21:46:40 +02:00
Lewin Bormann
5a568f2358 fix(refresh): Write refreshed tokens back to cache.
Tested manually.
2019-06-13 18:58:49 +02:00
Lewin Bormann
0eb1268567 doc(tokio): Set keep_alive to false on hyper clients.
This prevents hanging event loops.
2019-06-13 18:52:04 +02:00
Lewin Bormann
10f94a3fd4 docs(Authenticator): Update doc about hyper client as in #93. 2019-06-13 18:33:50 +02:00
Lewin Bormann
f034b8bea4 imp(ServiceAccountAccess): Print exact error if server returns one.
Prevents #76.
2019-06-13 16:16:51 +02:00
Lewin Bormann
6b05056b05 imp(expiry): Treat tokens with < 1 minute life left as expired.
Fixes #78.
2019-06-13 16:08:23 +02:00