-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c4fb0f
commit 2f0b404
Showing
24 changed files
with
859 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use oxide_auth::primitives::registrar::EncodedClient as Inner; | ||
use serde::{Deserialize, Serialize}; | ||
use tf_database::{primitives::Relation, query::ClientQuery, resource::Resource, Traverse}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct EncodedClient { | ||
pub inner: Inner, | ||
} | ||
|
||
impl Resource for EncodedClient { | ||
const NAME: &'static str = "client"; | ||
|
||
type Key = ClientQuery; | ||
} | ||
|
||
impl Traverse<ClientName> for EncodedClient { | ||
type Collection = Relation<ClientQuery, ClientName, ClientQuery, EncodedClient>; | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ClientName { | ||
pub inner: String, | ||
} | ||
|
||
impl Resource for ClientName { | ||
const NAME: &'static str = "client_name"; | ||
|
||
type Key = ClientQuery; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod client; | ||
pub mod user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use oxide_auth::{ | ||
code_grant::{ | ||
accesstoken::Request as AccessTokenRequest, authorization::Request as AuthorizationRequest, | ||
}, | ||
endpoint, | ||
frontends::simple::extensions, | ||
primitives::grant::Extensions, | ||
}; | ||
use oxide_auth_async::endpoint::{AccessTokenExtension, AuthorizationExtension, Extension}; | ||
|
||
pub struct Empty; | ||
|
||
impl Extension for Empty {} | ||
|
||
#[derive(Default)] | ||
pub struct AddonList { | ||
inner: extensions::AddonList, | ||
} | ||
|
||
impl std::ops::Deref for AddonList { | ||
type Target = extensions::AddonList; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.inner | ||
} | ||
} | ||
|
||
impl std::ops::DerefMut for AddonList { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.inner | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl AuthorizationExtension for AddonList { | ||
async fn extend( | ||
&mut self, | ||
request: &(dyn AuthorizationRequest + Sync), | ||
) -> std::result::Result<Extensions, ()> { | ||
endpoint::AuthorizationExtension::extend(&mut self.inner, request) | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl AccessTokenExtension for AddonList { | ||
async fn extend( | ||
&mut self, | ||
request: &(dyn AccessTokenRequest + Sync), | ||
data: Extensions, | ||
) -> std::result::Result<Extensions, ()> { | ||
endpoint::AccessTokenExtension::extend(&mut self.inner, request, data) | ||
} | ||
} | ||
|
||
impl Extension for AddonList { | ||
fn authorization(&mut self) -> Option<&mut (dyn AuthorizationExtension + Send)> { | ||
Some(self) | ||
} | ||
|
||
fn access_token(&mut self) -> Option<&mut (dyn AccessTokenExtension + Send)> { | ||
Some(self) | ||
} | ||
} |
Oops, something went wrong.