1
0
mirror of https://github.com/go-micro/go-micro.git synced 2026-04-30 19:15:24 +02:00
Commit Graph

245 Commits

Author SHA1 Message Date
asim a38d7df106 go fmt 2026-02-04 14:37:40 +00:00
Copilot 50ce1a5e83 TLS certificate verification: opt-in security to preserve backward compatibility (#2843)
* Initial plan

* Fix insecure TLS configuration - make secure by default

- Changed util/tls/Config() to be secure by default (InsecureSkipVerify=false)
- Added MICRO_TLS_INSECURE=true environment variable for development/testing
- Updated documentation to emphasize security-first approach
- Added comprehensive tests for TLS configuration
- All existing broker tests pass

Co-authored-by: asim <17530+asim@users.noreply.github.com>

* Revert to backward-compatible TLS defaults to avoid breaking changes

- Reverted default to InsecureSkipVerify=true for backward compatibility
- Changed environment variable to MICRO_TLS_SECURE=true (opt-in security)
- Added deprecation warning that logs once per process
- Updated tests to reflect backward-compatible behavior
- Added comprehensive migration guide
- No breaking changes - production systems safe to upgrade
- Security improvement is opt-in via environment variable
- Planned breaking change for v6 with proper major version bump

Co-authored-by: asim <17530+asim@users.noreply.github.com>

* Add TLS security update documentation

Co-authored-by: asim <17530+asim@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: asim <17530+asim@users.noreply.github.com>
2026-02-03 15:53:03 +00:00
Asim Aslam cae6fbbe76 Framework hardening: security, reliability, and developer experience improvements (#2826)
* fix: remove deprecated rand.Seed calls

Go 1.20+ automatically seeds the global random number generator.
These calls are no-ops and generate warnings with newer Go versions.

Removed from:
- selector/strategy.go
- registry/cache/cache.go
- broker/memory.go
- broker/http.go
- cmd/cmd.go
- transport/memory.go

Co-authored-by: Shelley <shelley@exe.dev>

* fix: handle previously ignored errors

- MySQL store: properly handle prepared statement errors in initDB()
- Consul registry: handle client creation errors in Client() method

These silent failures could cause hard-to-debug issues in production.

Co-authored-by: Shelley <shelley@exe.dev>

* feat(genai): improve provider interface with context and streaming

Breaking changes:
- Generate() and Stream() now require context.Context as first parameter
- Stream.Close() added for proper resource cleanup

Improvements:
- Proper context support for cancellation and timeouts
- Real SSE streaming for OpenAI and Gemini text generation
- Better error handling with wrapped errors and API error responses
- Thread-safe provider registry with sync.RWMutex
- New options: WithMaxTokens, WithTemperature, WithTimeout
- Stream has proper Close() method for cleanup
- Results can include Error field for per-chunk errors

Provider updates:
- OpenAI: true streaming with SSE parsing, proper HTTP client with timeout
- Gemini: true streaming with streamGenerateContent endpoint
- Default model updated to gpt-4o-mini (OpenAI) and gemini-2.0-flash (Gemini)

Co-authored-by: Shelley <shelley@exe.dev>

* feat(tls): make TLS secure by default, configurable via environment

BREAKING: TLS now verifies certificates by default. Set MICRO_TLS_INSECURE=true
to restore previous behavior (NOT recommended for production).

Changes:
- Add util/tls.Config(), SecureConfig(), InsecureConfig(), ConfigFromEnv() helpers
- Update all components to use ConfigFromEnv() instead of hardcoded InsecureSkipVerify
- Set MinVersion to TLS 1.2 for all TLS configs

Affected components:
- broker/http
- broker/rabbitmq
- registry/etcd
- registry/consul
- transport/grpc

This improves security posture while allowing opt-out for development environments.

Co-authored-by: Shelley <shelley@exe.dev>

* feat(tls): add TLS helpers with opt-in secure mode

NOT a breaking change - keeps InsecureSkipVerify=true as default for
local development compatibility.

New util/tls helpers:
- Config() - returns config based on MICRO_TLS_SECURE env var
- SecureConfig() - certificate verification enabled
- InsecureConfig() - certificate verification disabled (dev only)

For production security, use one of:
- Set MICRO_TLS_SECURE=true with proper CA-signed certs
- Use a service mesh (Istio, Linkerd) for automatic mTLS
- Configure TLSConfig directly with your certificates

Also: Changed CLI alias from 'g' to 'gen' for clarity
- micro generate handler -> micro gen handler

Co-authored-by: Shelley <shelley@exe.dev>

* refactor(cli): rename generate directory to gen for consistency

Directory name now matches the command alias:
  cmd/micro/cli/gen/ -> micro gen handler

Co-authored-by: Shelley <shelley@exe.dev>

---------

Co-authored-by: Shelley <shelley@exe.dev>
2026-01-27 10:39:25 +00:00
Ak-Army 0433e98dbc Better connection pool handling (#2725)
* [fix] etcd config source prefix issue (#2389)

* http transport data race issue (#2436)

* [fix] #2431 http transport data race issue

* [feature] Ability to close connection while receiving.
Ability to send messages while receiving.
Icreased r channel limit to 100 to more fluently communication.
Do not dropp sent request if r channel is full.

* [fix] Use pool connection close timeout

* [fix] replace Close with private function

* [fix] Do not close the transport client twice in stream connection , the transport client is closed in the rpc codec

* [fix] tests

---------

Co-authored-by: Johnson C <chengqiaosheng@gmail.com>
2024-07-23 12:19:43 +01:00
asim dd0145fa18 unused packages 2024-07-08 18:48:52 +01:00
asim 72df27b7d1 remove util/sync 2024-07-08 18:46:34 +01:00
asim e9a52070e6 k8s not needed 2024-07-08 18:44:42 +01:00
asim 6e393f6abf move cmd package back to top level. Strip grpc plugin 2024-07-07 22:38:11 +01:00
asim 3d5f87c01b no one is using that 2024-07-07 18:40:15 +01:00
asim bac34aaec1 still more fixes 2024-07-07 18:36:04 +01:00
asim db0fa9fe1f fix bugs 2024-07-07 18:32:26 +01:00
asim 3676232df1 strip runtime 2024-07-07 18:30:48 +01:00
asim 610c00859f v5 2024-06-04 21:40:43 +01:00
guangwu 252385e39c chore: replace for loop with call to copy (#2678) 2023-11-30 11:18:05 +00:00
Guillaume Bour 674b9822e0 util/addr: Fixes findIP to return public IP if present. (#2673) 2023-11-26 11:06:55 +01:00
mamadeusia 67d48b205e Add Context in event options (#2634)
Co-authored-by: mamadeusia <timadues7775@gmail.com>
2023-05-03 13:24:36 +01:00
Lukasz Raczylo a7522e7d6c fix: struct field alignment (#2632) 2023-04-26 02:16:34 +02:00
David Brouwer a3980c2308 feat: add test framework & refactor RPC server (#2579)
Co-authored-by: Rene Jochum <rene@jochum.dev>
2022-10-20 13:00:50 +02:00
Rene Jochum 010b1d9f11 fix: linting issues (#2566) 2022-09-30 20:32:55 +02:00
David Brouwer 85c0b0b8eb fix: some linting issues (#2563) 2022-09-30 16:27:07 +02:00
Mohamed MHAMDI 1db36357d5 feat(logger): add logger option to all micro components (override DefaultLogger) closes #2556 (#2559)
* feat(logger): add logger option to all components

* fix: refactor api/rpc.go

* fix: refactor api/stream.go

* fix: api/options.go comment

* fix(logger): do not use logger.Helper internally

* fix(logger): fix comments

* fix(logger): use level.Enabled method

* fix: rename mlogger to log

* fix: run go fmt

* fix: log level

* fix: factories

Co-authored-by: Mohamed MHAMDI <mmhamdi@hubside.com>
Co-authored-by: Davincible <david.brouwer.99@gmail.com>
2022-09-29 16:44:53 +02:00
Asim Aslam 6cf2b02f0f move cmd to util (#2527)
* move cmd to util

* go fmt
2022-07-11 14:37:34 +01:00
Asim Aslam 0c2041e439 add events package (#2341)
* add events package

* update go version
2021-11-08 08:52:39 +00:00
Benjamin 5d5aee1f08 replace ioutil with io and os (#2327)
set the go version to 1.16 in pr.yml and tests.yml, so as to be consistent with the version in go.mod.
2021-10-30 19:24:40 +01:00
Asim Aslam 62801c3d68 update 2021-10-13 13:31:23 +01:00
Asim Aslam 1cd7cfaa6c go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
Asim Aslam 12eff1cc60 go fmt 2021-09-24 09:08:39 +01:00
simon 440aa4a1ce Add AuthCall wrapper func (#2250)
* Add grpc,memory,quic transport automatically discover

* Add grpc,memory,quic transport automatically discover

* Add jwt auth automatically discover

* Add jwt auth automatically discover

* Add config command option automatically discover

* Add AuthCall wrapper func
2021-09-07 07:13:56 +01:00
Tt yo 32cb1b435b fix k8s api memory leak (#2166) 2021-05-11 08:58:19 +01:00
Cui Gang 9e9157d878 Fix util/log/log.Infof format didn't work (#2160)
Co-authored-by: Cui Gang <cuigang@yunpbx.com>
2021-05-06 06:43:05 +01:00
Asim Aslam 57003414be remove network package 2021-02-26 08:13:12 +00:00
Shubhendra Singh Chauhan 26b859c4f9 improve code quality (#2128)
* Fix inefficient string comparison

* Fix unnecessary calls to Printf

* Canonicalize header key

* Replace `t.Sub(time.Now())` with `time.Until`

* Remove unnecessary blank (_) identifier

* Remove unnecessary use of slice

* Remove unnecessary comparison with bool
2021-02-25 08:30:35 +00:00
Asim Aslam d94936f6c9 v3 (#2104)
* v3

* revert plugins

* fixup some issues
2021-01-20 13:54:31 +00:00
Asim Aslam eb1e22bd10 strip grpc 2020-12-30 08:21:30 +00:00
Asim Aslam a7c31a0d2b refactor all the things 2020-12-29 15:49:26 +00:00
Asim Aslam 15a62ae0b9 move debug handler 2020-12-12 20:50:36 +00:00
Asim Aslam 4ce77373c0 remove auth cruft 2020-12-12 20:44:32 +00:00
Asim Aslam 8054478cc3 remove util/scope 2020-12-12 20:28:09 +00:00
Asim Aslam 167fcd0d78 fix wrapper test 2020-12-12 20:25:29 +00:00
Asim Aslam df687fe5d4 move selector 2020-12-12 20:14:50 +00:00
Asim Aslam 43ff2a540d move proxy 2020-12-12 19:02:04 +00:00
Asim Aslam 35c59042bf refactor network 2020-12-12 18:59:40 +00:00
Dominic Wong 7be4a67673 MDNS registry fix for users on VPNs (#1759)
* filter out unsolicited responses
* send to local ip in case
* allow ip func to be passed in. add option for sending to 0.0.0.0
2020-07-03 11:30:59 +01:00
Di Wu c28f625cd4 Custom private blocks (#1705)
Co-authored-by: Asim Aslam <asim@aslam.me>
2020-07-03 11:30:59 +01:00
Janos Dobronszki 00b76e0a64 Initialize selector before we make an auth.Generate call (#1693) 2020-06-12 10:42:52 +01:00
ben-toogood 8dfd93e915 util/wrapper: Add Static Client wrapper (#1685)
* util/wrapper: Add Static Client wrapper

* util/wrapper/static: pass address to stream too

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* add static client wrapper tests

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server: fix error message spaces between words

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>

* server/{rpc,grpc}: replace log.Error with log.Errorf

* server/grpc: fix log typo

* server/rpc: fix log typo

Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-06-12 10:42:52 +01:00
mlboy 15d5142d9b fix: misspell (#1667) 2020-05-29 17:49:22 +01:00
Máximo Cuadros 0d88650511 go modules cleanup and remove wrong self import to v1 (#1658)
* Runtime local git, simply go-git code
* go modules cleanup and remove wrong self import to v1
* pin mergo v0.3.8 to avoid panics

Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-05-29 14:32:11 +03:00
Dominic Wong 27e41c4ad5 fix locking of socket pool 2020-05-27 20:18:26 +01:00
Dominic Wong e7ad031eb8 Check ipv4 or ipv6 address is valid before assigning 2020-05-27 15:47:12 +01:00