Can specify default clients
This commit is contained in:
@ -6,11 +6,24 @@ pub struct ClientID(pub String);
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Client {
|
||||
/// The ID of the client
|
||||
pub id: ClientID,
|
||||
|
||||
/// The human-readable name of the client
|
||||
pub name: String,
|
||||
|
||||
/// A short description of the service provided by the client
|
||||
pub description: String,
|
||||
|
||||
/// The secret used by the client to retrieve authenticated users information
|
||||
pub secret: String,
|
||||
|
||||
/// The URI where the users should be redirected once authenticated
|
||||
pub redirect_uri: String,
|
||||
|
||||
/// Specify if the client must be allowed by default for new account
|
||||
#[serde(default = "bool::default")]
|
||||
pub default: bool,
|
||||
}
|
||||
|
||||
impl PartialEq for Client {
|
||||
@ -33,6 +46,13 @@ impl EntityManager<Client> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Get the list of default clients.
|
||||
///
|
||||
/// i.e. the clients that are granted to new accounts by default
|
||||
pub fn get_default_clients(&self) -> Vec<&Client> {
|
||||
self.iter().filter(|u| u.default).collect()
|
||||
}
|
||||
|
||||
pub fn apply_environment_variables(&mut self) {
|
||||
for c in self.iter_mut() {
|
||||
c.id = ClientID(apply_env_vars(&c.id.0));
|
||||
|
Reference in New Issue
Block a user