Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 27f62b0

Browse files
committed
Fix examples
1 parent ee2804d commit 27f62b0

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

ql/src/experimental/CWE-352/ConstantOauth2StateBad.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package main
22

33
import (
4-
"fmt"
5-
64
"golang.org/x/oauth2"
75
)
86

@@ -21,7 +19,6 @@ func badWithStringLiteralState() {
2119
},
2220
}
2321

24-
url := conf.AuthCodeURL(stateStringVar, oauth2.AccessTypeOffline)
25-
fmt.Printf("Visit the URL for the auth dialog: %v", url)
22+
url := conf.AuthCodeURL(stateStringVar)
2623
// ...
2724
}

ql/src/experimental/CWE-352/ConstantOauth2StateBetter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ func betterWithVariableStateReturned(w http.ResponseWriter) {
2727
func generateStateOauthCookie(w http.ResponseWriter) string {
2828
b := make([]byte, 128)
2929
rand.Read(b)
30-
// TODO: save the state string to cookies or HTML storage.
30+
// TODO: save the state string to cookies or HTML storage,
31+
// and bind it to the authenticated status of the user.
3132
state := base64.URLEncoding.EncodeToString(b)
3233

3334
return state

0 commit comments

Comments
 (0)