diff --git a/web/authorize.qtpl b/web/authorize.qtpl index 594dc54..3a8a3ea 100644 --- a/web/authorize.qtpl +++ b/web/authorize.qtpl @@ -1,121 +1,139 @@ {% import "source.toby3d.me/website/indieauth/internal/domain" %} -{% code type AuthPage struct { +{% code type AuthorizePage struct { BaseOf Client *domain.Client - Me *domain.Me RedirectURI *domain.URL + Me *domain.Me CodeChallengeMethod domain.CodeChallengeMethod ResponseType domain.ResponseType Scope domain.Scopes + CSRF []byte CodeChallenge string - CSRF string State string } %} -{% func (p *AuthPage) Lang() %} - en -{% endfunc %} - -{% func (p *AuthPage) Title() %} - Authorize {%s p.Client.Name[0] %} -{% endfunc %} - -{% func (p *AuthPage) Head() %} -{% endfunc %} - -{% func (p *AuthPage) Body() %} - {% if p.Client.Logo[0] != nil %} - {%s p.Client.Name[0] %} +{% func (p *AuthorizePage) Title() %} + {% if p.Client.GetName() == "" %} + {%= p.T("Authorize %s", p.Client.GetName()) %} + {% else %} + {%= p.T("Authorize application") %} {% endif %} +{% endfunc %} -

{%s p.Client.Name[0] %}

- -
- - {% if p.CSRF != "" %} - +{% func (p *AuthorizePage) Body() %} +
+ {% if p.Client.GetLogo() != nil %} + {%s p.Client.GetName() %} {% endif %} - +

+ {% if p.Client.GetURL() != nil %} + + {% endif %} + {% if p.Client.GetName() != "" %} + {%s p.Client.GetName() %} + {% else %} + {%s p.Client.ID.String() %} + {% endif %} + {% if p.Client.GetURL() != nil %} + + {% endif %} +

+
- +
+ - + {% if p.CSRF != nil %} + + {% endif %} - + {% for key, val := range map[string]string{ + "client_id": p.Client.ID.String(), + "redirect_uri": p.RedirectURI.String(), + "response_type": p.ResponseType.String(), + "state": p.State, + } %} + + {% endfor %} - {% if p.CodeChallenge != "" %} - + {% if len(p.Scope) > 0 %} +
+ {%= p.T("Choose your scopes") %} - - {% endif %} + {% for _, scope := range p.Scope %} +
+ +
+ {% endfor %} +
+ {% endif %} - {% if p.Me != nil %} - - {% endif %} + {% if p.CodeChallenge != "" %} + - + {% if p.Me != nil %} + + {% endif %} - - + {%= p.T("Deny") %} + + + + +
{% endfunc %} \ No newline at end of file diff --git a/web/authorize.qtpl.go b/web/authorize.qtpl.go index 3fd96fc..665cce8 100644 --- a/web/authorize.qtpl.go +++ b/web/authorize.qtpl.go @@ -21,61 +21,46 @@ var ( ) //line web/authorize.qtpl:3 -type AuthPage struct { +type AuthorizePage struct { BaseOf Client *domain.Client - Me *domain.Me RedirectURI *domain.URL + Me *domain.Me CodeChallengeMethod domain.CodeChallengeMethod ResponseType domain.ResponseType Scope domain.Scopes + CSRF []byte CodeChallenge string - CSRF string State string } //line web/authorize.qtpl:16 -func (p *AuthPage) StreamLang(qw422016 *qt422016.Writer) { +func (p *AuthorizePage) StreamTitle(qw422016 *qt422016.Writer) { //line web/authorize.qtpl:16 qw422016.N().S(` - en -`) + `) +//line web/authorize.qtpl:17 + if p.Client.GetName() == "" { +//line web/authorize.qtpl:17 + qw422016.N().S(` + `) //line web/authorize.qtpl:18 -} - + p.StreamT(qw422016, "Authorize %s", p.Client.GetName()) //line web/authorize.qtpl:18 -func (p *AuthPage) WriteLang(qq422016 qtio422016.Writer) { -//line web/authorize.qtpl:18 - qw422016 := qt422016.AcquireWriter(qq422016) -//line web/authorize.qtpl:18 - p.StreamLang(qw422016) -//line web/authorize.qtpl:18 - qt422016.ReleaseWriter(qw422016) -//line web/authorize.qtpl:18 -} - -//line web/authorize.qtpl:18 -func (p *AuthPage) Lang() string { -//line web/authorize.qtpl:18 - qb422016 := qt422016.AcquireByteBuffer() -//line web/authorize.qtpl:18 - p.WriteLang(qb422016) -//line web/authorize.qtpl:18 - qs422016 := string(qb422016.B) -//line web/authorize.qtpl:18 - qt422016.ReleaseByteBuffer(qb422016) -//line web/authorize.qtpl:18 - return qs422016 -//line web/authorize.qtpl:18 -} - + qw422016.N().S(` + `) +//line web/authorize.qtpl:19 + } else { +//line web/authorize.qtpl:19 + qw422016.N().S(` + `) //line web/authorize.qtpl:20 -func (p *AuthPage) StreamTitle(qw422016 *qt422016.Writer) { + p.StreamT(qw422016, "Authorize application") //line web/authorize.qtpl:20 - qw422016.N().S(` - Authorize `) + qw422016.N().S(` + `) //line web/authorize.qtpl:21 - qw422016.E().S(p.Client.Name[0]) + } //line web/authorize.qtpl:21 qw422016.N().S(` `) @@ -83,7 +68,7 @@ func (p *AuthPage) StreamTitle(qw422016 *qt422016.Writer) { } //line web/authorize.qtpl:22 -func (p *AuthPage) WriteTitle(qq422016 qtio422016.Writer) { +func (p *AuthorizePage) WriteTitle(qq422016 qtio422016.Writer) { //line web/authorize.qtpl:22 qw422016 := qt422016.AcquireWriter(qq422016) //line web/authorize.qtpl:22 @@ -94,7 +79,7 @@ func (p *AuthPage) WriteTitle(qq422016 qtio422016.Writer) { } //line web/authorize.qtpl:22 -func (p *AuthPage) Title() string { +func (p *AuthorizePage) Title() string { //line web/authorize.qtpl:22 qb422016 := qt422016.AcquireByteBuffer() //line web/authorize.qtpl:22 @@ -109,254 +94,297 @@ func (p *AuthPage) Title() string { } //line web/authorize.qtpl:24 -func (p *AuthPage) StreamHead(qw422016 *qt422016.Writer) { +func (p *AuthorizePage) StreamBody(qw422016 *qt422016.Writer) { //line web/authorize.qtpl:24 qw422016.N().S(` -`) -//line web/authorize.qtpl:25 -} - -//line web/authorize.qtpl:25 -func (p *AuthPage) WriteHead(qq422016 qtio422016.Writer) { -//line web/authorize.qtpl:25 - qw422016 := qt422016.AcquireWriter(qq422016) -//line web/authorize.qtpl:25 - p.StreamHead(qw422016) -//line web/authorize.qtpl:25 - qt422016.ReleaseWriter(qw422016) -//line web/authorize.qtpl:25 -} - -//line web/authorize.qtpl:25 -func (p *AuthPage) Head() string { -//line web/authorize.qtpl:25 - qb422016 := qt422016.AcquireByteBuffer() -//line web/authorize.qtpl:25 - p.WriteHead(qb422016) -//line web/authorize.qtpl:25 - qs422016 := string(qb422016.B) -//line web/authorize.qtpl:25 - qt422016.ReleaseByteBuffer(qb422016) -//line web/authorize.qtpl:25 - return qs422016 -//line web/authorize.qtpl:25 -} - -//line web/authorize.qtpl:27 -func (p *AuthPage) StreamBody(qw422016 *qt422016.Writer) { -//line web/authorize.qtpl:27 - qw422016.N().S(` - `) -//line web/authorize.qtpl:28 - if p.Client.Logo[0] != nil { -//line web/authorize.qtpl:28 - qw422016.N().S(` - `)
-//line web/authorize.qtpl:30
-		qw422016.E().S(p.Client.Name[0])
-//line web/authorize.qtpl:30
-		qw422016.N().S(` - `) -//line web/authorize.qtpl:39 - } -//line web/authorize.qtpl:39 - qw422016.N().S(` - -

`) -//line web/authorize.qtpl:41 - qw422016.E().S(p.Client.Name[0]) -//line web/authorize.qtpl:41 - qw422016.N().S(`

- -
- +
`) -//line web/authorize.qtpl:52 - if p.CSRF != "" { -//line web/authorize.qtpl:52 +//line web/authorize.qtpl:26 + if p.Client.GetLogo() != nil { +//line web/authorize.qtpl:26 qw422016.N().S(` - + `) +//line web/authorize.qtpl:37 + } +//line web/authorize.qtpl:37 + qw422016.N().S(` + +

+ `) +//line web/authorize.qtpl:40 + if p.Client.GetURL() != nil { +//line web/authorize.qtpl:40 + qw422016.N().S(` + - `) -//line web/authorize.qtpl:57 + `) +//line web/authorize.qtpl:42 } -//line web/authorize.qtpl:57 +//line web/authorize.qtpl:42 + qw422016.N().S(` + `) +//line web/authorize.qtpl:43 + if p.Client.GetName() != "" { +//line web/authorize.qtpl:43 + qw422016.N().S(` + `) +//line web/authorize.qtpl:44 + qw422016.E().S(p.Client.GetName()) +//line web/authorize.qtpl:44 + qw422016.N().S(` + `) +//line web/authorize.qtpl:45 + } else { +//line web/authorize.qtpl:45 + qw422016.N().S(` + `) +//line web/authorize.qtpl:46 + qw422016.E().S(p.Client.ID.String()) +//line web/authorize.qtpl:46 + qw422016.N().S(` + `) +//line web/authorize.qtpl:47 + } +//line web/authorize.qtpl:47 + qw422016.N().S(` + `) +//line web/authorize.qtpl:48 + if p.Client.GetURL() != nil { +//line web/authorize.qtpl:48 + qw422016.N().S(` + + `) +//line web/authorize.qtpl:50 + } +//line web/authorize.qtpl:50 + qw422016.N().S(` +

+
+ +
+ + + `) +//line web/authorize.qtpl:64 + if p.CSRF != nil { +//line web/authorize.qtpl:64 + qw422016.N().S(` + + `) +//line web/authorize.qtpl:69 + } +//line web/authorize.qtpl:69 qw422016.N().S(` - - - - - - - - - `) + `) +//line web/authorize.qtpl:71 + for key, val := range map[string]string{ + "client_id": p.Client.ID.String(), + "redirect_uri": p.RedirectURI.String(), + "response_type": p.ResponseType.String(), + "state": p.State, + } { +//line web/authorize.qtpl:76 + qw422016.N().S(` + + `) +//line web/authorize.qtpl:81 + } +//line web/authorize.qtpl:81 + qw422016.N().S(` + + `) +//line web/authorize.qtpl:83 + if len(p.Scope) > 0 { +//line web/authorize.qtpl:83 + qw422016.N().S(` +
+ `) +//line web/authorize.qtpl:85 + p.StreamT(qw422016, "Choose your scopes") +//line web/authorize.qtpl:85 + qw422016.N().S(` + + `) +//line web/authorize.qtpl:87 + for _, scope := range p.Scope { +//line web/authorize.qtpl:87 + qw422016.N().S(` +
+ +
+ `) +//line web/authorize.qtpl:99 + } +//line web/authorize.qtpl:99 + qw422016.N().S(` +
+ `) +//line web/authorize.qtpl:101 + } +//line web/authorize.qtpl:101 + qw422016.N().S(` + + `) +//line web/authorize.qtpl:103 if p.CodeChallenge != "" { -//line web/authorize.qtpl:79 +//line web/authorize.qtpl:103 qw422016.N().S(` - - - `) -//line web/authorize.qtpl:89 + `) +//line web/authorize.qtpl:113 } -//line web/authorize.qtpl:89 +//line web/authorize.qtpl:113 qw422016.N().S(` - `) -//line web/authorize.qtpl:91 - if len(p.Scope) != 0 { -//line web/authorize.qtpl:91 - qw422016.N().S(` - - `) -//line web/authorize.qtpl:96 - } -//line web/authorize.qtpl:96 - qw422016.N().S(` - - `) -//line web/authorize.qtpl:98 + `) +//line web/authorize.qtpl:115 if p.Me != nil { -//line web/authorize.qtpl:98 +//line web/authorize.qtpl:115 qw422016.N().S(` - - `) -//line web/authorize.qtpl:103 + `) +//line web/authorize.qtpl:120 } -//line web/authorize.qtpl:103 +//line web/authorize.qtpl:120 qw422016.N().S(` - + - - + + +
`) -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 } -//line web/authorize.qtpl:121 -func (p *AuthPage) WriteBody(qq422016 qtio422016.Writer) { -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 +func (p *AuthorizePage) WriteBody(qq422016 qtio422016.Writer) { +//line web/authorize.qtpl:139 qw422016 := qt422016.AcquireWriter(qq422016) -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 p.StreamBody(qw422016) -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 qt422016.ReleaseWriter(qw422016) -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 } -//line web/authorize.qtpl:121 -func (p *AuthPage) Body() string { -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 +func (p *AuthorizePage) Body() string { +//line web/authorize.qtpl:139 qb422016 := qt422016.AcquireByteBuffer() -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 p.WriteBody(qb422016) -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 qs422016 := string(qb422016.B) -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 qt422016.ReleaseByteBuffer(qb422016) -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 return qs422016 -//line web/authorize.qtpl:121 +//line web/authorize.qtpl:139 } diff --git a/web/callback.qtpl b/web/callback.qtpl new file mode 100644 index 0000000..d03f25c --- /dev/null +++ b/web/callback.qtpl @@ -0,0 +1,15 @@ +{% import "source.toby3d.me/website/indieauth/internal/domain" %} + +{% code type CallbackPage struct { + BaseOf + Token *domain.Token +} %} + +{% collapsespace %} +{% func (p *CallbackPage) Body() %} + {% if p.Token != nil %} +

{%s p.Token.Me.String() %}

+ {%s p.Token.AccessToken %} + {% endif %} +{% endfunc %} +{% endcollapsespace %} diff --git a/web/callback.qtpl.go b/web/callback.qtpl.go new file mode 100644 index 0000000..7bfc26b --- /dev/null +++ b/web/callback.qtpl.go @@ -0,0 +1,76 @@ +// Code generated by qtc from "callback.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +//line web/callback.qtpl:1 +package web + +//line web/callback.qtpl:1 +import "source.toby3d.me/website/indieauth/internal/domain" + +//line web/callback.qtpl:3 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line web/callback.qtpl:3 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line web/callback.qtpl:3 +type CallbackPage struct { + BaseOf + Token *domain.Token +} + +//line web/callback.qtpl:9 +func (p *CallbackPage) StreamBody(qw422016 *qt422016.Writer) { +//line web/callback.qtpl:9 + qw422016.N().S(` `) +//line web/callback.qtpl:10 + if p.Token != nil { +//line web/callback.qtpl:10 + qw422016.N().S(`

