Commit Graph

208 Commits

Author SHA1 Message Date
Luke Bakken 9bcd4328d2
Use case-insensitive `lists:member`
References:
* [`RMQ-1585`](https://vmw-jira.broadcom.net/browse/RMQ-1585)
* https://github.com/lukebakken/rmq-1585
2025-03-26 16:40:23 -07:00
Michael Klishin 968eefa1bb
Bump (c) line year
There are no functional changes to this massive diff.
2025-01-01 17:54:10 -05:00
Lois Soto Lopez 3ff7e82c5c Provide specific f. to fix client ssl options
Provides a specific function to fix client ssl options, i.e.: apply all
fixes that are applied for TLS listeneres and clients on previous
versions but also sets `cacerts` option to CA certificates obtained by
`public_key:cacerts_get`, only when no `cacertfile` or `cacerts` are
provided.
2024-10-21 18:00:06 -04:00
Loïc Hoguin 5222bea44e
ldap auth backend: Drop support for pre-OTP-25 search results
The search results record change was done in OTP-25, which is
no longer supported. So we can use the modern search results
record and drop the compatibility clauses.

For more context:

* 8d8847e069
* https://github.com/erlang/otp/pull/5538
2024-09-30 12:35:43 +02:00
Michael Klishin 15fe108cc3 LDAP: allow tagged values to be used for sensitive settings
Plus a drive-by Dialyzer improvement.
2024-08-14 11:57:37 -04:00
Michael Klishin f414c2d512
More missed license header updates #9969 2024-02-05 11:53:50 -05:00
Arnaud Cogoluègnes 1f89ede396
Remove rabbit_authz_backend:state_can_expire/0
Use expiry_timestamp/1 instead, which returns 'never'
if the credentials do not expire.

Fixes #10382
2024-01-24 09:58:59 +01:00
Arnaud Cogoluègnes 33c64d06ea
Add expiry_timestamp/1 callback to authz backend behavior
Backends return 'never' or the timestamp of the expiry time
of the credentials. Only the OAuth2 backend returns a timestamp,
other RabbitMQ authz backends return 'never'.

Client code uses rabbit_access_control, so it contains now
a new expiry_timestamp/1 function that returns the earliest
expiry time of the underlying backends.

Fixes #10298
2024-01-19 14:46:47 +01:00
Michael Klishin 01092ff31f
(c) year bumps 2024-01-01 22:02:20 -05:00
Michael Klishin 1b642353ca
Update (c) according to [1]
1. https://investors.broadcom.com/news-releases/news-release-details/broadcom-and-vmware-intend-close-transaction-november-22-2023
2023-11-21 23:18:22 -05:00
Marcial Rosales b53ef89825 Support non-ascii attribute values 2023-08-23 13:14:13 +01:00
Marcial Rosales a70539a1a1 Remove debug log statements 2023-08-14 13:09:58 +01:00
Marcial Rosales dbffccba9d Fix #9043 2023-08-14 11:51:46 +01:00
Michael Klishin ec4f1dba7d
(c) year bump: 2022 => 2023 2023-01-01 23:17:36 -05:00
Rin Kuryloski bef2756b5f Fixes for various dialyzer warnings 2022-12-02 09:14:08 +01:00
Simon Unge 09d84e6bd5 See #4842. Obfuscate impl value 2022-11-09 15:14:51 -08:00
Luke Bakken 7fe159edef
Yolo-replace format strings
Replaces `~s` and `~p` with their unicode-friendly counterparts.

```
git ls-files *.erl | xargs sed -i.ORIG -e s/~s>/~ts/g -e s/~p>/~tp/g
```
2022-10-10 10:32:03 +04:00
Luke Bakken 8d8847e069
Take other eldap_search_result cases into account
Reported here
https://github.com/rabbitmq/rabbitmq-server/discussions/4281#discussioncomment-2508220

Fixes #4444

Follow-up to #4285
2022-04-05 07:09:23 -07:00
Michael Klishin c38a3d697d
Bump (c) year 2022-03-21 01:21:56 +04:00
Michael Klishin 730856e296
LDAP: match on eldap_search_result record for OTP 24.3 compat
In https://github.com/erlang/otp/pull/5538, the eldap_search_result
record structure has changed:
https://github.com/erlang/otp/pull/5538/files#diff-30e064e89b115da7e974f229ed5c92f28e489da679ef42f17e70b9e7cf874179R24

It does have a default but for code
compiled on, say, Erlang 23.0, which is the case for current RabbitMQ
releases, it would still be a breaking change resulting in
case expression matching failures (a case_clause).

Closes #4284.
2022-03-17 16:47:40 +04:00
Luke Bakken 160a74862a
Update link in comment
It is a useful comment, so update all the links to the correct place on the internet:
http://erlang.org/pipermail/erlang-questions/2010-April/050508.html
2021-11-04 15:45:17 -07:00
Philip Kuryloski 29ddca78aa Fix additional Erlang 24 compiler warnings 2021-05-17 12:05:28 +02:00
Philip Kuryloski 388654c542
Add a partial Bazel build (#2938)
Adds WORKSPACE.bazel, BUILD.bazel & *.bzl files for partial build & test with Bazel. Introduces a build-time dependency on https://github.com/rabbitmq/bazel-erlang
2021-03-29 11:01:43 +02:00
Michael Klishin 97ff62d3b2
Drop trailing newlines from logged messages where possible
Lager strips trailing newline characters but OTP logger with the default
formatter adds a newline at the end. To avoid unintentional multi-line log
messages we have to revisit most messages logged.

Some log entries are intentionally multiline, others
are printed to stdout directly: newlines are required there
for sensible formatting.
2021-03-11 15:17:37 +01:00
Jean-Sébastien Pédron cdcf602749
Switch from Lager to the new Erlang Logger API for logging
The configuration remains the same for the end-user. The only exception
is the log root directory: it is now set through the `log_root`
application env. variable in `rabbit`. People using the Cuttlefish-based
configuration file are not affected by this exception.

The main change is how the logging facility is configured. It now
happens in `rabbit_prelaunch_logging`. The `rabbit_lager` module is
removed.

The supported outputs remain the same: the console, text files, the
`amq.rabbitmq.log` exchange and syslog.

The message text format slightly changed: the timestamp is more precise
(now to the microsecond) and the level can be abbreviated to always be
4-character long to align all messages and improve readability. Here is
an example:

    2021-03-03 10:22:30.377392+01:00 [dbug] <0.229.0> == Prelaunch DONE ==
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>  Starting RabbitMQ 3.8.10+115.g071f3fb on Erlang 23.2.5
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>  Licensed under the MPL 2.0. Website: https://rabbitmq.com

The example above also shows that multiline messages are supported and
each line is prepended with the same prefix (the timestamp, the level
and the Erlang process PID).

JSON is also supported as a message format and now for any outputs.
Indeed, it is possible to use it with e.g. syslog or the exchange. Here
is an example of a JSON-formatted message sent to syslog:

    Mar  3 11:23:06 localhost rabbitmq-server[27908] <0.229.0> - {"time":"2021-03-03T11:23:06.998466+01:00","level":"notice","msg":"Logging: configured log handlers are now ACTIVE","meta":{"domain":"rabbitmq.prelaunch","file":"src/rabbit_prelaunch_logging.erl","gl":"<0.228.0>","line":311,"mfa":["rabbit_prelaunch_logging","configure_logger",1],"pid":"<0.229.0>"}}

For quick testing, the values accepted by the `$RABBITMQ_LOGS`
environment variables were extended:
  * `-` still means stdout
  * `-stderr` means stderr
  * `syslog:` means syslog on localhost
  * `exchange:` means logging to `amq.rabbitmq.log`

`$RABBITMQ_LOG` was also extended. It now accepts a `+json` modifier (in
addition to the existing `+color` one). With that modifier, messages are
formatted as JSON intead of plain text.

The `rabbitmqctl rotate_logs` command is deprecated. The reason is
Logger does not expose a function to force log rotation. However, it
will detect when a file was rotated by an external tool.

From a developer point of view, the old `rabbit_log*` API remains
supported, though it is now deprecated. It is implemented as regular
modules: there is no `parse_transform` involved anymore.

In the code, it is recommended to use the new Logger macros. For
instance, `?LOG_INFO(Format, Args)`. If possible, messages should be
augmented with some metadata. For instance (note the map after the
message):

    ?LOG_NOTICE("Logging: switching to configured handler(s); following "
                "messages may not be visible in this log output",
                #{domain => ?RMQLOG_DOMAIN_PRELAUNCH}),

Domains in Erlang Logger parlance are the way to categorize messages.
Some predefined domains, matching previous categories, are currently
defined in `rabbit_common/include/logging.hrl` or headers in the
relevant plugins for plugin-specific categories.

At this point, very few messages have been converted from the old
`rabbit_log*` API to the new macros. It can be done gradually when
working on a particular module or logging.

The Erlang builtin console/file handler, `logger_std_h`, has been forked
because it lacks date-based file rotation. The configuration of
date-based rotation is identical to Lager. Once the dust has settled for
this feature, the goal is to submit it upstream for inclusion in Erlang.
The forked module is calld `rabbit_logger_std_h` and is based
`logger_std_h` in Erlang 23.0.
2021-03-11 15:17:36 +01:00
Michael Klishin 66badb9492
LDAP plugin: handle undefined app env values, pass Dialyzer 2021-02-11 21:26:27 +03:00
Michael Klishin 8ea212a6b6
New configuration settings for TLS
* [Client] hostname verification matching: wildcard or none
 * SNI hostname or none

Closes #2805
2021-02-11 00:12:24 +03:00
Michael Klishin 52479099ec
Bump (c) year 2021-01-22 09:00:14 +03:00
dcorbacho 015e1152c2 Switch to Mozilla Public License 2.0 (MPL 2.0) 2020-07-10 20:19:35 +01:00
Michael Klishin ffefe91771 Explain 2020-03-24 16:08:11 +03:00
Luke Bakken d8ff8a548a Setting idle_timeout to 0 will request a connection for every operation
[171933299]
2020-03-23 14:32:59 -07:00
Luke Bakken ef14002fb6 Setting idle_timeout to 0 will request a connection for every operation
[171933299]
2020-03-23 10:29:26 -07:00
Jean-Sébastien Pédron 084605ab9d Update copyright (year 2020) 2020-03-10 16:02:56 +01:00
Luke Bakken dcb92cfabf Remove unused variable
See b67ccfbd15
2020-02-28 15:08:36 -08:00
Luke Bakken c0f43acfba Remove spammy log message
Fixes #118
2020-02-27 14:40:05 -08:00
Michael Klishin d9890ad642 (c) bump 2019-12-29 05:50:24 +03:00
Luke Bakken d9835870d2 Ensure results match expected rabbit_authz_backend behaviour
Fixes #116
2019-10-30 14:05:06 -07:00
Luke Bakken b843487019 Add warning messages when configuration values do not make sense 2019-10-14 09:58:58 -07:00
Michael Klishin 1d712739d5 Adapt to rabbit_authz_backend interface changes in rabbitmq/rabbitmq-auth-backend-oauth2#28. 2019-07-03 10:41:01 +02:00
Arnaud Cogoluègnes db497a2baf Propagate protocol-specific context
Information like MQTT client ID is now propagated to the LDAP registry
for all authentication and authorization functions.

References rabbitmq/rabbitmq-server#1767
2019-06-03 15:54:37 +02:00
Luke Bakken 4953a835d9 Rename unused variable to reflect changes
Small part of rabbitmq/rabbitmq-auth-backend-cache#20
2019-03-22 11:08:15 -07:00
Spring Operator 2afc58cf87 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# HTTP URLs that Could Not Be Fixed
These URLs were unable to be fixed. Please review them to see if they can be manually resolved.

* http://blog.listincomprehension.com/search/label/procket (200) with 1 occurrences could not be migrated:
   ([https](https://blog.listincomprehension.com/search/label/procket) result ClosedChannelException).
* http://dozzie.jarowit.net/trac/wiki/TOML (200) with 1 occurrences could not be migrated:
   ([https](https://dozzie.jarowit.net/trac/wiki/TOML) result SSLHandshakeException).
* http://dozzie.jarowit.net/trac/wiki/subproc (200) with 1 occurrences could not be migrated:
   ([https](https://dozzie.jarowit.net/trac/wiki/subproc) result SSLHandshakeException).
* http://e2project.org (200) with 1 occurrences could not be migrated:
   ([https](https://e2project.org) result AnnotatedConnectException).
* http://nitrogenproject.com/ (200) with 2 occurrences could not be migrated:
   ([https](https://nitrogenproject.com/) result ConnectTimeoutException).
* http://proper.softlab.ntua.gr (200) with 1 occurrences could not be migrated:
   ([https](https://proper.softlab.ntua.gr) result SSLHandshakeException).
* http://yaws.hyber.org (200) with 1 occurrences could not be migrated:
   ([https](https://yaws.hyber.org) result AnnotatedConnectException).
* http://choven.ca (503) with 1 occurrences could not be migrated:
   ([https](https://choven.ca) result ConnectTimeoutException).

# Fixed URLs

## Fixed But Review Recommended
These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended.

* http://fixprotocol.org/ (301) with 1 occurrences migrated to:
  https://fixtrading.org ([https](https://fixprotocol.org/) result SSLHandshakeException).
* http://erldb.org (UnknownHostException) with 1 occurrences migrated to:
  https://erldb.org ([https](https://erldb.org) result UnknownHostException).

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* http://cloudi.org/ with 27 occurrences migrated to:
  https://cloudi.org/ ([https](https://cloudi.org/) result 200).
* http://erlware.org/ with 1 occurrences migrated to:
  https://erlware.org/ ([https](https://erlware.org/) result 200).
* http://github.com/rabbitmq/rabbitmq-auth-backend-cache with 1 occurrences migrated to:
  https://github.com/rabbitmq/rabbitmq-auth-backend-cache ([https](https://github.com/rabbitmq/rabbitmq-auth-backend-cache) result 200).
* http://inaka.github.io/cowboy-trails/ with 1 occurrences migrated to:
  https://inaka.github.io/cowboy-trails/ ([https](https://inaka.github.io/cowboy-trails/) result 200).
* http://ninenines.eu with 6 occurrences migrated to:
  https://ninenines.eu ([https](https://ninenines.eu) result 200).
* http://www.actordb.com/ with 2 occurrences migrated to:
  https://www.actordb.com/ ([https](https://www.actordb.com/) result 200).
* http://www.cs.kent.ac.uk/projects/wrangler/Home.html with 1 occurrences migrated to:
  https://www.cs.kent.ac.uk/projects/wrangler/Home.html ([https](https://www.cs.kent.ac.uk/projects/wrangler/Home.html) result 200).
* http://www.rabbitmq.com/ldap.html with 4 occurrences migrated to:
  https://www.rabbitmq.com/ldap.html ([https](https://www.rabbitmq.com/ldap.html) result 200).
* http://www.rabbitmq.com/plugin-development.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/plugin-development.html ([https](https://www.rabbitmq.com/plugin-development.html) result 200).
* http://www.rebar3.org with 1 occurrences migrated to:
  https://www.rebar3.org ([https](https://www.rebar3.org) result 200).
* http://contributor-covenant.org with 1 occurrences migrated to:
  https://contributor-covenant.org ([https](https://contributor-covenant.org) result 301).
* http://contributor-covenant.org/version/1/3/0/ with 1 occurrences migrated to:
  https://contributor-covenant.org/version/1/3/0/ ([https](https://contributor-covenant.org/version/1/3/0/) result 301).
* http://inaka.github.com/apns4erl with 1 occurrences migrated to:
  https://inaka.github.com/apns4erl ([https](https://inaka.github.com/apns4erl) result 301).
* http://inaka.github.com/edis/ with 1 occurrences migrated to:
  https://inaka.github.com/edis/ ([https](https://inaka.github.com/edis/) result 301).
* http://lasp-lang.org/ with 1 occurrences migrated to:
  https://lasp-lang.org/ ([https](https://lasp-lang.org/) result 301).
* http://rabbitmq.com/access-control.html with 1 occurrences migrated to:
  https://rabbitmq.com/access-control.html ([https](https://rabbitmq.com/access-control.html) result 301).
* http://saleyn.github.com/erlexec with 1 occurrences migrated to:
  https://saleyn.github.com/erlexec ([https](https://saleyn.github.com/erlexec) result 301).
* http://www.mozilla.org/MPL/ with 7 occurrences migrated to:
  https://www.mozilla.org/MPL/ ([https](https://www.mozilla.org/MPL/) result 301).
* http://zhongwencool.github.io/observer_cli with 1 occurrences migrated to:
  https://zhongwencool.github.io/observer_cli ([https](https://zhongwencool.github.io/observer_cli) result 301).
2019-03-20 03:11:50 -05:00
Michael Klishin 52d7cba41d Drive by change: Lager adds a trailing new line 2019-02-08 03:42:16 +03:00
Yury.Alioshinov 866f50790f replace rabbit_log by rabbit_log_ldap 2019-02-08 01:48:10 +03:00
Luke Bakken dab0ccc006 Rather than crash return error if search results in referrals
Fixes #97

The case of a referral being returned has only been brought up once. For now, return an error. If this turns out to be a more common case, the referral URL should be parsed and chased.
2018-11-02 15:44:20 -07:00
Joel Forsberg f8fd4393e1 Fix LDAP evaluation resulting in list of strings.
The previous code tries to do weird things by exchanging the arguments being put in to re:run(). Bidirectional match might seem to work when the regular expression is just a couple of plaintexts, but is actually really wrong and also causes confusing log messages when your RE-expression end up in the string matching.

Secondly it seemed to handle multi-valued LDAP results by concatenating them into strings like "First_item;second_item" which makes for very interesting results when you try to match against R.Es like ^read$

This change guards against cases when the LDAP query evaluates to a list and fallbacks to regular do_match when the arguments aren't lists of strings.
2018-11-02 11:59:10 -07:00
Luke Bakken 85dcb36ce6 Add user_bind_pattern
This allows using a different pattern during the "simple bind" phase. If `user_bind_pattern` is defined, it is used, otherwise fall back to `user_dn_pattern`

Related to #98 and #99

(cherry picked from commit 7f32abde3b)
2018-10-31 02:43:38 +03:00
Luke Bakken 300004dfc6 Add unit test for ad_domain / ad_user 2018-10-26 12:55:20 -07:00
Luke Bakken d2452b6cc4 Tokenize NetBIOS logins on the backslash character
Fixes #98

This allows `Domain\User` to be used in templates via `${ad_domain}` and `{$ad_user}`

See the following discussion: https://groups.google.com/d/topic/rabbitmq-users/mK87YcRy4vQ/discussion
2018-10-26 12:41:16 -07:00
Michael Klishin 4888a008cf Accept authentication context in user_login_authorization/2
Part of rabbitmq/rabbitmq-server#1633.

[#158805410]
2018-07-03 23:30:23 +03:00