Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/basic auth extension #534

Merged
merged 45 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
67a1477
fix: display different error message depending on the type
Siolto Jul 19, 2023
a0673b1
chore: update package-lock
Siolto Jul 19, 2023
4ba1917
chore: update package-lock with chromedriver
Siolto Jul 19, 2023
66f0377
wip: basic auth extension
Siolto Jul 24, 2023
84ef048
Merge branch 'main' into feat/basic-auth-extension
Siolto Aug 29, 2023
a337510
ci: fix attempt for download and deploy artifact
vobu Aug 30, 2023
179325e
feat: cap basic authentication
Sep 7, 2023
18406a9
feat: cap basic authentication
Sep 7, 2023
dcca311
fix: removing extra file
Sep 7, 2023
34909c2
fix: package-lock.json
Sep 7, 2023
bfbc0ec
fix: package-lock.json
Sep 7, 2023
85175ef
fix: package-lock.json
Sep 7, 2023
b1e5fb5
chore: add cap-submodule to wdi5
Siolto Sep 7, 2023
73e128c
Merge branch 'main' into feat/basic-auth-extension
vobu Sep 7, 2023
05ff4a4
chore(deps): update package-lock.json
vobu Sep 7, 2023
0ebf8d4
chore: update submodule
Siolto Sep 7, 2023
49332e8
Merge remote-tracking branch 'wdi5/feat/add-cap-submodule' into feat/…
Siolto Sep 7, 2023
39008c1
Merge branch 'main' of github.com:ui5-community/wdi5
vobu Sep 7, 2023
af1fa01
fix: use baseUrl from outside and update dependencies
Siolto Sep 7, 2023
807a1d3
feat: add capAuth to pipeline
Siolto Sep 7, 2023
a10f308
chore: update submodule commit
Siolto Sep 7, 2023
269154a
docs: rename basichAuthUrl property
Siolto Sep 7, 2023
b98b3e8
chore: update pipeline config
Siolto Sep 7, 2023
8e7dbf9
fix: cap pipeline
Siolto Sep 7, 2023
260aab6
fix: checkout submodules
Siolto Sep 7, 2023
2a97ffc
wip: cap pipeline
Siolto Sep 7, 2023
81cd76a
wip: update commit link
Siolto Sep 7, 2023
d55a6fd
wip: new commit reference
Siolto Sep 7, 2023
2e023ad
wip: pipeline fix
Siolto Sep 7, 2023
d20fd11
Merge remote-tracking branch 'wdi5/main' into feat/basic-auth-extension
Siolto Sep 7, 2023
3788736
wip: fix lock.json
Siolto Sep 7, 2023
75fcccd
wip: increase UI5 timeout
Siolto Sep 7, 2023
2e4558d
docs: update docs
Siolto Sep 7, 2023
ff6d069
feat: final basic auth additions
Siolto Sep 8, 2023
e12c954
feat: refactor basic authenticator
Siolto Sep 8, 2023
264628e
ci: add context info
vobu Sep 8, 2023
9c862bf
chore: reenable lint-stage config
vobu Sep 8, 2023
ee133e5
Merge branch 'main' into pr/ChristophMarotzke/534
vobu Sep 8, 2023
238c8eb
refactor: safeguard regex matches
vobu Sep 8, 2023
5a1dda6
chore(deps): update
vobu Sep 8, 2023
3bcbf71
ci(auth): sequence
vobu Sep 8, 2023
c2440fd
refactor: ts-ignore -> ts-expect-error
vobu Sep 8, 2023
9b7a30f
Merge branch 'main' into feat/basic-auth-extension
Siolto Sep 8, 2023
bacdc04
ci: increase timeout
vobu Sep 8, 2023
2a74cb6
Merge branch 'feat/basic-auth-extension' of github.com:ChristophMarot…
vobu Sep 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/wdi5-tests_capAuth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CAP-auth
on:
pull_request:
branches:
- main
- main-v2
paths:
# relevant
- "client-side-js/**"
- "examples/**"
- "scripts/**"
- "src/**"
# don't run on changes to these
- "!.husky/**"
- "!.vscode/**"
- "!docs/**"
- "!.*"
- "!*.md"
- "!*.cjs"

env:
wdi5_username: "admin" # dummy user for cap app

jobs:
authorize:
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true

tests:
needs: authorize
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20]

steps:
- name: check out repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
submodules: recursive

- name: use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"

# install both module + sample app(s) deps + cap submodule
- name: install packages (wdi5 + sample app(s))
run: |
npm pkg delete scripts.prepare
npm ci

# build things
- name: build
run: npm run build

- name: cap authentication
run: npm run test:capAuth
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "examples/cap-bookshop-wdi5"]
path = examples/cap-bookshop-wdi5
url = git@github.com:SAP-samples/cap-bookshop-wdi5.git
branch = wdi5-tests
24 changes: 14 additions & 10 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

