|
1 | | -use crate::subprovider::{OidcProviderPkceCodeChallenge, OidcProviderVisibility, OidcSubprovider}; |
| 1 | +use crate::subprovider::{ |
| 2 | + oidc_subprovider_builder::{SetClientId, SetDiscoveryUrl, SetId, SetName}, |
| 3 | + OidcSubprovider, OidcSubproviderBuilder, |
| 4 | +}; |
2 | 5 |
|
3 | | -#[derive(Debug)] |
4 | | -pub struct KeycloakBuilder { |
5 | | - id: String, |
6 | | - name: String, |
7 | | - discovery_url: String, |
8 | | - client_id: String, |
9 | | - client_secret: Option<String>, |
10 | | - redirect_url: Option<String>, |
11 | | -} |
12 | | - |
13 | | -impl KeycloakBuilder { |
14 | | - pub fn new(id: &str, discovery_url: &str, client_id: &str) -> Self { |
15 | | - Self { |
16 | | - id: id.to_owned(), |
17 | | - name: "Keycloak".to_owned(), |
18 | | - discovery_url: discovery_url.to_owned(), |
19 | | - client_id: client_id.to_owned(), |
20 | | - client_secret: None, |
21 | | - redirect_url: None, |
22 | | - } |
23 | | - } |
24 | | - |
25 | | - pub fn name(mut self, name: &str) -> Self { |
26 | | - self.name = name.to_owned(); |
27 | | - self |
28 | | - } |
29 | | - |
30 | | - pub fn client_secret(mut self, client_secret: &str) -> Self { |
31 | | - self.client_secret = Some(client_secret.to_owned()); |
32 | | - self |
33 | | - } |
34 | | - |
35 | | - pub fn redirect_url(mut self, redirect_url: &str) -> Self { |
36 | | - self.redirect_url = Some(redirect_url.to_owned()); |
37 | | - self |
38 | | - } |
| 6 | +pub struct Keycloak {} |
39 | 7 |
|
40 | | - pub fn build(self) -> OidcSubprovider { |
41 | | - OidcSubprovider { |
42 | | - id: self.id, |
43 | | - name: self.name, |
44 | | - slug: None, |
45 | | - visibility: OidcProviderVisibility::Public, |
46 | | - client_id: self.client_id, |
47 | | - client_secret: self.client_secret, |
48 | | - scopes: None, |
49 | | - redirect_url: self.redirect_url, |
50 | | - discovery_url: Some(self.discovery_url), |
51 | | - issuer_url: None, |
52 | | - authorization_url: None, |
53 | | - authorization_url_params: None, |
54 | | - token_url: None, |
55 | | - token_url_params: None, |
56 | | - introspection_url: None, |
57 | | - introspection_url_params: None, |
58 | | - revocation_url: None, |
59 | | - revocation_url_params: None, |
60 | | - user_info_url: None, |
61 | | - json_web_key_set_url: None, |
62 | | - json_web_key_set: None, |
63 | | - pkce_code_challenge: OidcProviderPkceCodeChallenge::S256, |
64 | | - } |
| 8 | +impl Keycloak { |
| 9 | + pub fn builder( |
| 10 | + id: &str, |
| 11 | + discovery_url: &str, |
| 12 | + client_id: &str, |
| 13 | + ) -> OidcSubproviderBuilder<SetDiscoveryUrl<SetClientId<SetName<SetId>>>> { |
| 14 | + OidcSubprovider::builder() |
| 15 | + .id(id) |
| 16 | + .name("Keycloak") |
| 17 | + .client_id(client_id) |
| 18 | + .discovery_url(discovery_url) |
65 | 19 | } |
66 | 20 | } |
0 commit comments