-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow the specs more closely, switch to JWTs.jl, and fix the tests (#9)
* Replace JSONWebTokens.jl with JWTs.jl * Follow the specs more closely and fix tests * Update Project.toml * Fix Documenter * Fix typo * Add `/metadata` fallback * Additional test * Extend tests * Make keyid mandatory * Update public_jwkset.json * Simplify tests
- Loading branch information
Showing
13 changed files
with
222 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
name = "SMARTBackendServices" | ||
uuid = "78af60b6-7677-4c75-8291-bd270d1b4390" | ||
authors = ["Dilum Aluthge", "contributors"] | ||
version = "1.0.1" | ||
version = "2.0.0" | ||
|
||
[deps] | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" | ||
HealthBase = "94e1309d-ccf4-42de-905f-515f1d7b1cae" | ||
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" | ||
JSONWebTokens = "9b8beb19-0777-58c6-920b-28f749fee4d3" | ||
JWTs = "d850fbd6-035d-5a70-a269-1ca2e636ac6c" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" | ||
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" | ||
|
||
[compat] | ||
HTTP = "0.9.3" | ||
HealthBase = "1.0.1" | ||
JSON3 = "1.5.1" | ||
JSONWebTokens = "0.3.4, 1" | ||
TimeZones = "1.5.3" | ||
JWTs = "0.2.4" | ||
URIs = "1.2" | ||
julia = "1.5" | ||
|
||
[extras] | ||
JSONWebTokens = "9b8beb19-0777-58c6-920b-28f749fee4d3" | ||
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["JSONWebTokens", "Test"] | ||
test = ["MbedTLS", "Test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
SMARTBackendServices = "78af60b6-7677-4c75-8291-bd270d1b4390" | ||
|
||
[compat] | ||
Documenter = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ makedocs(; | |
"Home" => "index.md", | ||
"API" => "api.md", | ||
], | ||
strict=true, | ||
) | ||
|
||
deploydocs(; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,55 @@ | ||
token_endpoint = "https://launch.smarthealthit.org/v/r4/auth/token" | ||
# This test uses the public https://launch.smarthealthit.org test server | ||
# | ||
# In the webinterface, select "Launch Type": "Backend Service" | ||
# and then switch to the "Client Registration & Validation" tab | ||
# | ||
# There you can register a client (with randomly generated ID), | ||
# possibly restricted to some scope, | ||
# with a JWK set of public keys for authentication. | ||
# | ||
# Use the base URL at the bottom of the page to connect to the | ||
# server with the stated client ID, scope, and keys. | ||
# | ||
# A private key together with a public JWK set can be generated | ||
# e.g. with https://mkjwk.org/ (alternatively, you can e.g. | ||
# generate the key with openssl and create the JWK set manually): | ||
# 1. Select "Key Use": "Signature" | ||
# 2. Select "Algorithm": "RS384" | ||
# 3. Specify a key id (or let it be generated automatically) | ||
# 4. Check "Show X.509" | ||
# 5. Press "Generate" | ||
# 6. Update the `keyid` below | ||
# 7. Save the private key (in X.509 format) as ./key/private.pem | ||
|
||
client_id = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwdWJfa2V5IjoiTFMwdExTMUNSVWRKVGlCUVZVSk1TVU1nUzBWWkxTMHRMUzBLVFVsSlFrbHFRVTVDWjJ0eGFHdHBSemwzTUVKQlVVVkdRVUZQUTBGUk9FRk5TVWxDUTJkTFEwRlJSVUYzWVdvMVoza3hkRXRvVGtOWVdYTjNOV0YzVkFwd1p5OVRja2xuYm1sU1YybElVVmwyZDFseWFrSk5WSHBYUkhkcGQyRTNXbkZLTDNSalRFTk5lR1Y1T0dRMlRHdDRWbkpoYldOb1lqWkdSMnhaZERaUkNtRnZNbkpRWlRSNGJVZ3hkak4zZW1kbVZqaEljbTFUTTI5R2NqbDRjRFJPTm5rNGNtdFdkekZ2Vmtoc2RqZHpVRTV0VlRkell5OHhhU3RJY1ZOUlRFb0thM3BWY1dOQ2FubzFVME14YkhwMlpYaG5jVzkxWjNKNGRUVk5abWwwTmtGd1pHRjFSVGc0U3k5dVNGVk9TM1l2T1ROWmFqTkNaM3BNSzBGV1UwUkpRUW92Ynpsc2VFVlplVmxHV1RBek5HaFJSVmhwVFVFME4yY3ZVRk5ZU20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Gr5Tr4GBtxphtnSr9tWzDA0noX9VhF4AehYMdG2xtbVGmkERRs0PKGHpQUYXZ7YDkxkzKwnveok4lJS73fRitWcgBZi1TaVWZPOVs2rlXVDW57k87h1rzaofgvYFpfGOdfHmP87o2VXAQ8XYnW8THoLxwcdICnV9mY0xZ8YnuKR38XvEiPlxax5ZF77YQ5sPbFy53Ru6Ci2Dly6vU9quuTVK3MJaQI1IUfRqLQFwUivtXl7iFDH0mPWQUs5skRzXKQEcnLVR2fU0TVt39MX5WnSPgoeNVwxt84hsseOKbFJzZmGXSjScbFLDqUN3DKH07KHKOs0eMIYGw0dnnlvjlQM4NTlgTyogIfgBwLfCeXuTdEHBXkImNCDDqNKsxVS9irVCWvZcDTxjrY7nt1fPW3WoGfGVjxm2q5ao71bmMHIrxHuuOwk1G1C1z" | ||
scope = "system/*.rs" | ||
|
||
smart_config = BackendServicesConfig(; | ||
iss = "https://whatever.smart/our-sample-backend-service", | ||
sub = client_id, | ||
private_key = JSONWebTokens.RS384(test_private_key), | ||
scope = "system/*.*", | ||
token_endpoint = token_endpoint, | ||
) | ||
# Signing key (RS384 algorithm, i.e., SHA384 hash function) | ||
key = JWTs.JWKRSA(MbedTLS.MD_SHA384, MbedTLS.parse_keyfile(joinpath(@__DIR__, "key", "private.pem"))) | ||
keyid = "Yb09hTDCqmo0UttScFOf37Vzx19jiDlbnzYQYAv6uXk" | ||
|
||
smart_result = backend_services(smart_config) | ||
smart_config = BackendServicesConfig(; base_url, client_id, key, keyid, scope) | ||
|
||
smart_result = backend_services(smart_config) | ||
@test smart_result isa SMARTBackendServices.BackendServicesResult | ||
|
||
access_token = get_fhir_access_token(smart_result) | ||
|
||
@test access_token isa AbstractString | ||
|
||
@test length(access_token) > 1 | ||
|
||
@testset "token_endpoint" begin | ||
# Correct settings | ||
token_endpoint_wellknown = SMARTBackendServices._token_endpoint_wellknown(smart_config) | ||
@test token_endpoint_wellknown isa String | ||
token_endpoint_metadata = SMARTBackendServices._token_endpoint_metadata(smart_config) | ||
@test token_endpoint_metadata isa String | ||
@test token_endpoint_metadata === token_endpoint_wellknown | ||
|
||
# Incorrect base url | ||
config = BackendServicesConfig(; base_url = "https://google.com", client_id, key, keyid, scope) | ||
@test SMARTBackendServices._token_endpoint_wellknown(config) === nothing | ||
@test SMARTBackendServices._token_endpoint_metadata(config) === nothing | ||
@test_throws ErrorException("SMART configuration: Violation of the FHIR specification. The FHIR server does neither convey its SMART capabilities using a Well-Known Uniform Resource Identifiers (URIs) JSON file nor its CapabilityStatement.") backend_services(config) | ||
end |
Oops, something went wrong.
84ead00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
84ead00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/100953
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: