Browse Source

nullable fields

pull/1955/head
Stuart Heap 4 years ago
parent
commit
92b4c7efe6
No known key found for this signature in database GPG Key ID: C753450AB379AA25
  1. 8
      migrations/mysql/2021-09-16-133000_add-sso/up.sql
  2. 8
      migrations/postgresql/2021-09-16-133000_add_sso/up.sql
  3. 8
      migrations/sqlite/2021-09-16-133000_add_sso/up.sql
  4. 8
      src/api/core/organizations.rs
  5. 6
      src/api/identity.rs
  6. 16
      src/db/models/organization.rs
  7. 8
      src/db/schemas/mysql/schema.rs
  8. 8
      src/db/schemas/postgresql/schema.rs
  9. 8
      src/db/schemas/sqlite/schema.rs

8
migrations/mysql/2021-09-16-133000_add-sso/up.sql

@ -1,7 +1,7 @@
ALTER TABLE organizations ADD COLUMN identifier TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN identifier TEXT;
ALTER TABLE organizations ADD COLUMN use_sso BOOLEAN NOT NULL; ALTER TABLE organizations ADD COLUMN use_sso BOOLEAN NOT NULL;
ALTER TABLE organizations ADD COLUMN callback_path TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN callback_path TEXT NOT NULL;
ALTER TABLE organizations ADD COLUMN signed_out_callback_path TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN signed_out_callback_path TEXT NOT NULL;
ALTER TABLE organizations ADD COLUMN authority TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN authority TEXT;
ALTER TABLE organizations ADD COLUMN client_id TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN client_id TEXT;
ALTER TABLE organizations ADD COLUMN client_secret TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN client_secret TEXT;

8
migrations/postgresql/2021-09-16-133000_add_sso/up.sql

@ -1,7 +1,7 @@
ALTER TABLE organizations ADD COLUMN identifier TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN identifier TEXT;
ALTER TABLE organizations ADD COLUMN use_sso BOOLEAN NOT NULL; ALTER TABLE organizations ADD COLUMN use_sso BOOLEAN NOT NULL;
ALTER TABLE organizations ADD COLUMN callback_path TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN callback_path TEXT NOT NULL;
ALTER TABLE organizations ADD COLUMN signed_out_callback_path TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN signed_out_callback_path TEXT NOT NULL;
ALTER TABLE organizations ADD COLUMN authority TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN authority TEXT;
ALTER TABLE organizations ADD COLUMN client_id TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN client_id TEXT;
ALTER TABLE organizations ADD COLUMN client_secret TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN client_secret TEXT;

8
migrations/sqlite/2021-09-16-133000_add_sso/up.sql

@ -1,7 +1,7 @@
ALTER TABLE organizations ADD COLUMN identifier TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN identifier TEXT;
ALTER TABLE organizations ADD COLUMN use_sso BOOLEAN NOT NULL; ALTER TABLE organizations ADD COLUMN use_sso BOOLEAN NOT NULL;
ALTER TABLE organizations ADD COLUMN callback_path TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN callback_path TEXT NOT NULL;
ALTER TABLE organizations ADD COLUMN signed_out_callback_path TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN signed_out_callback_path TEXT NOT NULL;
ALTER TABLE organizations ADD COLUMN authority TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN authority TEXT;
ALTER TABLE organizations ADD COLUMN client_id TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN client_id TEXT;
ALTER TABLE organizations ADD COLUMN client_secret TEXT NOT NULL; ALTER TABLE organizations ADD COLUMN client_secret TEXT;

8
src/api/core/organizations.rs

