Skip to content

Commit 5ea0779

Browse files
authored
a little cleanup after SSO merge (#6153)
* fix some typos * rename scss variable to sso_enabled * refactor is_mobile to device * also mask sensitive sso config options
1 parent a133d4e commit 5ea0779

File tree

16 files changed

+55
-49
lines changed

16 files changed

+55
-49
lines changed

.env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@
485485
# SSO_AUTHORITY=https://auth.example.com
486486

487487
## Authorization request scopes. Optional SSO scopes, override if email and profile are not enough (`openid` is implicit).
488-
#SSO_SCOPES="email profile"
488+
# SSO_SCOPES="email profile"
489489

490490
## Additional authorization url parameters (ex: to obtain a `refresh_token` with Google Auth).
491491
# SSO_AUTHORIZE_EXTRA_PARAMS="access_type=offline&prompt=consent"

playwright/README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Integration tests
22

33
This allows running integration tests using [Playwright](https://playwright.dev/).
4-
\
5-
It usse its own [test.env](/test/scenarios/test.env) with different ports to not collide with a running dev instance.
4+
5+
It uses its own `test.env` with different ports to not collide with a running dev instance.
66

77
## Install
88

9-
This rely on `docker` and the `compose` [plugin](https://docs.docker.com/compose/install/).
9+
This relies on `docker` and the `compose` [plugin](https://docs.docker.com/compose/install/).
1010
Databases (`Mariadb`, `Mysql` and `Postgres`) and `Playwright` will run in containers.
1111

1212
### Running Playwright outside docker
1313

14-
It's possible to run `Playwright` outside of the container, this remove the need to rebuild the image for each change.
15-
You'll additionally need `nodejs` then run:
14+
It is possible to run `Playwright` outside of the container, this removes the need to rebuild the image for each change.
15+
You will additionally need `nodejs` then run:
1616

1717
```bash
1818
npm install
@@ -33,7 +33,7 @@ To force a rebuild of the Playwright image:
3333
DOCKER_BUILDKIT=1 docker compose --env-file test.env build Playwright
3434
```
3535

36-
To access the ui to easily run test individually and debug if needed (will not work in docker):
36+
To access the UI to easily run test individually and debug if needed (this will not work in docker):
3737

3838
```bash
3939
npx playwright test --ui
@@ -42,7 +42,7 @@ npx playwright test --ui
4242
### DB
4343

4444
Projects are configured to allow to run tests only on specific database.
45-
\
45+
4646
You can use:
4747

4848
```bash
@@ -62,7 +62,7 @@ DOCKER_BUILDKIT=1 docker compose --profile playwright --env-file test.env run Pl
6262

6363
### Keep services running
6464

65-
If you want you can keep the Db and Keycloak runnning (states are not impacted by the tests):
65+
If you want you can keep the DB and Keycloak runnning (states are not impacted by the tests):
6666

6767
```bash
6868
PW_KEEP_SERVICE_RUNNNING=true npx playwright test
@@ -86,7 +86,8 @@ DOCKER_BUILDKIT=1 docker compose --profile playwright --env-file test.env run Pl
8686

8787
## Writing scenario
8888

89-
When creating new scenario use the recorder to more easily identify elements (in general try to rely on visible hint to identify elements and not hidden ids).
89+
When creating new scenario use the recorder to more easily identify elements
90+
(in general try to rely on visible hint to identify elements and not hidden IDs).
9091
This does not start the server, you will need to start it manually.
9192

9293
```bash
@@ -95,7 +96,7 @@ npx playwright codegen "http://127.0.0.1:8000"
9596

9697
## Override web-vault
9798

98-
It's possible to change the `web-vault` used by referencing a different `bw_web_builds` commit.
99+
It is possible to change the `web-vault` used by referencing a different `bw_web_builds` commit.
99100

100101
```bash
101102
export PW_WV_REPO_URL=https://github.com/Timshel/oidc_web_builds.git
@@ -105,12 +106,13 @@ DOCKER_BUILDKIT=1 docker compose --profile playwright --env-file test.env build
105106

106107
# OpenID Connect test setup
107108

108-
Additionally this `docker-compose` template allow to run locally `VaultWarden`, [Keycloak](https://www.keycloak.org/) and [Maildev](https://github.com/timshel/maildev) to test OIDC.
109+
Additionally this `docker-compose` template allows to run locally Vaultwarden,
110+
[Keycloak](https://www.keycloak.org/) and [Maildev](https://github.com/timshel/maildev) to test OIDC.
109111

110112
## Setup
111113

112114
This rely on `docker` and the `compose` [plugin](https://docs.docker.com/compose/install/).
113-
First create a copy of `.env.template` as `.env` (This is done to prevent commiting your custom settings, Ex `SMTP_`).
115+
First create a copy of `.env.template` as `.env` (This is done to prevent committing your custom settings, Ex `SMTP_`).
114116

115117
## Usage
116118

@@ -125,11 +127,12 @@ keycloakSetup_1 | 74af4933-e386-4e64-ba15-a7b61212c45e
125127
oidc_keycloakSetup_1 exited with code 0
126128
```
127129

128-
Wait until `oidc_keycloakSetup_1 exited with code 0` which indicate the correct setup of the Keycloak realm, client and user (It's normal for this container to stop once the configuration is done).
130+
Wait until `oidc_keycloakSetup_1 exited with code 0` which indicates the correct setup of the Keycloak realm, client and user
131+
(It is normal for this container to stop once the configuration is done).
129132

130133
Then you can access :
131134

132-
- `VaultWarden` on http://0.0.0.0:8000 with the default user `[email protected]/test`.
135+
- `Vaultwarden` on http://0.0.0.0:8000 with the default user `[email protected]/test`.
133136
- `Keycloak` on http://0.0.0.0:8080/admin/master/console/ with the default user `admin/admin`
134137
- `Maildev` on http://0.0.0.0:1080
135138

@@ -143,7 +146,7 @@ You can run just `Keycloak` with `--profile keycloak`:
143146
```bash
144147
> docker compose --profile keycloak --env-file .env up
145148
```
146-
When running with a local VaultWarden, you can use a front-end build from [dani-garcia/bw_web_builds](https://github.com/dani-garcia/bw_web_builds/releases).
149+
When running with a local Vaultwarden, you can use a front-end build from [dani-garcia/bw_web_builds](https://github.com/dani-garcia/bw_web_builds/releases).
147150

148151
## Rebuilding the Vaultwarden
149152

@@ -155,12 +158,12 @@ docker compose --profile vaultwarden --env-file .env build VaultwardenPrebuild V
155158

156159
## Configuration
157160

158-
All configuration for `keycloak` / `VaultWarden` / `keycloak_setup.sh` can be found in [.env](.env.template).
161+
All configuration for `keycloak` / `Vaultwarden` / `keycloak_setup.sh` can be found in [.env](.env.template).
159162
The content of the file will be loaded as environment variables in all containers.
160163

161-
- `keycloak` [configuration](https://www.keycloak.org/server/all-config) include `KEYCLOAK_ADMIN` / `KEYCLOAK_ADMIN_PASSWORD` and any variable prefixed `KC_` ([more information](https://www.keycloak.org/server/configuration#_example_configuring_the_db_url_host_parameter)).
162-
- All `VaultWarden` configuration can be set (EX: `SMTP_*`)
164+
- `keycloak` [configuration](https://www.keycloak.org/server/all-config) includes `KEYCLOAK_ADMIN` / `KEYCLOAK_ADMIN_PASSWORD` and any variable prefixed `KC_` ([more information](https://www.keycloak.org/server/configuration#_example_configuring_the_db_url_host_parameter)).
165+
- All `Vaultwarden` configuration can be set (EX: `SMTP_*`)
163166

164167
## Cleanup
165168

166-
Use `docker compose --profile vaultWarden down`.
169+
Use `docker compose --profile vaultwarden down`.

playwright/compose/warden/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM playwright_oidc_vaultwarden_prebuilt AS prebuilt
22

3-
FROM node:18-bookworm AS build
3+
FROM node:22-bookworm AS build
44

55
ARG REPO_URL
66
ARG COMMIT_HASH

playwright/test.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN}
4343
KC_HTTP_HOST=127.0.0.1
4444
KC_HTTP_PORT=8081
4545

46-
# Script parameters (use Keycloak and VaultWarden config too)
46+
# Script parameters (use Keycloak and Vaultwarden config too)
4747
TEST_REALM=test
4848
DUMMY_REALM=dummy
4949
DUMMY_AUTHORITY=http://${KC_HTTP_HOST}:${KC_HTTP_PORT}/realms/${DUMMY_REALM}

src/api/core/accounts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ async fn post_set_password(data: Json<SetPasswordData>, headers: Headers, mut co
342342
let mut user = headers.user;
343343

344344
if user.private_key.is_some() {
345-
err!("Account already intialized cannot set password")
345+
err!("Account already initialized, cannot set password")
346346
}
347347

348-
// Check against the password hint setting here so if it fails, the user
349-
// can retry without losing their invitation below.
348+
// Check against the password hint setting here so if it fails,
349+
// the user can retry without losing their invitation below.
350350
let password_hint = clean_password_hint(&data.master_password_hint);
351351
enforce_password_hint_setting(&password_hint)?;
352352

src/api/core/organizations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2310,7 +2310,7 @@ struct OrgImportData {
23102310
users: Vec<OrgImportUserData>,
23112311
}
23122312

2313-
/// This function seems to be deprected
2313+
/// This function seems to be deprecated
23142314
/// It is only used with older directory connectors
23152315
/// TODO: Cleanup Tech debt
23162316
#[post("/organizations/<org_id>/import", data = "<data>")]

src/api/icons.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,9 @@ async fn stream_to_bytes_limit(res: Response, max_size: usize) -> Result<Bytes,
641641
let mut buf = BytesMut::new();
642642
let mut size = 0;
643643
while let Some(chunk) = stream.next().await {
644-
// It is possible that there might occure UnexpectedEof errors or others
644+
// It is possible that there might occur UnexpectedEof errors or others
645645
// This is most of the time no issue, and if there is no chunked data anymore or at all parsing the HTML will not happen anyway.
646-
// Therfore if chunk is an err, just break and continue with the data be have received.
646+
// Therefore if chunk is an err, just break and continue with the data be have received.
647647
if chunk.is_err() {
648648
break;
649649
}

src/api/identity.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ async fn _sso_login(
293293
}
294294
};
295295

296-
// We passed 2FA get full user informations
296+
// We passed 2FA get full user information
297297
let auth_user = sso::redeem(&user_infos.state, conn).await?;
298298

299299
if sso_user.is_none() {
@@ -1060,12 +1060,12 @@ async fn oidcsignin_redirect(
10601060
wrapper: impl FnOnce(OIDCState) -> sso::OIDCCodeWrapper,
10611061
conn: &DbConn,
10621062
) -> ApiResult<Redirect> {
1063-
let state = sso::deocde_state(base64_state)?;
1063+
let state = sso::decode_state(base64_state)?;
10641064
let code = sso::encode_code_claims(wrapper(state.clone()));
10651065

10661066
let nonce = match SsoNonce::find(&state, conn).await {
10671067
Some(n) => n,
1068-
None => err!(format!("Failed to retrive redirect_uri with {state}")),
1068+
None => err!(format!("Failed to retrieve redirect_uri with {state}")),
10691069
};
10701070

10711071
let mut url = match url::Url::parse(&nonce.redirect_uri) {

src/api/web.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn vaultwarden_css() -> Cached<Css<String>> {
6161
"mail_enabled": CONFIG.mail_enabled(),
6262
"sends_allowed": CONFIG.sends_allowed(),
6363
"signup_disabled": CONFIG.is_signup_disabled(),
64-
"sso_disabled": !CONFIG.sso_enabled(),
64+
"sso_enabled": CONFIG.sso_enabled(),
6565
"sso_only": CONFIG.sso_enabled() && CONFIG.sso_only(),
6666
"yubico_enabled": CONFIG._enable_yubico() && CONFIG.yubico_client_id().is_some() && CONFIG.yubico_secret_key().is_some(),
6767
});

src/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ impl AuthTokens {
11741174

11751175
let access_claims = LoginJwtClaims::default(device, user, &sub, client_id);
11761176

1177-
let validity = if DeviceType::is_mobile(&device.atype) {
1177+
let validity = if device.is_mobile() {
11781178
*MOBILE_REFRESH_VALIDITY
11791179
} else {
11801180
*DEFAULT_REFRESH_VALIDITY

0 commit comments

Comments
 (0)