Generally speaking, the authentication behavior mimicks that of a regular user session: first, the `baseUrl` (from the `wdio.conf.(j|t)s`-file) is opened in the configured browser. Then, the redirect to the Authentication provider is awaited and [the credentials](#credentials) are supplied.

BTP-, IAS-, Office365- and custom IdP all supply credentials as a user would, meaning they're literally typed into the respective input fields on each login screen.
BTP-, IAS-, Office365- and custom IdP all supply credentials as a user would, meaning they're literally typed into the respective input fields on each login screen.
Basic Authentication prepends username and password in encoded form to the URL, resulting in an `HTTP` `GET` in the form of `https://username:encoded-pwd@your-deployed-UI5.app`.

!> Multi-Factor Authentication is not supported as it's nearly impossible to manage any media break (e.g. browser ↔ mobile) in authentication flows out of the box

For you as users, authentication is done at design-time, meaning: **by configuration only, not programmatically**.
For you as users, authentication is done at design-time, meaning: **by configuration only, not programmatically**.
This especially means that no changes in the test code are needed for using authentication in `wdi5` tests!

?> No [skipping of the UI5 injection](configuration#skipinjectui5onstart) is necessary, `wdi5` takes care of the correct order of operation (first authentication, then injecting UI5) itself.

!> Credentials can only be supplied via environment variables, not in any configuration file.
!> Credentials can only be supplied via environment variables, not in any configuration file.
More on the [how and why below](#credentials) :point_down:

## Configuration
Expand Down Expand Up @@ -127,8 +127,8 @@ The `BTP` authenticator will automatically detect whether the login process is a

?> only available in `wdi5` >= 2

Using the 'Identity Authentication Service (IAS) Authenticator' in `wdi5` is a subset of the [above BTP Authentication](#sap-cloud-idp-default-btp-identity-provider).
It takes the same configuration options, plus `disableBiometricAuth` (default: `true`, which you want in almost all cases) and `idpDomain`. The latter is necessary to satisfy cookie conditions in the remote-controlled browser.
Using the 'Identity Authentication Service (IAS) Authenticator' in `wdi5` is a subset of the [above BTP Authentication](#sap-cloud-idp-default-btp-identity-provider).
It takes the same configuration options, plus `disableBiometricAuth` (default: `true`, which you want in almost all cases) and `idpDomain`. The latter is necessary to satisfy cookie conditions in the remote-controlled browser.
Set `idpDomain` to the _domain-only_ part of your IAS tenant URL, e.g. `weiruhg.accounts.ondemand.com`, _omitting_ the protocol prefix (`https://`).

!> If `disableBiometricAuth` is set to `true`, `idpDomain` must be set as well!
Expand Down Expand Up @@ -310,7 +310,8 @@ baseUrl: "https://caution_your-deployed-ui5-with-basic-auth.app",
capabilities: {
// browserName: "..."
"wdi5:authentication": {
provider: "BasicAuth" //> mandatory
provider: "BasicAuth", //> mandatory
basicAuthUrls: ["https://your-custom-basic-auth-endpoint"] //> optional: default is the configured `baseUrl`
}
}
```
Expand All @@ -325,7 +326,8 @@ capabilities: {
capabilities: {
// browserName: "..."
"wdi5:authentication": {
provider: "BasicAuth" //> mandatory
provider: "BasicAuth", //> mandatory
basicAuthUrls: ["https://your-custom-basic-auth-endpoint"] //> optional: default is the configured `baseUrl`
}
}
},
Expand All @@ -334,7 +336,8 @@ capabilities: {
capabilities: {
// browserName: "..."
"wdi5:authentication": {
provider: "BasicAuth" //> mandatory
provider: "BasicAuth", //> mandatory
basicAuthUrls: ["https://your-custom-basic-auth-endpoint"] //> optional: default is the configured `baseUrl`
}
}
}
Expand All @@ -343,6 +346,7 @@ capabilities: {

<!-- tabs:end -->


## Credentials

Exposing credentials in configuration files that were accidentally checked into version control is one of the most common causes of data leaks. That's why `wdi5` only allows providing credentials through environment variables at runtime.
Expand All @@ -351,7 +355,7 @@ Exposing credentials in configuration files that were accidentally checked into

There are multiple ways to achieve that in Node.js, with [using the `dotenv`-module](https://www.npmjs.com/package/dotenv) being one of the most popular: `dotenv` automatically transfers all variables from a `.env`-file into the environment of the app at runtime.

In single browser scenarios, `wdi5_username` and `wdi5_password` need to be provided.
In single browser scenarios, `wdi5_username` and `wdi5_password` need to be provided.
In multiremote scenarios, credential keys in the environment adhere to `wdi5_$browserInstanceName_username` and `wdi5_$browserInstanceName_password`.

<!-- tabs:start -->
Expand Down Expand Up @@ -381,5 +385,5 @@ wdi5_nix_password='dmac'

## Miscellaneous

Why the `wdi5:...` prefix?
Why the `wdi5:...` prefix?
Because the W3C standard for providing options in the WebDriver protocol asks for any vendor-specfic setting to have a unique prefix.
1 change: 1 addition & 0 deletions examples/cap-bookshop-wdi5
Submodule cap-bookshop-wdi5 added at c288cc
2 changes: 1 addition & 1 deletion examples/ui5-ts-app/webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate" />
Expand Down
Loading
Loading