63 changed files with 1679 additions and 623 deletions
@ -1,3 +1,12 @@ |
|||
--- |
|||
name: Bug report |
|||
about: Create a report to help us improve |
|||
title: '' |
|||
labels: '' |
|||
assignees: '' |
|||
|
|||
--- |
|||
|
|||
<!-- |
|||
Please fill out the following template to make solving your problem easier and faster for us. |
|||
This is only a guideline. If you think that parts are unneccessary for your issue, feel free to remove them. |
@ -0,0 +1,11 @@ |
|||
--- |
|||
name: Feature request |
|||
about: Suggest an idea for this project |
|||
title: '' |
|||
labels: better for forum |
|||
assignees: '' |
|||
|
|||
--- |
|||
|
|||
# Please submit all your feature requests to the forum |
|||
Link: https://bitwardenrs.discourse.group/c/feature-requests |
@ -0,0 +1,11 @@ |
|||
--- |
|||
name: Help with installation/configuration |
|||
about: Any questions about the setup of bitwarden_rs |
|||
title: '' |
|||
labels: better for forum |
|||
assignees: '' |
|||
|
|||
--- |
|||
|
|||
# Please submit all your third party help requests to the forum |
|||
Link: https://bitwardenrs.discourse.group/c/help |
@ -0,0 +1,11 @@ |
|||
--- |
|||
name: Help with proxy/database/NAS setup |
|||
about: Any questions about third party software |
|||
title: '' |
|||
labels: better for forum |
|||
assignees: '' |
|||
|
|||
--- |
|||
|
|||
# Please submit all your third party help requests to the forum |
|||
Link: https://bitwardenrs.discourse.group/c/third-party-help |
File diff suppressed because it is too large
@ -0,0 +1 @@ |
|||
DROP TABLE org_policies; |
@ -0,0 +1,9 @@ |
|||
CREATE TABLE org_policies ( |
|||
uuid CHAR(36) NOT NULL PRIMARY KEY, |
|||
org_uuid CHAR(36) NOT NULL REFERENCES organizations (uuid), |
|||
atype INTEGER NOT NULL, |
|||
enabled BOOLEAN NOT NULL, |
|||
data TEXT NOT NULL, |
|||
|
|||
UNIQUE (org_uuid, atype) |
|||
); |
@ -0,0 +1 @@ |
|||
DROP TABLE org_policies; |
@ -0,0 +1,9 @@ |
|||
CREATE TABLE org_policies ( |
|||
uuid CHAR(36) NOT NULL PRIMARY KEY, |
|||
org_uuid CHAR(36) NOT NULL REFERENCES organizations (uuid), |
|||
atype INTEGER NOT NULL, |
|||
enabled BOOLEAN NOT NULL, |
|||
data TEXT NOT NULL, |
|||
|
|||
UNIQUE (org_uuid, atype) |
|||
); |
@ -0,0 +1 @@ |
|||
DROP TABLE org_policies; |
@ -0,0 +1,9 @@ |
|||
CREATE TABLE org_policies ( |
|||
uuid TEXT NOT NULL PRIMARY KEY, |
|||
org_uuid TEXT NOT NULL REFERENCES organizations (uuid), |
|||
atype INTEGER NOT NULL, |
|||
enabled BOOLEAN NOT NULL, |
|||
data TEXT NOT NULL, |
|||
|
|||
UNIQUE (org_uuid, atype) |
|||
); |
@ -1 +1 @@ |
|||
nightly-2020-01-30 |
|||
nightly-2020-03-09 |
@ -0,0 +1,142 @@ |
|||
use diesel; |
|||
use diesel::prelude::*; |
|||
use serde_json::Value; |
|||
|
|||
use crate::api::EmptyResult; |
|||
use crate::db::schema::org_policies; |
|||
use crate::db::DbConn; |
|||
use crate::error::MapResult; |
|||
|
|||
use super::Organization; |
|||
|
|||
#[derive(Debug, Identifiable, Queryable, Insertable, Associations, AsChangeset)] |
|||
#[table_name = "org_policies"] |
|||
#[belongs_to(Organization, foreign_key = "org_uuid")] |
|||
#[primary_key(uuid)] |
|||
pub struct OrgPolicy { |
|||
pub uuid: String, |
|||
pub org_uuid: String, |
|||
pub atype: i32, |
|||
pub enabled: bool, |
|||
pub data: String, |
|||
} |
|||
|
|||
#[allow(dead_code)] |
|||
#[derive(FromPrimitive)] |
|||
pub enum OrgPolicyType { |
|||
TwoFactorAuthentication = 0, |
|||
MasterPassword = 1, |
|||
PasswordGenerator = 2, |
|||
} |
|||
|
|||
/// Local methods
|
|||
impl OrgPolicy { |
|||
pub fn new(org_uuid: String, atype: OrgPolicyType, data: String) -> Self { |
|||
Self { |
|||
uuid: crate::util::get_uuid(), |
|||
org_uuid, |
|||
atype: atype as i32, |
|||
enabled: false, |
|||
data, |
|||
} |
|||
} |
|||
|
|||
pub fn to_json(&self) -> Value { |
|||
let data_json: Value = serde_json::from_str(&self.data).unwrap_or(Value::Null); |
|||
json!({ |
|||
"Id": self.uuid, |
|||
"OrganizationId": self.org_uuid, |
|||
"Type": self.atype, |
|||
"Data": data_json, |
|||
"Enabled": self.enabled, |
|||
"Object": "policy", |
|||
}) |
|||
} |
|||
} |
|||
|
|||
/// Database methods
|
|||
impl OrgPolicy { |
|||
#[cfg(feature = "postgresql")] |
|||
pub fn save(&self, conn: &DbConn) -> EmptyResult { |
|||
// We need to make sure we're not going to violate the unique constraint on org_uuid and atype.
|
|||
// This happens automatically on other DBMS backends due to replace_into(). PostgreSQL does
|
|||
// not support multiple constraints on ON CONFLICT clauses.
|
|||
diesel::delete( |
|||
org_policies::table |
|||
.filter(org_policies::org_uuid.eq(&self.org_uuid)) |
|||
.filter(org_policies::atype.eq(&self.atype)), |
|||
) |
|||
.execute(&**conn) |
|||
.map_res("Error deleting org_policy for insert")?; |
|||
|
|||
diesel::insert_into(org_policies::table) |
|||
.values(self) |
|||
.on_conflict(org_policies::uuid) |
|||
.do_update() |
|||
.set(self) |
|||
.execute(&**conn) |
|||
.map_res("Error saving org_policy") |
|||
} |
|||
|
|||
#[cfg(not(feature = "postgresql"))] |
|||
pub fn save(&self, conn: &DbConn) -> EmptyResult { |
|||
diesel::replace_into(org_policies::table) |
|||
.values(&*self) |
|||
.execute(&**conn) |
|||
.map_res("Error saving org_policy") |
|||
} |
|||
|
|||
pub fn delete(self, conn: &DbConn) -> EmptyResult { |
|||
diesel::delete(org_policies::table.filter(org_policies::uuid.eq(self.uuid))) |
|||
.execute(&**conn) |
|||
.map_res("Error deleting org_policy") |
|||
} |
|||
|
|||
pub fn find_by_uuid(uuid: &str, conn: &DbConn) -> Option<Self> { |
|||
org_policies::table |
|||
.filter(org_policies::uuid.eq(uuid)) |
|||
.first::<Self>(&**conn) |
|||
.ok() |
|||
} |
|||
|
|||
pub fn find_by_org(org_uuid: &str, conn: &DbConn) -> Vec<Self> { |
|||
org_policies::table |
|||
.filter(org_policies::org_uuid.eq(org_uuid)) |
|||
.load::<Self>(&**conn) |
|||
.expect("Error loading org_policy") |
|||
} |
|||
|
|||
pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> { |
|||
use crate::db::schema::users_organizations; |
|||
|
|||
org_policies::table |
|||
.left_join( |
|||
users_organizations::table.on( |
|||
users_organizations::org_uuid.eq(org_policies::org_uuid) |
|||
.and(users_organizations::user_uuid.eq(user_uuid))) |
|||
) |
|||
.select(org_policies::all_columns) |
|||
.load::<Self>(&**conn) |
|||
.expect("Error loading org_policy") |
|||
} |
|||
|
|||
pub fn find_by_org_and_type(org_uuid: &str, atype: i32, conn: &DbConn) -> Option<Self> { |
|||
org_policies::table |
|||
.filter(org_policies::org_uuid.eq(org_uuid)) |
|||
.filter(org_policies::atype.eq(atype)) |
|||
.first::<Self>(&**conn) |
|||
.ok() |
|||
} |
|||
|
|||
pub fn delete_all_by_organization(org_uuid: &str, conn: &DbConn) -> EmptyResult { |
|||
diesel::delete(org_policies::table.filter(org_policies::org_uuid.eq(org_uuid))) |
|||
.execute(&**conn) |
|||
.map_res("Error deleting org_policy") |
|||
} |
|||
|
|||
/*pub fn delete_all_by_user(user_uuid: &str, conn: &DbConn) -> EmptyResult {
|
|||
diesel::delete(twofactor::table.filter(twofactor::user_uuid.eq(user_uuid))) |
|||
.execute(&**conn) |
|||
.map_res("Error deleting twofactors") |
|||
}*/ |
|||
} |
@ -0,0 +1,8 @@ |
|||
Bitwarden_rs SMTP Test |
|||
<!----------------> |
|||
<html> |
|||
<p> |
|||
This is a test email to verify the SMTP configuration for <a href="{{url}}">{{url}}</a>. |
|||
</p> |
|||
<p>When you can read this email it is probably configured correctly.</p> |
|||
</html> |
@ -0,0 +1,129 @@ |
|||
Bitwarden_rs SMTP Test |
|||
<!----------------> |
|||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> |
|||
<head> |
|||
<meta name="viewport" content="width=device-width" /> |
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|||
<title>Bitwarden_rs</title> |
|||
</head> |
|||
<body style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; height: 100%; line-height: 25px; width: 100% !important;" bgcolor="#f6f6f6"> |
|||
<style type="text/css"> |
|||
body { |
|||
margin: 0; |
|||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; |
|||
box-sizing: border-box; |
|||
font-size: 16px; |
|||
color: #333; |
|||
line-height: 25px; |
|||
-webkit-font-smoothing: antialiased; |
|||
-webkit-text-size-adjust: none; |
|||
} |
|||
body * { |
|||
margin: 0; |
|||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; |
|||
box-sizing: border-box; |
|||
font-size: 16px; |
|||
color: #333; |
|||
line-height: 25px; |
|||
-webkit-font-smoothing: antialiased; |
|||
-webkit-text-size-adjust: none; |
|||
} |
|||
img { |
|||
max-width: 100%; |
|||
border: none; |
|||
} |
|||
body { |
|||
-webkit-font-smoothing: antialiased; |
|||
-webkit-text-size-adjust: none; |
|||
width: 100% !important; |
|||
height: 100%; |
|||
line-height: 25px; |
|||
} |
|||
body { |
|||
background-color: #f6f6f6; |
|||
} |
|||
@media only screen and (max-width: 600px) { |
|||
body { |
|||
padding: 0 !important; |
|||
} |
|||
.container { |
|||
padding: 0 !important; |
|||
width: 100% !important; |
|||
} |
|||
.container-table { |
|||
padding: 0 !important; |
|||
width: 100% !important; |
|||
} |
|||
.content { |
|||
padding: 0 0 10px 0 !important; |
|||
} |
|||
.content-wrap { |
|||
padding: 10px !important; |
|||
} |
|||
.invoice { |
|||
width: 100% !important; |
|||
} |
|||
.main { |
|||
border-right: none !important; |
|||
border-left: none !important; |
|||
border-radius: 0 !important; |
|||
} |
|||
.logo { |
|||
padding-top: 10px !important; |
|||
} |
|||
.footer { |
|||
margin-top: 10px !important; |
|||
} |
|||
.indented { |
|||
padding-left: 10px; |
|||
} |
|||
} |
|||
</style> |
|||
<table class="body-wrap" cellpadding="0" cellspacing="0" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0; width: 100%;" bgcolor="#f6f6f6"> |
|||
<tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> |
|||
<td valign="middle" class="aligncenter middle logo" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0; padding: 20px 0 10px;" align="center"> |
|||
<img src="{{url}}/bwrs_static/logo-gray.png" alt="" width="250" height="39" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; border: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0; max-width: 100%;" /> |
|||
</td> |
|||
</tr> |
|||
<tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> |
|||
<td class="container" align="center" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; clear: both !important; color: #333; display: block !important; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0 auto; max-width: 600px !important; width: 600px;" valign="top"> |
|||
<table cellpadding="0" cellspacing="0" class="container-table" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; clear: both !important; color: #333; display: block !important; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0 auto; max-width: 600px !important; width: 600px;"> |
|||
<tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> |
|||
<td class="content" align="center" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; display: block; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 0; line-height: 0; margin: 0 auto; max-width: 600px; padding-bottom: 20px;" valign="top"> |
|||
<table class="main" width="100%" cellpadding="0" cellspacing="0" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; margin: 0; -webkit-text-size-adjust: none; border: 1px solid #e9e9e9; border-radius: 3px;" bgcolor="white"> |
|||
<tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> |
|||
<td class="content-wrap" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 20px; -webkit-text-size-adjust: none;" valign="top"> |
|||
<table width="100%" cellpadding="0" cellspacing="0" style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> |
|||
<tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> |
|||
<td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none; text-align: center;" valign="top" align="center"> |
|||
This is a test email to verify the SMTP configuration for <a href="{{url}}">{{url}}</a>. |
|||
</td> |
|||
</tr> |
|||
<tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> |
|||
<td class="content-block last" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0; -webkit-text-size-adjust: none; text-align: center;" valign="top" align="center"> |
|||
When you can read this email it is probably configured correctly. |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
<table class="footer" cellpadding="0" cellspacing="0" width="100%" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; clear: both; color: #999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; margin: 0; width: 100%;"> |
|||
<tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> |
|||
<td class="aligncenter social-icons" align="center" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; margin: 0; padding: 15px 0 0 0;" valign="top"> |
|||
<table cellpadding="0" cellspacing="0" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0 auto;"> |
|||
<tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> |
|||
<td style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; margin: 0; padding: 0 10px;" valign="top"><a href="https://github.com/dani-garcia/bitwarden_rs" target="_blank" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; margin: 0; text-decoration: underline;"><img src="{{url}}/bwrs_static/mail-github.png" alt="GitHub" width="30" height="30" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; border: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0; max-width: 100%;" /></a></td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
</body> |
|||
</html> |
Loading…
Reference in new issue