-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/add_transitional_support'
- Loading branch information
Showing
18 changed files
with
564 additions
and
80 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
module github.com/ONSdigital/dp-authorisation | ||
|
||
go 1.13 | ||
go 1.17 | ||
|
||
require ( | ||
github.com/ONSdigital/dp-api-clients-go v1.34.3 | ||
github.com/ONSdigital/dp-api-clients-go v1.43.0 | ||
github.com/ONSdigital/dp-rchttp v1.0.0 | ||
github.com/ONSdigital/go-ns v0.0.0-20200205115900-a11716f93bad // indirect | ||
github.com/ONSdigital/log.go/v2 v2.0.5 | ||
github.com/ONSdigital/log.go/v2 v2.0.9 | ||
github.com/gorilla/mux v1.8.0 | ||
github.com/smartystreets/goconvey v1.6.4 | ||
) | ||
|
||
require ( | ||
github.com/ONSdigital/go-ns v0.0.0-20210916104633-ac1c1c52327e // indirect | ||
github.com/fatih/color v1.13.0 // indirect | ||
github.com/gopherjs/gopherjs v0.0.0-20210202160940-bed99a852dfe // indirect | ||
github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect | ||
github.com/jtolds/gls v4.20.0+incompatible // indirect | ||
github.com/mattn/go-colorable v0.1.12 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
github.com/smartystreets/assertions v1.2.0 // indirect | ||
golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b // indirect | ||
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test: | ||
go test -race -cover ./... | ||
.PHONY: test | ||
|
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 |
---|---|---|
|
@@ -70,6 +70,25 @@ A mock for the `Middleware` interface is available for unit testing: | |
} | ||
``` | ||
|
||
##### Creating a mock ZebedeeClient instance for unit testing | ||
|
||
A mock for the `ZebedeeClient` interface is available for unit testing: | ||
```go | ||
import ( | ||
authorisation "github.com/ONSdigital/dp-authorisation/v2/authorisation/mock" | ||
) | ||
|
||
... | ||
|
||
zebedeeIdentity = &mock.ZebedeeClientMock{ | ||
CheckTokenIdentityFunc: func(ctx context.Context, token string) (*dprequest.IdentityResponse, error) { | ||
return &dprequest.IdentityResponse{ | ||
Identifier: "[email protected]", | ||
}, nil | ||
}, | ||
} | ||
``` | ||
|
||
#### Option 2 - Add authorisation within a handler (not via middleware) | ||
|
||
If the authorisation for a service requires something more complex than middleware around a handler, the implementation will depend on the services particular requirements. Though it will still come down to the two fundamental pieces of the authorisation - JWT token parsing, and permissions checking. Refer to the readme's for the [JWT parser](jwt/README.md) and [permissions checker](permissions/README.md) for more information on creating and using them. | ||
|
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
Oops, something went wrong.