Skip to content

Commit

Permalink
remove JwtAuthAPI (#4837)
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode authored Mar 22, 2022
1 parent 89c6d12 commit 5ceac1c
Show file tree
Hide file tree
Showing 13 changed files with 2 additions and 226 deletions.
21 changes: 0 additions & 21 deletions pkg/jwtauth/local_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,3 @@ func (jwtAuth *JwtAuth) Verify(ctx context.Context, token string) ([]auth.Permis
}
return payload.Allow, nil
}

type JwtAuthAPI struct { // nolint
JwtAuth *JwtAuth
}

// Verify check the token is valid or not
func (a *JwtAuthAPI) Verify(ctx context.Context, token string) ([]auth.Permission, error) {
var payload JwtPayload
if _, err := jwt3.Verify([]byte(token), (*jwt3.HMACSHA)(a.JwtAuth.apiSecret), &payload); err != nil {
return nil, xerrors.Errorf("JWT Verification failed: %v", err)
}
return payload.Allow, nil
}

// AuthNew create new token with specify permission for access venus
func (a *JwtAuthAPI) AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error) {
p := JwtPayload{
Allow: perms, // TODO: consider checking validity
}
return jwt3.Sign(&p, (*jwt3.HMACSHA)(a.JwtAuth.apiSecret))
}
1 change: 0 additions & 1 deletion venus-shared/api/chain/v0/fullnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ type FullNode interface {
IPaychan
ISyncer
IWallet
IJwtAuthAPI
}
12 changes: 0 additions & 12 deletions venus-shared/api/chain/v0/jwtauth.go

This file was deleted.

41 changes: 0 additions & 41 deletions venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
* [StateWaitMsg](#StateWaitMsg)
* [StateWaitMsgLimited](#StateWaitMsgLimited)
* [VerifyEntry](#VerifyEntry)
* [JwtAuth](#JwtAuth)
* [AuthNew](#AuthNew)
* [Verify](#Verify)
* [Market](#Market)
* [StateMarketParticipants](#StateMarketParticipants)
* [MessagePool](#MessagePool)
Expand Down Expand Up @@ -1528,44 +1525,6 @@ Inputs:

Response: `true`

## JwtAuth

### AuthNew


Perms: admin

Inputs:
```json
[
[
"string value"
]
]
```

Response: `"Ynl0ZSBhcnJheQ=="`

### Verify


Perms: read

Inputs:
```json
[
"string value",
"string value"
]
```

Response:
```json
[
"string value"
]
```

## Market

### StateMarketParticipants
Expand Down
30 changes: 0 additions & 30 deletions venus-shared/api/chain/v0/mock/mock_fullnode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions venus-shared/api/chain/v0/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion venus-shared/api/chain/v1/fullnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ type FullNode interface {
IPaychan
ISyncer
IWallet
IJwtAuthAPI
}
12 changes: 0 additions & 12 deletions venus-shared/api/chain/v1/jwtauth.go

This file was deleted.

41 changes: 0 additions & 41 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
* [StateVerifierStatus](#StateVerifierStatus)
* [StateWaitMsg](#StateWaitMsg)
* [VerifyEntry](#VerifyEntry)
* [JwtAuth](#JwtAuth)
* [AuthNew](#AuthNew)
* [Verify](#Verify)
* [Market](#Market)
* [StateMarketParticipants](#StateMarketParticipants)
* [MessagePool](#MessagePool)
Expand Down Expand Up @@ -1544,44 +1541,6 @@ Inputs:

Response: `true`

## JwtAuth

### AuthNew


Perms: admin

Inputs:
```json
[
[
"string value"
]
]
```

Response: `"Ynl0ZSBhcnJheQ=="`

### Verify


Perms: read

Inputs:
```json
[
"string value",
"string value"
]
```

Response:
```json
[
"string value"
]
```

## Market

### StateMarketParticipants
Expand Down
30 changes: 0 additions & 30 deletions venus-shared/api/chain/v1/mock/mock_fullnode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions venus-shared/api/chain/v1/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions venus-shared/compatible-checks/api-diff.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.com/filecoin-project/lotus/api/v0api.FullNode:
- AuthNew
- AuthVerify
+ BlockTime
> ChainExport {[func(context.Context, abi.ChainEpoch, bool, types.TipSetKey) (<-chan []uint8, error) <> func(context.Context, abi.ChainEpoch, bool, types.TipSetKey) (<-chan []uint8, error)] base=func in type: #3 input; nested={[types.TipSetKey <> types.TipSetKey] base=codec marshaler implementations for codec Cbor: true != false; nested=nil}}
Expand Down Expand Up @@ -176,7 +177,6 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c
- SyncValidateTipset
+ SyncerTracker
+ UnLockWallet
+ Verify
+ VerifyEntry
> Version {[func(context.Context) (types.Version, error) <> func(context.Context) (api.APIVersion, error)] base=func out type: #0 input; nested={[types.Version <> api.APIVersion] base=struct field; nested={[types.Version <> api.APIVersion] base=exported fields count: 2 != 3; nested=nil}}}
+ WalletAddresses
Expand All @@ -191,6 +191,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c
- WalletVerify

github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.com/filecoin-project/lotus/api.FullNode:
- AuthNew
- AuthVerify
+ BlockTime
- ChainBlockstoreInfo
Expand Down Expand Up @@ -369,7 +370,6 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c
- SyncValidateTipset
+ SyncerTracker
+ UnLockWallet
+ Verify
+ VerifyEntry
> Version {[func(context.Context) (types.Version, error) <> func(context.Context) (api.APIVersion, error)] base=func out type: #0 input; nested={[types.Version <> api.APIVersion] base=struct field; nested={[types.Version <> api.APIVersion] base=exported fields count: 2 != 3; nested=nil}}}
+ WalletAddresses
Expand Down
3 changes: 0 additions & 3 deletions venus-shared/compatible-checks/api-perm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ v0: github.com/filecoin-project/venus/venus-shared/api/chain/v0 <> github.com/fi
- IChainInfo.VerifyEntry
- IMinerState.StateMinerSectorSize
- IMinerState.StateMinerWorkerAddress
- IJwtAuthAPI.AuthNew
- IJwtAuthAPI.Verify
- IMessagePool.GasBatchEstimateMessageGas
- IMessagePool.MpoolDeleteByAdress
- IMessagePool.MpoolPublishByAddr
Expand Down Expand Up @@ -60,7 +58,6 @@ v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/fi
- IChainInfo.VerifyEntry
- IMinerState.StateMinerSectorSize
- IMinerState.StateMinerWorkerAddress
- IJwtAuthAPI.Verify
- IMessagePool.GasBatchEstimateMessageGas
- IMessagePool.MpoolDeleteByAdress
- IMessagePool.MpoolPublishByAddr
Expand Down

0 comments on commit 5ceac1c

Please sign in to comment.