@ -82,9 +82,9 @@ struct OrganizationSsoUpdateData {
UseSso: bool, UseSso: bool,
CallbackPath: String, CallbackPath: String,
SignedOutCallbackPath: String, SignedOutCallbackPath: String,
Authority: String, Authority: Option<String>,
ClientId: String, ClientId: Option<String>,
ClientSecret: String, ClientSecret: Option<String>,
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -213,7 +213,7 @@ fn post_organization(
org.name = data.Name; org.name = data.Name;
org.billing_email = data.BillingEmail; org.billing_email = data.BillingEmail;
org.identifier = data.Identifier.unwrap_or_default(); org.identifier = data.Identifier;
org.save(&conn)?; org.save(&conn)?;
Ok(Json(org.to_json())) Ok(Json(org.to_json()))

6
src/api/identity.rs

@ -571,9 +571,9 @@ fn get_client_from_identifier (identifier: &str, conn: &DbConn) -> Result<CoreCl
match organization { match organization {
Some(organization) => { Some(organization) => {
let redirect = organization.callback_path.to_string(); let redirect = organization.callback_path.to_string();
let client_id = ClientId::new(organization.client_id); let client_id = ClientId::new(organization.client_id.unwrap_or_default());
let client_secret = ClientSecret::new(organization.client_secret); let client_secret = ClientSecret::new(organization.client_secret.unwrap_or_default());
let issuer_url = IssuerUrl::new(organization.authority).expect("invalid issuer URL"); let issuer_url = IssuerUrl::new(organization.authority.unwrap_or_default()).expect("invalid issuer URL");
let provider_metadata = match CoreProviderMetadata::discover(&issuer_url, http_client) { let provider_metadata = match CoreProviderMetadata::discover(&issuer_url, http_client) {
Ok(metadata) => metadata, Ok(metadata) => metadata,
Err(_err) => { Err(_err) => {

16
src/db/models/organization.rs

@ -12,15 +12,15 @@ db_object! {
pub uuid: String, pub uuid: String,
pub name: String, pub name: String,
pub billing_email: String, pub billing_email: String,
pub identifier: String, pub identifier: Option<String>,
pub private_key: Option<String>, pub private_key: Option<String>,
pub public_key: Option<String>, pub public_key: Option<String>,
pub use_sso: bool, pub use_sso: bool,
pub callback_path: String, pub callback_path: String,
pub signed_out_callback_path: String, pub signed_out_callback_path: String,
pub authority: String, pub authority: Option<String>,
pub client_id: String, pub client_id: Option<String>,
pub client_secret: String, pub client_secret: Option<String>,
} }
#[derive(Identifiable, Queryable, Insertable, AsChangeset)] #[derive(Identifiable, Queryable, Insertable, AsChangeset)]
@ -138,13 +138,13 @@ impl Organization {
billing_email, billing_email,
private_key, private_key,
public_key, public_key,
identifier: String::from(""), identifier: None,
use_sso: false, use_sso: false,
callback_path: String::from("http://localhost/#/sso/"), callback_path: String::from("http://localhost/#/sso/"),
signed_out_callback_path: String::from("http://localhost/#/sso/"), signed_out_callback_path: String::from("http://localhost/#/sso/"),
authority: String::from(""), authority: None,
client_id: String::from(""), client_id: None,
client_secret: String::from(""), client_secret: None,
} }
} }

8
src/db/schemas/mysql/schema.rs

@ -100,15 +100,15 @@ table! {
uuid -> Text, uuid -> Text,
name -> Text, name -> Text,
billing_email -> Text, billing_email -> Text,
identifier -> Text, identifier -> Nullable<Text>,
private_key -> Nullable<Text>, private_key -> Nullable<Text>,
public_key -> Nullable<Text>, public_key -> Nullable<Text>,
use_sso -> Bool, use_sso -> Bool,
callback_path -> Text, callback_path -> Text,
signed_out_callback_path -> Text, signed_out_callback_path -> Text,
authority -> Text, authority -> Nullable<Text>,
client_id -> Text, client_id -> Nullable<Text>,
client_secret -> Text, client_secret -> Nullable<Text>,
} }
} }

8
src/db/schemas/postgresql/schema.rs

@ -100,15 +100,15 @@ table! {
uuid -> Text, uuid -> Text,
name -> Text, name -> Text,
billing_email -> Text, billing_email -> Text,
identifier -> Text, identifier -> Nullable<Text>,
private_key -> Nullable<Text>, private_key -> Nullable<Text>,
public_key -> Nullable<Text>, public_key -> Nullable<Text>,
use_sso -> Bool, use_sso -> Bool,
callback_path -> Text, callback_path -> Text,
signed_out_callback_path -> Text, signed_out_callback_path -> Text,
authority -> Text, authority -> Nullable<Text>,
client_id -> Text, client_id -> Nullable<Text>,
client_secret -> Text, client_secret -> Nullable<Text>,
} }
} }

8
src/db/schemas/sqlite/schema.rs

@ -100,15 +100,15 @@ table! {
uuid -> Text, uuid -> Text,
name -> Text, name -> Text,
billing_email -> Text, billing_email -> Text,
identifier -> Text, identifier -> Nullable<Text>,
private_key -> Nullable<Text>, private_key -> Nullable<Text>,
public_key -> Nullable<Text>, public_key -> Nullable<Text>,
use_sso -> Bool, use_sso -> Bool,
callback_path -> Text, callback_path -> Text,
signed_out_callback_path -> Text, signed_out_callback_path -> Text,
authority -> Text, authority -> Nullable<Text>,
client_id -> Text, client_id -> Nullable<Text>,
client_secret -> Text, client_secret -> Nullable<Text>,
} }
} }

Loading…
Cancel
Save