Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
immerda
Immerda Apps
iapi
Commits
b7606a89
Commit
b7606a89
authored
Jul 20, 2021
by
o@immerda.ch
Browse files
fix all the tests
parent
38151856
Pipeline
#7989
passed with stage
in 2 minutes and 33 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
db/migrations/mail/20210720000000_webauthn_add_sign_count.rb
View file @
b7606a89
...
...
@@ -2,11 +2,5 @@ require 'webauthn'
class
WebauthnAddSignCount
<
ActiveRecord
::
Migration
[
5.2
]
def
change
add_column
:web_authn_credentials
,
:signcount
,
:integer
,
default:
0
# We now store keys ids in the original webauthn urlsafe base64
WebAuthnCredential
.
each
do
|
w
|
w
.
external_id
=
WebAuthn
.
standard_encoder
.
encode
(
Base64
.
decode64
(
w
.
external_id
))
w
.
save!
end
end
end
db/migrations/mail/20210720000001_webauthn_migrate.rb
0 → 100644
View file @
b7606a89
require
'webauthn'
class
WebauthnMigrate
<
ActiveRecord
::
Migration
[
5.2
]
def
up
# We now store keys ids in the original webauthn urlsafe base64
WebAuthnCredential
.
all
.
each
do
|
w
|
w
.
external_id
=
WebAuthn
.
standard_encoder
.
encode
(
Base64
.
decode64
(
w
.
external_id
))
w
.
save!
end
end
end
tests/replay/replay.rb
View file @
b7606a89
...
...
@@ -4,7 +4,8 @@ require 'yaml'
require
'json'
require
'rest_client'
require
'rotp'
require
"webauthn/fake_client"
require
'webauthn'
require
'webauthn/fake_client'
require
'onelogin/ruby-saml'
DIR
=
File
.
expand_path
(
File
.
dirname
(
__FILE__
))
...
...
@@ -44,6 +45,10 @@ MASTER_KEY = File.join(DIR, '../../../local_data/iapi_certs/master.kring')
WEBAUTHN_REGISTER_ORIGIN
=
'https://users.127.0.0.1.nip.io:3000'
WEBAUTHN_VERIFY_ORIGIN
=
'https://login.127.0.0.1.nip.io:3002'
WebAuthn
.
configure
do
|
config
|
config
.
origin
=
WEBAUTHN_VERIFY_ORIGIN
end
# we must be able to reset the origin
class
WebAuthn::FakeClient
def
origin
=
(
o
)
...
...
@@ -217,10 +222,10 @@ def patch_variables(data)
r
[
'SAMLRequest'
]
elsif
data
==
'%%WEBAUTHN_ATTESTATION_OBJECT%%'
VARIABLE
[
'WEBAUTHN_ATTESTATION_RESPONSE'
]
||=
webauthn_attestation_response
Base64
.
strict_encode64
(
VARIABLE
[
'WEBAUTHN_ATTESTATION_RESPONSE'
][
:
attestation
_o
bject
]
)
VARIABLE
[
'WEBAUTHN_ATTESTATION_RESPONSE'
][
'
attestation
O
bject
'
]
elsif
data
==
'%%WEBAUTHN_CLIENT_DATA_JSON%%'
VARIABLE
[
'WEBAUTHN_ATTESTATION_RESPONSE'
]
||=
webauthn_attestation_response
Base64
.
strict_encode64
(
VARIABLE
[
'WEBAUTHN_ATTESTATION_RESPONSE'
][
:
client
_d
ata
_json
])
VARIABLE
[
'WEBAUTHN_ATTESTATION_RESPONSE'
][
'
client
D
ata
JSON'
]
elsif
data
==
'%%WEBAUTHN_ASSERTION%%'
webauthn_assertion_response
elsif
data
==
'%%TODAY%%'
...
...
@@ -238,23 +243,23 @@ end
def
webauthn_attestation_response
VARIABLE
[
'WEBAUTHN_CLIENT'
]
=
WebAuthn
::
FakeClient
.
new
(
WEBAUTHN_REGISTER_ORIGIN
)
public_key_credential
=
VARIABLE
[
'WEBAUTHN_CLIENT'
].
create
(
challenge:
Base64
.
strict_decode64
(
VARIABLE
[
'%%WEBAUTHN_CHALLENGE%%'
]
)
,
challenge:
VARIABLE
[
'%%WEBAUTHN_CHALLENGE%%'
],
rp_id:
VARIABLE
[
'%%WEBAUTHN_RP_ID%%'
],
)
public_key_credential
[
:
response
]
public_key_credential
[
'
response
'
]
end
def
webauthn_assertion_response
client
=
VARIABLE
[
'WEBAUTHN_CLIENT'
]
client
.
origin
=
WEBAUTHN_VERIFY_ORIGIN
assertion
=
client
.
get
(
challenge:
Base64
.
strict_decode64
(
VARIABLE
[
'%%WEBAUTHN_CHALLENGE%%'
]
)
,
rp_id:
VARIABLE
[
'%%WEBAUTHN_RP_ID%%'
])
assertion
=
client
.
get
(
challenge:
VARIABLE
[
'%%WEBAUTHN_CHALLENGE%%'
],
rp_id:
VARIABLE
[
'%%WEBAUTHN_RP_ID%%'
])
{
challenge:
VARIABLE
[
'%%WEBAUTHN_CHALLENGE%%'
],
credential_id:
Base64
.
strict_encode64
(
assertion
[
:
id
]
)
,
client_data_json:
Base64
.
strict_encode64
(
assertion
[
:
response
][
:
client
_d
ata
_json
])
,
authenticator_data:
Base64
.
strict_encode64
(
assertion
[
:
response
][
:
authenticator
_d
ata
]
)
,
signature:
Base64
.
strict_encode64
(
assertion
[
:
response
][
:
signature
]
)
,
credential_id:
assertion
[
'
id
'
],
client_data_json:
assertion
[
'
response
'
][
'
client
D
ata
JSON'
]
,
authenticator_data:
assertion
[
'
response
'
][
'
authenticator
D
ata
'
],
signature:
assertion
[
'
response
'
][
'
signature
'
],
}
end
...
...
tests/replay/scripts/2fa.log
View file @
b7606a89
...
...
@@ -258,7 +258,7 @@
:response:
:status: 200
:body:
- '{"result":"success", "credential_options": {"challenge": "%%WEBAUTHN_CHALLENGE%%", "pubKeyCredParams": [{"type": "public-key", "alg": -7}, {"type": "public-key", "alg": -37}, {"type": "public-key", "alg": -257}], "user": {"id": "dXNlcjFAZXhhbXBsZS5jb20=", "name": "user1@example.com", "displayName": "user1@example.com"}, "rp": {"name": "iAPI RP",
"icon": "https://www.immerda.ch/favicon.ico",
"id": "%%WEBAUTHN_RP_ID%%"}, "exclude
_c
redentials": []}}'
- '{"result":"success", "credential_options": {"challenge": "%%WEBAUTHN_CHALLENGE%%",
"timeout": 120000,
"pubKeyCredParams": [{"type": "public-key", "alg": -7}, {"type": "public-key", "alg": -37}, {"type": "public-key", "alg": -257}], "user": {"id": "dXNlcjFAZXhhbXBsZS5jb20=", "name": "user1@example.com", "displayName": "user1@example.com"}, "rp": {"name": "iAPI RP", "id": "%%WEBAUTHN_RP_ID%%"}, "exclude
C
redentials": []}}'
---
:request:
:method: :post
...
...
tests/replay/scripts/bills.log
View file @
b7606a89
...
...
@@ -129,7 +129,7 @@
:response:
:status: 200
:body:
- '{"result":"success","
notfound":true
}'
- '{"result":"success","
status":"empty"
}'
---
:request:
:method: :post
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment