Skip to content

Commit

Permalink
fill in sid and sc
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptix committed Mar 24, 2021
1 parent 82f2b51 commit 0ce0f6b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion muxrpc/handlers/signinwithssb/withssb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
refs "go.mindeco.de/ssb-refs"
)

// Handler implements the muxrpc methods for alias registration and recvocation
// Handler implements the muxrpc methods for the "Sign-in with SSB" calls. SendSolution and InvalidateAllSolutions.
type Handler struct {
logger kitlog.Logger
self refs.FeedRef
Expand Down
11 changes: 5 additions & 6 deletions web/handlers/auth/withssb.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ func (h WithSSBHandler) login(w http.ResponseWriter, req *http.Request) (interfa

// validate and update client challenge
cc := queryParams.Get("cc")
if _, err := signinwithssb.DecodeChallengeString(cc); err != nil {
return nil, weberrors.ErrBadRequest{Where: "client-challenge", Details: err}
}
clientReq.ClientChallenge = cc

// check who the client is
Expand Down Expand Up @@ -278,24 +275,26 @@ func (h WithSSBHandler) startWithServer(w http.ResponseWriter, req *http.Request

var queryParams = make(url.Values)
queryParams.Set("action", "start-http-auth")
queryParams.Set("sid", h.roomID.Ref())
queryParams.Set("sc", sc)

var startAuthURI url.URL
startAuthURI.Scheme = "ssb"
startAuthURI.Opaque = "experimental"
startAuthURI.RawQuery = queryParams.Encode()

qrCode, err := qrcode.New(startAuthURI.String(), qrcode.High)
// generate a QR code with the token inside so that you can open it easily in a supporting mobile app
qrCode, err := qrcode.New(startAuthURI.String(), qrcode.Medium)
if err != nil {
return nil, err
}
qrCode.BackgroundColor = color.RGBA{R: 0xf9, G: 0xfa, B: 0xfb}
qrCode.ForegroundColor = color.Black

qrCodeData, err := qrCode.PNG(-8)
qrCodeData, err := qrCode.PNG(-5)
if err != nil {
return nil, err
}

qrURI := "data:image/png;base64," + base64.StdEncoding.EncodeToString(qrCodeData)

return struct {
Expand Down
3 changes: 2 additions & 1 deletion web/i18n/defaults/active.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GenericSave = "Save"
GenericCreate = "Create"
GenericPreview = "Preview"
GenericLanguage = "Language"
GenericOpenLink = "Open Link"

PageNotFound = "The requested page was not found."

Expand All @@ -20,7 +21,7 @@ AuthSignIn = "Sign in"
AuthSignOut = "Sign out"

AuthWithSSBTitle = "Sign-in with SSB"
AuthWithSSBWelcome = "If you have a compatible device/application, you can sign-in here without a password."
AuthWithSSBWelcome = "If you have a compatible device/application, you can sign-in here without a password. Open the QR-Code on your mobile device to complete the process or click the link below."

AdminDashboardWelcome = "Welcome to your dashboard"
AdminDashboardTitle = "Room Admin Dashboard"
Expand Down
5 changes: 2 additions & 3 deletions web/templates/auth/withssb_server_start.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
<h1 id="welcome" class="text-lg">{{i18n "AuthWithSSBWelcome"}}</h1>
</div>
<div>
<h3>TODO: qr code of the code</h3>
<img src="{{.QRCodeURI}}" alt="QR-Code to pass challange to an App" />
<pre>{{.SSBURI}}</pre>
<img src="{{.QRCodeURI}}" alt="QR-Code to pass the challange to an App" />
<a href="{{.SSBURI}}">{{i18n "GenericOpenLink"}}</a>

<h3>Server events</h3>
<p id="ping"></p>
Expand Down

0 comments on commit 0ce0f6b

Please sign in to comment.