Skip to content

Commit

Permalink
Quote using %q
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Jun 6, 2024
1 parent d64f3d4 commit feacbf6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/webserver/authenticators/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"log"
"net/http"
"net/url"
Expand Down Expand Up @@ -199,11 +200,12 @@ func (o *Oidc) AuthorisationAPI(w http.ResponseWriter, r *http.Request) {
}

if issuerDetails.Issuer != rp.Issuer() {
return errors.New("stored issuer " + issuerDetails.Issuer + " did not equal actual issuer: " + rp.Issuer())
return fmt.Errorf("stored issuer %q did not equal actual issuer: %q", issuerDetails.Issuer, rp.Issuer())

}

if deviceUsername != username {
log.Printf("Error logging in user, idP supplied device username (%s) does not equal expected username (%s)", deviceUsername, username)
log.Printf("Error logging in user, idP supplied device username (%q) does not equal expected username (%q)", deviceUsername, username)
return errors.New("user is not associated with device")
}

Expand All @@ -215,7 +217,7 @@ func (o *Oidc) AuthorisationAPI(w http.ResponseWriter, r *http.Request) {

msg, _ := resultMessage(err)
if strings.Contains(err.Error(), "returned username") {
msg = "username '" + info.GetPreferredUsername() + "' not associated with device, device owned by '" + user.Username + "'"
msg = fmt.Sprintf("username %q not associated with device, device owned by %q", info.GetPreferredUsername(), user.Username)
}

w.WriteHeader(http.StatusUnauthorized)
Expand Down

0 comments on commit feacbf6

Please sign in to comment.