This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
feat(security): add ReplicaSession interceptor #135
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
adab598
init jaas
levy5307 ce20285
fix
levy5307 48e3d75
fix
levy5307 c5cc59a
fix
levy5307 b8367e9
fix
levy5307 4f6cf3e
fix
levy5307 baa0fc1
fix
levy5307 9e4ddac
fix
levy5307 67b2631
fix
levy5307 edc0a10
fix
levy5307 6294add
fix
levy5307 55e8eab
fix
levy5307 260e381
add config comments
levy5307 e69d2b7
ReplicaSessionHook -> ReplicaSessionInterceptor
levy5307 b19e5aa
fix
levy5307 08abb63
fix
levy5307 de6b5c7
fix
levy5307 78017a3
fix by review
levy5307 27fab2b
fix
levy5307 43fa5f2
don't let ReplicationSessionInterceptorManager be a singleton
levy5307 36a8016
remove of jaas
levy5307 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.xiaomi.infra.pegasus.rpc.interceptor; | ||
|
||
import com.xiaomi.infra.pegasus.rpc.async.ReplicaSession; | ||
|
||
public interface ReplicaSessionInterceptor { | ||
// The behavior when a rpc session is connected. | ||
void onConnected(ReplicaSession session); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptorManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.xiaomi.infra.pegasus.rpc.interceptor; | ||
|
||
import com.xiaomi.infra.pegasus.client.ClientOptions; | ||
import com.xiaomi.infra.pegasus.rpc.async.ReplicaSession; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ReplicaSessionInterceptorManager { | ||
private List<ReplicaSessionInterceptor> interceptors = new ArrayList<>(); | ||
|
||
public ReplicaSessionInterceptorManager(ClientOptions options) { | ||
if (options.isEnableAuth()) { | ||
ReplicaSessionInterceptor securityInterceptor = | ||
new SecurityReplicaSessionInterceptor(options.getServiceName(), options.getServiceFQDN()); | ||
interceptors.add(securityInterceptor); | ||
} | ||
} | ||
|
||
public void onConnected(ReplicaSession session) { | ||
for (ReplicaSessionInterceptor interceptor : interceptors) { | ||
interceptor.onConnected(session); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You can pass ClientOptions here. Each ReplicaSession creates its ReplicaSessionInterceptorManager separately.
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.
I don't think we should create a
ReplicaSessionInterceptorManager
for eachReplicationSession
. Each ClusterManager has aReplicaSessionInterceptorManager
is enough