plugins/
frontend.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use auth::UserProviderRef;
16use common_base::Plugins;
17use frontend::error::{IllegalAuthConfigSnafu, Result};
18use frontend::frontend::FrontendOptions;
19use snafu::ResultExt;
20
21use crate::options::PluginOptions;
22
23#[allow(unused_mut)]
24pub async fn setup_frontend_plugins(
25    plugins: &mut Plugins,
26    _plugin_options: &[PluginOptions],
27    fe_opts: &FrontendOptions,
28) -> Result<()> {
29    if let Some(user_provider) = fe_opts.user_provider.as_ref() {
30        let provider =
31            auth::user_provider_from_option(user_provider).context(IllegalAuthConfigSnafu)?;
32        plugins.insert::<UserProviderRef>(provider);
33    }
34    Ok(())
35}
36
37pub async fn start_frontend_plugins(_plugins: Plugins) -> Result<()> {
38    Ok(())
39}