`) +//line web/callback.qtpl:11 + qw422016.E().S(p.Token.Me.String()) +//line web/callback.qtpl:11 + qw422016.N().S(`

`) +//line web/callback.qtpl:12 + qw422016.E().S(p.Token.AccessToken) +//line web/callback.qtpl:12 + qw422016.N().S(` `) +//line web/callback.qtpl:13 + } +//line web/callback.qtpl:13 + qw422016.N().S(` `) +//line web/callback.qtpl:14 +} + +//line web/callback.qtpl:14 +func (p *CallbackPage) WriteBody(qq422016 qtio422016.Writer) { +//line web/callback.qtpl:14 + qw422016 := qt422016.AcquireWriter(qq422016) +//line web/callback.qtpl:14 + p.StreamBody(qw422016) +//line web/callback.qtpl:14 + qt422016.ReleaseWriter(qw422016) +//line web/callback.qtpl:14 +} + +//line web/callback.qtpl:14 +func (p *CallbackPage) Body() string { +//line web/callback.qtpl:14 + qb422016 := qt422016.AcquireByteBuffer() +//line web/callback.qtpl:14 + p.WriteBody(qb422016) +//line web/callback.qtpl:14 + qs422016 := string(qb422016.B) +//line web/callback.qtpl:14 + qt422016.ReleaseByteBuffer(qb422016) +//line web/callback.qtpl:14 + return qs422016 +//line web/callback.qtpl:14 +} diff --git a/web/home.qtpl b/web/home.qtpl index 9911b99..04adc14 100644 --- a/web/home.qtpl +++ b/web/home.qtpl @@ -2,26 +2,24 @@ {% code type HomePage struct { BaseOf - RedirectURI []*domain.URL - Client *domain.Client - AuthEndpoint, - State string + Client *domain.Client + State string } %} {% collapsespace %} {% func (p *HomePage) Head() %} {%= p.BaseOf.Head() %} - {% for i := range p.RedirectURI %} - + {% for i := range p.Client.RedirectURI %} + {% endfor %} {% endfunc %} {% func (p *HomePage) Body() %} -
+
+ href="{%s p.Client.GetURL().String() %}"> - {%s p.Client.Name[0] %} + {%s p.Client.GetName() %} +
+
{% for name, value := range map[string]string { - "client_id": p.Client.ID.String(), - "redirect_uri": p.Client.RedirectURI[0].String(), - "response_type": "code", - "state": p.State, + "client_id": p.Client.ID.String(), + "redirect_uri": p.Client.RedirectURI[0].String(), + "response_type": domain.ResponseTypeCode.String(), + "state": p.State, + "scope": domain.Scopes{domain.ScopeProfile, domain.ScopeEmail}.String(), } %} {% endfor %} - - {%= p.T("Sign In") %}
-
+ {% endfunc %} {% endcollapsespace %} diff --git a/web/home.qtpl.go b/web/home.qtpl.go index 9efc90d..28916d4 100644 --- a/web/home.qtpl.go +++ b/web/home.qtpl.go @@ -23,143 +23,130 @@ var ( //line web/home.qtpl:3 type HomePage struct { BaseOf - RedirectURI []*domain.URL - Client *domain.Client - AuthEndpoint, - State string + Client *domain.Client + State string } -//line web/home.qtpl:12 +//line web/home.qtpl:10 func (p *HomePage) StreamHead(qw422016 *qt422016.Writer) { -//line web/home.qtpl:12 +//line web/home.qtpl:10 qw422016.N().S(` `) -//line web/home.qtpl:13 +//line web/home.qtpl:11 p.BaseOf.StreamHead(qw422016) -//line web/home.qtpl:13 +//line web/home.qtpl:11 qw422016.N().S(` `) -//line web/home.qtpl:14 - for i := range p.RedirectURI { -//line web/home.qtpl:14 +//line web/home.qtpl:12 + for i := range p.Client.RedirectURI { +//line web/home.qtpl:12 qw422016.N().S(` `) -//line web/home.qtpl:16 +//line web/home.qtpl:14 } -//line web/home.qtpl:16 +//line web/home.qtpl:14 qw422016.N().S(` `) -//line web/home.qtpl:17 +//line web/home.qtpl:15 } -//line web/home.qtpl:17 +//line web/home.qtpl:15 func (p *HomePage) WriteHead(qq422016 qtio422016.Writer) { -//line web/home.qtpl:17 +//line web/home.qtpl:15 qw422016 := qt422016.AcquireWriter(qq422016) -//line web/home.qtpl:17 +//line web/home.qtpl:15 p.StreamHead(qw422016) -//line web/home.qtpl:17 +//line web/home.qtpl:15 qt422016.ReleaseWriter(qw422016) -//line web/home.qtpl:17 +//line web/home.qtpl:15 } -//line web/home.qtpl:17 +//line web/home.qtpl:15 func (p *HomePage) Head() string { -//line web/home.qtpl:17 +//line web/home.qtpl:15 qb422016 := qt422016.AcquireByteBuffer() -//line web/home.qtpl:17 +//line web/home.qtpl:15 p.WriteHead(qb422016) -//line web/home.qtpl:17 +//line web/home.qtpl:15 qs422016 := string(qb422016.B) -//line web/home.qtpl:17 +//line web/home.qtpl:15 qt422016.ReleaseByteBuffer(qb422016) -//line web/home.qtpl:17 +//line web/home.qtpl:15 return qs422016 -//line web/home.qtpl:17 +//line web/home.qtpl:15 } -//line web/home.qtpl:19 +//line web/home.qtpl:17 func (p *HomePage) StreamBody(qw422016 *qt422016.Writer) { -//line web/home.qtpl:19 - qw422016.N().S(`

`) -//line web/home.qtpl:37 - qw422016.E().S(p.Client.Name[0]) -//line web/home.qtpl:37 - qw422016.N().S(`

`) +//line web/home.qtpl:35 + qw422016.E().S(p.Client.GetName()) +//line web/home.qtpl:35 + qw422016.N().S(`
`) //line web/home.qtpl:48 for name, value := range map[string]string{ "client_id": p.Client.ID.String(), "redirect_uri": p.Client.RedirectURI[0].String(), - "response_type": "code", + "response_type": domain.ResponseTypeCode.String(), "state": p.State, + "scope": domain.Scopes{domain.ScopeProfile, domain.ScopeEmail}.String(), } { -//line web/home.qtpl:53 +//line web/home.qtpl:54 qw422016.N().S(` `) -//line web/home.qtpl:58 +//line web/home.qtpl:59 } -//line web/home.qtpl:58 - qw422016.N().S(`
`) -//line web/home.qtpl:76 +//line web/home.qtpl:69 + qw422016.N().S(` `) +//line web/home.qtpl:72 } -//line web/home.qtpl:76 +//line web/home.qtpl:72 func (p *HomePage) WriteBody(qq422016 qtio422016.Writer) { -//line web/home.qtpl:76 +//line web/home.qtpl:72 qw422016 := qt422016.AcquireWriter(qq422016) -//line web/home.qtpl:76 +//line web/home.qtpl:72 p.StreamBody(qw422016) -//line web/home.qtpl:76 +//line web/home.qtpl:72 qt422016.ReleaseWriter(qw422016) -//line web/home.qtpl:76 +//line web/home.qtpl:72 } -//line web/home.qtpl:76 +//line web/home.qtpl:72 func (p *HomePage) Body() string { -//line web/home.qtpl:76 +//line web/home.qtpl:72 qb422016 := qt422016.AcquireByteBuffer() -//line web/home.qtpl:76 +//line web/home.qtpl:72 p.WriteBody(qb422016) -//line web/home.qtpl:76 +//line web/home.qtpl:72 qs422016 := string(qb422016.B) -//line web/home.qtpl:76 +//line web/home.qtpl:72 qt422016.ReleaseByteBuffer(qb422016) -//line web/home.qtpl:76 +//line web/home.qtpl:72 return qs422016 -//line web/home.qtpl:76 +//line web/home.qtpl:72 }