# TiInf

## Introduction

The example shows how to use the plugin in tiinf to complete the authentication and authorization of the gin service.

### How to use Auth in Gin

Create an account-api-svc-client and add a plugin named `CheckAuthByAuth0`.

Example code:

```
	accountClient := account.NewAccountAPIServiceClient(f.RPCConns().AccountProviderConn)
	f.GinEngine().Use(tigin.CheckAuthByAuth0(accountClient))
```

### How to use RBAC in Gin

Gen an url2resoureMap and url whitelist(optional) firstly, then use plugin named `CheckRBACPermission`.

Example code:

```
	var pathPattern2ResourceMap = map[string]string{
		"get:/orgs/(\\d+)/get_user_info": "orgs/{org_id}/my_user_profile/get",
	}
	var pathWhitelist = []string{"/health_check"}
	f.GinEngine().Use(tigin.CheckRBACPermission(accountClient, pathPattern2ResourceMap, pathWhitelist))
```

More details are [here](https://github.com/tidbcloud/tiinf/blob/gin_examples_with_auth_and_permission/examples/scenario/console_gin_server/main.go#L47)




