The LinkSmart® Border Gateway (BGW) can authenticate and authorize access to HTTP and MQTT services for users defined in an OpenID Connect provider.
If anonymous access to an endpoint accessed via browser is not allowed, the browser will present fields for username and password. You can either type in username and password (Basic access authentication) or put an access token (see below) in the username field. Leave the password field empty if you do the latter.
>>> How to: send credentials in header.<<<
- User provides username/password in the REST request
- BGW intercepts the request and negotiates with an OpenID Connect server for an access token
- If authenticated, BGW forwards the request to API
>>> How to: use Bearer authentication in Postman <<<
User directly negotiates with an OpenID Connect server for an access token. Example via curl for Keycloak:
- User provides the access token in the request
- BGW intercepts the request and validates the token
- If authenticated, BGW forwards the request to the API
If you connect to the Border Gateway via MQTT protocol, you can deliver username and password as defined in the MQTT standard. You can also deliver an access token (as described above for HTTP) in the MQTT username field. Leave the password field empty if you do. Both types of credentials will be validated against the OpenID Connect provider.
The access token is then verified and authorized (see below). If everything is ok, the WebSocket connection is established, otherwise rejected.
The LinkSmart® Border Gateway also offers some basic authorization capabilities. Authorization rules are defined as user and / or group attributes in the OpenID Connect Provider (see subpage).
- PROTOCOL is the transfer protocol (currently HTTP, HTTPS, MQTT or WS)
- METHOD is the method in regards to the protocol, e.g. GET,POST,DELETE for HTTP and PUB,SUB for MQTT. For WebSocket connections only method CONNECT is allowed.
- DOMAIN is the fully qualified domain name (FQDN)
- Case MQTT / WS: TCP port of the target / upstream service
- Case HTTPS: In a standard deployment the BGW External Interface will add headers x-forwarded-proto and x-forwarded-host (including port) and forward to the BGW HTTP proxy so in the rules regarding HTTP services you need to use protocol HTTPS and port 443 in your rule definitions. If you deploy a BGW HTTP Proxy without the BGW External Interface, you can configure your web server (e.g. nginx) to set headers x-forwarded-proto and x-forwarded-host and define rules in the same way.
- Case HTTP: If you do not use TLS at all or cannot configure your web server to set headers x-forwarded-proto and x-forwarded-host, you need to use HTTP in your rule definitions and the TCP port of BGW HTTP proxy.
- PATH is resource information and may contain slashes itself. For HTTP, it is the resource path (e.g. confluence/display/COM). For MQTT, it is the topic. For WebSocket connections PATH is currently not relevant.
Loolsely based on MQTT topic specification: https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices
- Every slash adds a new section. E.g.: a/b consists of two sections and a/b/ consists of three sections last of which contains an empty string.
- Strings are case-sensitive
- A plus + is a single section wildcard. E.g.: a/+ matches a/b but not a/b/ and a/b/c
- A hash # is a multi-section wildcard and may only be used in the end. E.g.: a/# matches all a/b and a/b/ and a/b/c