Skip to content

Commit

Permalink
Update golang backend qs to use latest versions (#10338)
Browse files Browse the repository at this point in the history
* Update golang backend qs to use latest versions

* Update golang webapp  qs to use latest versions
  • Loading branch information
ewanharris authored Dec 5, 2023
1 parent 1826236 commit 5dbe1f6
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 32 deletions.
8 changes: 4 additions & 4 deletions articles/quickstart/backend/golang/01-authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ Add a `go.mod` file to list all the dependencies to be used.
module 01-Authorization-RS256
go 1.16
go 1.21
require (
github.com/auth0/go-jwt-middleware/v2 v2.0.0
github.com/joho/godotenv v1.4.0
github.com/auth0/go-jwt-middleware/v2 v2.2.0
github.com/joho/godotenv v1.5.1
)
```

Expand Down Expand Up @@ -77,7 +77,7 @@ import (
"os"
"time"

"github.com/auth0/go-jwt-middleware/v2"
jwtmiddleware "github.com/auth0/go-jwt-middleware/v2"
"github.com/auth0/go-jwt-middleware/v2/jwks"
"github.com/auth0/go-jwt-middleware/v2/validator"
)
Expand Down
17 changes: 9 additions & 8 deletions articles/quickstart/backend/golang/files/jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
"net/http"
"net/url"
"os"
"strings"
"time"

"github.com/auth0/go-jwt-middleware/v2"
jwtmiddleware "github.com/auth0/go-jwt-middleware/v2"
"github.com/auth0/go-jwt-middleware/v2/jwks"
"github.com/auth0/go-jwt-middleware/v2/validator"
)
Expand Down Expand Up @@ -77,13 +78,13 @@ func EnsureValidToken() func(next http.Handler) http.Handler {

// HasScope checks whether our claims have a specific scope.
func (c CustomClaims) HasScope(expectedScope string) bool {
result := strings.Split(c.Scope, " ")
for i := range result {
if result[i] == expectedScope {
return true
}
}
result := strings.Split(c.Scope, " ")
for i := range result {
if result[i] == expectedScope {
return true
}
}

return false
return false
}
```
10 changes: 7 additions & 3 deletions articles/quickstart/backend/golang/files/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ language: go
package main

import (
"01-Authorization-RS256/middleware"
"log"
"net/http"

jwtmiddleware "github.com/auth0/go-jwt-middleware/v2"
"github.com/auth0/go-jwt-middleware/v2/validator"
"github.com/joho/godotenv"
"01-Authorization-RS256/middleware"
)

func main() {
Expand All @@ -37,9 +40,9 @@ func main() {
w.Write([]byte(`{"message":"Hello from a private endpoint! You need to be authenticated to see this."}`))
}),
))

// This route is only accessible if the user has a
// valid access_token with the read:messages scope.
// valid access_token with the read:messages scope.
router.Handle("/api/private-scoped", middleware.EnsureValidToken()(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
Expand All @@ -63,4 +66,5 @@ func main() {
log.Fatalf("There was an error with the http server: %v", err)
}
}

```
2 changes: 1 addition & 1 deletion articles/quickstart/backend/golang/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sdk:
url: https://github.com/auth0/go-jwt-middleware
logo: golang
requirements:
- Go 1.15+
- Go 1.21+
next_steps:
- path: 01-authorization
list:
Expand Down
6 changes: 3 additions & 3 deletions articles/quickstart/backend/golang/interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Add a `go.mod` file to list all the necessary dependencies.
module 01-Authorization-RS256
go 1.16
go 1.21
require (
github.com/auth0/go-jwt-middleware/v2 v2.0.0
github.com/joho/godotenv v1.4.0
github.com/auth0/go-jwt-middleware/v2 v2.2.0
github.com/joho/godotenv v1.5.1
)
```

Expand Down
12 changes: 6 additions & 6 deletions articles/quickstart/webapp/golang/01-login.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Start by adding a `go.mod` file to list all the dependencies to be used.
module 01-Login
go 1.16
go 1.21
require (
github.com/coreos/go-oidc/v3 v3.1.0
github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.7.4
github.com/joho/godotenv v1.4.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
github.com/coreos/go-oidc/v3 v3.8.0
github.com/gin-contrib/sessions v0.0.5
github.com/gin-gonic/gin v1.9.1
github.com/joho/godotenv v1.5.1
golang.org/x/oauth2 v0.15.0
)
```

Expand Down
12 changes: 6 additions & 6 deletions articles/quickstart/webapp/golang/files/go-mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ language: go-mod
module 01-Login
go 1.16
go 1.21
require (
github.com/coreos/go-oidc/v3 v3.1.0
github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.7.4
github.com/joho/godotenv v1.4.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
github.com/coreos/go-oidc/v3 v3.8.0
github.com/gin-contrib/sessions v0.0.5
github.com/gin-gonic/gin v1.9.1
github.com/joho/godotenv v1.5.1
golang.org/x/oauth2 v0.15.0
)
```
2 changes: 1 addition & 1 deletion articles/quickstart/webapp/golang/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ github:
repo: auth0-golang-web-app
branch: master
requirements:
- Go 1.16+
- Go 1.21+
next_steps:
- path: 01-login
list:
Expand Down

0 comments on commit 5dbe1f6

Please sign in to comment.