-
Notifications
You must be signed in to change notification settings - Fork 107
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
Flow API: Custom resume endpoint, polished mirror status endpoint, auth to all endpoints #1711
Conversation
28edd92
to
3424dca
Compare
dcc8e69
to
85da32c
Compare
Description updated with new status endpoint |
a205f79
to
67a3022
Compare
Updated description and functionally tested post changes |
testing on my cloud setup, drop mirror not working |
flow/middleware/interceptors.go
Outdated
// accommodate live password changes and reduce time hash is in memory | ||
hashCache := expirable.NewLRU[string, []byte](1, nil, 10*time.Minute) | ||
_, err := getCachedHash(hashCache) | ||
if err != nil { | ||
return nil, fmt.Errorf("error generating hash: %w", err) | ||
} | ||
|
||
return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { | ||
if _, ok := unauthenticatedMethodsSet[info.FullMethod]; ok { | ||
return handler(ctx, req) | ||
} | ||
ctx, err := Authorize(ctx, plaintext) | ||
ctx, err := authorize(ctx, hashCache) | ||
if err != nil { |
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.
Why do we need to look at live password changes?
Why not send the hash directly?
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.
Can you check dropmirror flow once @heavycrystal ? @serprex said that it was not working
flow/middleware/auth.go
Outdated
} | ||
|
||
if err := bcrypt.CompareHashAndPassword(hash, tokenBytes); err != nil { | ||
logger.LoggerFromCtx(ctx).Warn("Error validating token", slog.String("token", string(tokenBytes)), slog.Any("error", err)) |
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.
remove token from logging now since it is plaintext now.
Closing, this is replaced by #1823 |
Endpoints:
Custom sync:
Status:
Authentication
Flow API now has authentication on all routes (except for health). It uses Bearer Authentication with token being:
base64Encode(bcryptHash(PEERDB_PASSWORD))
It can be generated on Unix based systems via:
htpasswd -nbB -C 10 "" <PEERDB_PASSWORD_HERE> | tr -d ":" | base64
API Endpoint to Resume Mirror With Specified Syncs
This PR introduces an endpoint in our Flow API to resume mirrors with a request of custom number of syncs.
MaxSyncsPerCDCFlow
which is currently 32.Implementation:
Extends
CDCFlowConfigUpdate
to include number of syncs information.Functional testing:
Mirror Status Endpoint
Existing mirror status endpoint now has a flag in the request to include flow information. The UI sets this flag. If not set, response only contains flow name and running status, along with clean error messages.
This endpoint is also gated by authorization
Functionally tested