Skip to content

Commit

Permalink
more edits to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bnonni committed Oct 11, 2023
1 parent d2befdc commit de420a9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
34 changes: 33 additions & 1 deletion doc/config/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,37 @@ curl -H "Authorization: Bearer $TOKEN" ....

# Extending Authentication and Authorization for production environments

The server uses the [Gin framework](https://github.com/gin-gonic/gin), which allows various kinds of middleware. Look in `pkg/server/middleware/authn.go` and `pkg/server/server.go` for details on how you can wire up authentication and authorization for your use case. One such option is the https://github.com/zalando/gin-oauth2 framework.
The server uses the [Gin framework](https://github.com/gin-gonic/gin), which allows various kinds of middleware. Look in [`pkg/server/middleware/authn.go`](../../pkg/server/middleware/authn.go) and [`pkg/server/server.go`](../../pkg/server/server.go) for details on how you can wire up authentication and authorization for your use case. One such option is the https://github.com/zalando/gin-oauth2 framework.

## How to add Authentication to the SSI Service
1. Open [`pkg/server/middleware/authn.go`](../../pkg/server/middleware/authn.go) for a reference to where to add the proper code
```go
func setUpEngine(cfg config.ServerConfig, shutdown chan os.Signal) *gin.Engine {
gin.ForceConsoleColor()
middlewares := gin.HandlersChain{
gin.Recovery(),
gin.Logger(),
middleware.Errors(shutdown),
middleware.AuthMiddleware(),
}
}
```

2. Open [`pkg/server/server.go`](../../pkg/server/server.go) and uncomment line 126
```go
// uncomment the below line to enable middle ware auth, see doc/config/auth.md for details
middleware.AuthMiddleware()
```

3. Reference the [Authentication](#authentication) section for how to create an `AUTH_TOKEN`

4. Update `.env` with the hash produced in step 3
```conf
AUTH_TOKEN="8e455e42e94a0f3ac17fe27e9c6a8475800d02c123ba9d2dc0cf1063ef52bd90"
```

5. Build and run the server. When making API calls, pass the preimage (unhashed data) in the header
```bash
export TOKEN=hunter2
curl -H "Authorization: Bearer $TOKEN"
```
3 changes: 2 additions & 1 deletion doc/config/kms.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ For production deployments, using external KMS is strongly recommended.
To use an external KMS:

1. Create a symmetric encryption key in your KMS. You MUST select the algorithm that uses AES-256 block cipher in
Galois/Counter Mode (GCM). At the time of writing, this is the only algorithm supported by AWS and GCP.
Galois/Counter Mode (GCM). At the time of writing, this is the only algorithm supported by AWS and GCP for symmetric encrypt/decrypt.
In GCP, the algorithm will be called "Google symmetric key." It will be preselected and grayed out.
2. Set the `master_key_uri` field of the `[services.keystore]` section using the format described
in [tink](https://github.com/google/tink/blob/9bc2667963e20eb42611b7581e570f0dddf65a2b/docs/KEY-MANAGEMENT.md#key-management-systems)
(we use the tink library under the hood).
Expand Down
3 changes: 1 addition & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ func setUpEngine(cfg config.ServerConfig, shutdown chan os.Signal) *gin.Engine {
gin.Recovery(),
gin.Logger(),
middleware.Errors(shutdown),
// uncomment the below line to enable middle ware auth
// see doc/config/auth.md for details
// uncomment the below line to enable middle ware auth, see doc/config/auth.md for details
// middleware.AuthMiddleware()
}
if cfg.JagerEnabled {
Expand Down

0 comments on commit de420a9

Please sign in to comment.