Skip to content

Authentication and authorization of pub/sub #896

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

Merged
merged 49 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9104cd9
Added broker security
kleunen Oct 18, 2021
d1b187e
Added login to broker
kleunen Oct 19, 2021
096c743
Authorization of publish
kleunen Oct 19, 2021
1e7cd88
More efficient auth subscribe handling
kleunen Oct 19, 2021
55c0631
Some cleanup for temporary strings
kleunen Oct 20, 2021
ce05f88
Store password using hash in auth file
kleunen Oct 21, 2021
beaaf97
Allow broker to run without security
kleunen Oct 23, 2021
d89bfd1
Use anonymous login for test
kleunen Oct 24, 2021
b23d857
Configuration of hash/salt is required
kleunen Oct 24, 2021
487e74a
Obtain username from certificate
kleunen Oct 26, 2021
e169c61
Small cleanup
kleunen Oct 26, 2021
902d010
Initial test case for topic subscribe authorization
kleunen Jan 3, 2022
1b66c51
Small cleanup to subscribe authorization
kleunen Jan 3, 2022
75db887
Send failed/unauthorized return code if user is now allowed to subscr…
kleunen Jan 4, 2022
2901be2
Increase unit/system test timeout
kleunen Jan 5, 2022
53f1ad0
Performance optimization, pre-calculate topic filter tokens
kleunen Jan 5, 2022
089f333
Performance optimization subscription allow
kleunen Jan 5, 2022
900db10
Compile fix
kleunen Jan 5, 2022
e7415b1
Resolve some coding guideline errors
kleunen Jan 13, 2022
1e04cbf
Send connack on not authorized
kleunen Jan 14, 2022
e21ab34
Validate configuration topic filter
kleunen Jan 14, 2022
4e05bd2
Specify salt and hash per user
kleunen Jan 21, 2022
c6aeb37
Cleanup test cases, fixed client id, fixed authorization duplicate to…
kleunen Jan 22, 2022
b6bf702
Remove temporary in get_auth_sub_by_user
kleunen Jan 22, 2022
53c47df
Default configuration if no auth file is specified
kleunen Jan 22, 2022
7b5b494
Client id prepend username
kleunen Jan 23, 2022
1c080d4
simply prepend salt to password before hashing
kleunen Jan 23, 2022
785d1d0
Send puback/pubrec with error code if not authorized to publish
kleunen Jan 23, 2022
9b1243f
Added an unauthorized login method
kleunen Jan 23, 2022
ccc24ba
Make session id unique by using composite key
kleunen Jan 24, 2022
a1a675d
Generate warning on sha256 authentication without salt specified
kleunen Jan 27, 2022
ff91cf3
Rename unauthorized to unauthenticated and add comments to auth.json
kleunen Jan 29, 2022
95d3c9c
Fix generated client_id handling
kleunen Jan 30, 2022
8dd8121
- Added comments to json (# comment)
kleunen Jan 30, 2022
87a574a
Added additional test cases with slash
kleunen Feb 13, 2022
f0db9ac
Remove prev access in broker security
kleunen Feb 15, 2022
ee8d71e
Add authorization priority
kleunen Feb 15, 2022
9eb0e3b
Added any group for any or all users
kleunen Mar 9, 2022
9d4f352
Added req/res authorization
kleunen Mar 9, 2022
ba45cc4
Added req/res authorization
kleunen Mar 9, 2022
a15ebdb
Added loading certificate file
kleunen Mar 20, 2022
27792e1
Moved certificate field to general configuration instead of auth file
kleunen Mar 23, 2022
2277310
Added additional test case for checking subscription
kleunen Mar 25, 2022
26cbe82
Check verify_field in broker also if TLS server is not enabled
kleunen Mar 25, 2022
0f5f28a
Broker verify certificate error handling fix
kleunen Mar 25, 2022
26aa8c0
Added broker option to specify verify field
kleunen Mar 25, 2022
29a8519
Add error message in broker when authorization file not loaded
kleunen Mar 27, 2022
31a4170
Broker fix loading certificate before calling listen
kleunen Mar 27, 2022
9da0a15
broker: Don't set username if no field in certificate matches
kleunen Mar 28, 2022
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
70 changes: 70 additions & 0 deletions example/auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
# Configure username/login
"authentication": [
{
# Authenticates user by password using sha256 hash and specified salt for password sha256(salt + password)
"name": "u1",
"method": "sha256",
"salt": "salt",
"digest": "38ea2e5e88fcd692fe177c6cada15e9b2db6e70bee0a0d6678c8d3b2a9aae2ad"
}
,
{
# Authenticates user by client certificate
"name": "u2",
"method": "client_cert",
"field": "CNAME"
}
,
{
# Handles all users that login without username / password
"name": "anonymous",
"method": "anonymous"
}
,
{
# Handles all users that are not authenticated (non-existing user, invalid password)
"name": "unauthenticated",
"method": "unauthenticated"
}
],

# Combine users into groups
"groups": [
{
# Users can be combined into groups, group name starts with @
"name": "@g1",
"members": ["u1", "u2", "anonymous", "unauthenticated"]
}
],

# Give access to topics
"authorization": [
{
# Specified users and groups are denied to publish on this topic
"topic": "#",
"deny": { "pub": ["@g1"] }
},
{
# Specified users and groups are denied to subscribe on this topic"
"topic": "#",
"deny": { "sub": ["@g1"] }
},
{
# Specified users and groups are allowed to subscribe and publish on this topic"
"topic": "sub/#",
"allow": {
"sub": ["@g1"],
"pub": ["@g1"]
}
},
{
# Specified users and groups are denied to subscribe and publish on this topic
"topic": "sub/topic1",
"deny": {
"sub": ["u1", "anonymous"],
"pub": ["u1", "anonymous"]
}
}
]
}
1 change: 1 addition & 0 deletions example/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
verbose=1
certificate=server.crt.pem
private_key=server.key.pem
auth_file=auth.json

# 0 means automatic
# Num of vCPU
Expand Down
Loading