From 0bfb35520d7e138e6219e550187e0b55bc8a29ac Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 28 Nov 2022 14:29:12 +0100 Subject: Formatting: Run gofumpt -w --- internal/oauth/oauth.go | 33 +++++++++++++++++---------------- internal/oauth/token.go | 13 ++++++------- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'internal/oauth') diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 3c1e5d6..6abdb7f 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -57,11 +57,13 @@ func genChallengeS256(verifier string) string { // minimum length of 43 characters and a maximum length of 128 // characters. // We implement it according to the note: -// NOTE: The code verifier SHOULD have enough entropy to make it -// impractical to guess the value. It is RECOMMENDED that the output of -// a suitable random number generator be used to create a 32-octet -// sequence. The octet sequence is then base64url-encoded to produce a -// 43-octet URL safe string to use as the code verifier. +// +// NOTE: The code verifier SHOULD have enough entropy to make it +// impractical to guess the value. It is RECOMMENDED that the output of +// a suitable random number generator be used to create a 32-octet +// sequence. The octet sequence is then base64url-encoded to produce a +// 43-octet URL safe string to use as the code verifier. +// // See: https://datatracker.ietf.org/doc/html/rfc7636#section-4.1 func genVerifier() (string, error) { randomBytes, err := util.MakeRandomByteSlice(32) @@ -78,19 +80,19 @@ func genVerifier() (string, error) { // OAuth defines the main structure for this package. type OAuth struct { // ISS indicates the issuer indentifier of the authorization server as defined in RFC 9207 - ISS string `json:"iss"` + ISS string `json:"iss"` // BaseAuthorizationURL is the URL where authorization should take place - BaseAuthorizationURL string `json:"base_authorization_url"` + BaseAuthorizationURL string `json:"base_authorization_url"` // TokenURL is the URL where tokens should be obtained - TokenURL string `json:"token_url"` + TokenURL string `json:"token_url"` // session is the internal in progress OAuth session - session ExchangeSession `json:"-"` + session ExchangeSession `json:"-"` // Token is where the access and refresh tokens are stored along with the timestamps - token Token `json:"-"` + token Token `json:"-"` } // ExchangeSession is a structure that gets passed to the callback for easy access to the current state. @@ -102,19 +104,19 @@ type ExchangeSession struct { ClientID string // ISS indicates the issuer inditifer - ISS string + ISS string // State is the expected URL state paremeter - State string + State string // Verifier is the preimage of the challenge Verifier string // Context is the context used for cancellation - Context context.Context + Context context.Context // Server is the server of the session - Server *http.Server + Server *http.Server // Listener is the listener where the servers 'listens' on Listener net.Listener @@ -332,7 +334,7 @@ main { // oauthResponseHTML is a structure that is used to give back the OAuth response. type oauthResponseHTML struct { - Title string + Title string Message string } @@ -385,7 +387,6 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) { ) return } - } // Make sure the state is present and matches to protect against cross-site request forgeries diff --git a/internal/oauth/token.go b/internal/oauth/token.go index eb79357..bd17647 100644 --- a/internal/oauth/token.go +++ b/internal/oauth/token.go @@ -5,26 +5,25 @@ import "time" // TokenResponse defines the OAuth response from the server that includes the tokens. type TokenResponse struct { // Access is the access token returned by the server - Access string `json:"access_token"` + Access string `json:"access_token"` // Refresh token is the refresh token returned by the server - Refresh string `json:"refresh_token"` + Refresh string `json:"refresh_token"` // Type indicates which type of tokens we have - Type string `json:"token_type"` + Type string `json:"token_type"` // Expires is the expires time returned by the server - Expires int64 `json:"expires_in"` - + Expires int64 `json:"expires_in"` } // Token is a structure that contains our access and refresh tokens and a timestamp when they expire. type Token struct { // Access is the access token returned by the server - access string + access string // Refresh token is the refresh token returned by the server - refresh string + refresh string // ExpiredTimestamp is the Expires field but converted to a Go timestamp expiredTimestamp time.Time -- cgit v1.2.3