Skip to content

Commit 7b4264a

Browse files
feat(shield-oauth): add oauth method
1 parent b9b5ac0 commit 7b4264a

14 files changed

Lines changed: 743 additions & 45 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/methods/shield-oauth/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ version.workspace = true
1010

1111
[dependencies]
1212
async-trait.workspace = true
13+
chrono.workspace = true
1314
oauth2 = { version = "5.0.0", default-features = false, features = ["reqwest"] }
15+
serde.workspace = true
1416
shield.workspace = true
1517

1618
[features]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use oauth2::reqwest::{self, redirect::Policy};
2+
use shield::ConfigurationError;
3+
4+
pub fn async_http_client() -> Result<reqwest::Client, ConfigurationError> {
5+
reqwest::Client::builder()
6+
.redirect(Policy::none())
7+
.build()
8+
.map_err(|err| ConfigurationError::Invalid(err.to_string()))
9+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use chrono::{DateTime, FixedOffset};
2+
3+
#[derive(Clone, Debug)]
4+
pub struct OauthConnection {
5+
pub id: String,
6+
pub identifier: String,
7+
pub token_type: String,
8+
pub access_token: String,
9+
pub refresh_token: Option<String>,
10+
pub expired_at: Option<DateTime<FixedOffset>>,
11+
pub scopes: Option<Vec<String>>,
12+
pub provider_id: String,
13+
pub user_id: String,
14+
}
15+
16+
#[derive(Clone, Debug)]
17+
pub struct CreateOauthConnection {
18+
pub identifier: String,
19+
pub token_type: String,
20+
pub access_token: String,
21+
pub refresh_token: Option<String>,
22+
pub expired_at: Option<DateTime<FixedOffset>>,
23+
pub scopes: Option<Vec<String>>,
24+
pub provider_id: String,
25+
pub user_id: String,
26+
}
27+
28+
#[derive(Clone, Debug)]
29+
pub struct UpdateOauthConnection {
30+
pub id: String,
31+
pub token_type: Option<String>,
32+
pub access_token: Option<String>,
33+
pub refresh_token: Option<Option<String>>,
34+
pub expired_at: Option<Option<DateTime<FixedOffset>>>,
35+
pub scopes: Option<Option<Vec<String>>>,
36+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
mod client;
2+
mod connection;
13
mod method;
24
mod provider;
5+
mod session;
36
mod storage;
47

8+
pub use connection::*;
59
pub use method::*;
610
pub use provider::*;
711
pub use storage::*;

0 commit comments

Comments
 (0)