♻️ Replaced new domains in used parts

This commit is contained in:
Maxim Lebedev 2024-05-06 20:45:19 +05:00
parent 392f98c925
commit cba81b5ac4
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
13 changed files with 274 additions and 257 deletions

View File

@ -6,6 +6,8 @@ import (
"strings"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/grant"
"source.toby3d.me/toby3d/auth/internal/domain/response"
"source.toby3d.me/toby3d/form"
)
@ -26,7 +28,7 @@ type (
// Indicates to the authorization server that an authorization
// code should be returned as the response.
ResponseType domain.ResponseType `form:"response_type"` // code
ResponseType response.Type `form:"response_type"` // code
// A parameter set by the client which will be included when the
// user is redirected back to the client. This is used to
@ -50,7 +52,7 @@ type (
Me domain.Me `form:"me"`
RedirectURI domain.URL `form:"redirect_uri"`
CodeChallengeMethod domain.CodeChallengeMethod `form:"code_challenge_method,omitempty"`
ResponseType domain.ResponseType `form:"response_type"`
ResponseType response.Type `form:"response_type"`
Authorize string `form:"authorize"`
CodeChallenge string `form:"code_challenge,omitempty"`
State string `form:"state"`
@ -59,7 +61,7 @@ type (
}
AuthExchangeRequest struct {
GrantType domain.GrantType `form:"grant_type"` // authorization_code
GrantType grant.Type `form:"grant_type"` // authorization_code
// The client's URL, which MUST match the client_id used in the
// authentication request.
@ -98,7 +100,7 @@ func NewAuthAuthorizationRequest() *AuthAuthorizationRequest {
CodeChallengeMethod: domain.CodeChallengeMethodUnd,
Me: domain.Me{},
RedirectURI: domain.URL{},
ResponseType: domain.ResponseTypeUnd,
ResponseType: response.Und,
Scope: make(domain.Scopes, 0),
State: "",
}
@ -117,8 +119,8 @@ func (r *AuthAuthorizationRequest) bind(req *http.Request) error {
"https://indieauth.net/source/#authorization-request")
}
if r.ResponseType == domain.ResponseTypeID {
r.ResponseType = domain.ResponseTypeCode
if r.ResponseType == response.ID {
r.ResponseType = response.Code
}
return nil
@ -133,7 +135,7 @@ func NewAuthVerifyRequest() *AuthVerifyRequest {
Me: domain.Me{},
Provider: "",
RedirectURI: domain.URL{},
ResponseType: domain.ResponseTypeUnd,
ResponseType: response.Und,
Scope: make(domain.Scopes, 0),
State: "",
}
@ -159,8 +161,8 @@ func (r *AuthVerifyRequest) bind(req *http.Request) error {
// NOTE(toby3d): backwards-compatible support.
// See: https://aaronparecki.com/2020/12/03/1/indieauth-2020#response-type
if r.ResponseType == domain.ResponseTypeID {
r.ResponseType = domain.ResponseTypeCode
if r.ResponseType == response.ID {
r.ResponseType = response.Code
}
r.Provider = strings.ToLower(r.Provider)

View File

@ -19,6 +19,7 @@ import (
clientrepo "source.toby3d.me/toby3d/auth/internal/client/repository/memory"
clientucase "source.toby3d.me/toby3d/auth/internal/client/usecase"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/response"
"source.toby3d.me/toby3d/auth/internal/profile"
profilerepo "source.toby3d.me/toby3d/auth/internal/profile/repository/memory"
"source.toby3d.me/toby3d/auth/internal/session"
@ -68,7 +69,7 @@ func TestAuthorize(t *testing.T) {
"code_challenge_method": domain.CodeChallengeMethodS256.String(),
"me": me.String(),
"redirect_uri": client.RedirectURI[0].String(),
"response_type": domain.ResponseTypeCode.String(),
"response_type": response.Code.String(),
"scope": "profile email",
"state": "1234567890",
} {

View File

@ -7,14 +7,16 @@ import (
"io"
"net/http"
"net/url"
"slices"
"github.com/tomnomnom/linkheader"
"golang.org/x/exp/slices"
"willnorris.com/go/microformats"
"source.toby3d.me/toby3d/auth/internal/client"
"source.toby3d.me/toby3d/auth/internal/common"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/grant"
"source.toby3d.me/toby3d/auth/internal/domain/response"
)
type (
@ -30,11 +32,11 @@ type (
Microsub domain.URL `json:"microsub"`
Issuer domain.URL `json:"issuer"`
Micropub domain.URL `json:"micropub"`
GrantTypesSupported []domain.GrantType `json:"grant_types_supported,omitempty"`
GrantTypesSupported []grant.Type `json:"grant_types_supported,omitempty"`
IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported,omitempty"`
RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"`
ScopesSupported []domain.Scope `json:"scopes_supported,omitempty"`
ResponseTypesSupported []domain.ResponseType `json:"response_types_supported,omitempty"`
ResponseTypesSupported []response.Type `json:"response_types_supported,omitempty"`
CodeChallengeMethodsSupported []domain.CodeChallengeMethod `json:"code_challenge_methods_supported"`
AuthorizationResponseIssParameterSupported bool `json:"authorization_response_iss_parameter_supported,omitempty"`
}

View File

@ -1,4 +1,3 @@
//nolint:dupl
package domain_test
import (

View File

@ -12,6 +12,8 @@ import (
"source.toby3d.me/toby3d/auth/internal/common"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/grant"
"source.toby3d.me/toby3d/auth/internal/domain/response"
"source.toby3d.me/toby3d/auth/internal/metadata"
)
@ -28,11 +30,11 @@ type (
Microsub domain.URL `json:"microsub"`
Issuer domain.URL `json:"issuer"`
Micropub domain.URL `json:"micropub"`
GrantTypesSupported []domain.GrantType `json:"grant_types_supported,omitempty"`
GrantTypesSupported []grant.Type `json:"grant_types_supported,omitempty"`
IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported,omitempty"`
RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"`
ScopesSupported []domain.Scope `json:"scopes_supported,omitempty"`
ResponseTypesSupported []domain.ResponseType `json:"response_types_supported,omitempty"`
ResponseTypesSupported []response.Type `json:"response_types_supported,omitempty"`
CodeChallengeMethodsSupported []domain.CodeChallengeMethod `json:"code_challenge_methods_supported"`
AuthorizationResponseIssParameterSupported bool `json:"authorization_response_iss_parameter_supported,omitempty"`
}
@ -118,8 +120,8 @@ func populateBuffer(dst map[string][]string, rel, u string) {
func NewResponse() *Response {
return &Response{
CodeChallengeMethodsSupported: make([]domain.CodeChallengeMethod, 0),
GrantTypesSupported: make([]domain.GrantType, 0),
ResponseTypesSupported: make([]domain.ResponseType, 0),
GrantTypesSupported: make([]grant.Type, 0),
ResponseTypesSupported: make([]response.Type, 0),
ScopesSupported: make([]domain.Scope, 0),
IntrospectionEndpointAuthMethodsSupported: make([]string, 0),
RevocationEndpointAuthMethodsSupported: make([]string, 0),

View File

@ -14,6 +14,8 @@ import (
"source.toby3d.me/toby3d/auth/internal/common"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/grant"
"source.toby3d.me/toby3d/auth/internal/domain/response"
repository "source.toby3d.me/toby3d/auth/internal/metadata/repository/http"
)
@ -120,8 +122,8 @@ func TestGet(t *testing.T) {
if diff := cmp.Diff(tc.out, out, cmp.AllowUnexported(
domain.ClientID{},
domain.CodeChallengeMethod{},
domain.GrantType{},
domain.ResponseType{},
grant.Und,
response.Und,
domain.Scope{},
url.URL{},
)); diff != "" {

View File

@ -5,23 +5,24 @@ import (
"net/http"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/grant"
"source.toby3d.me/toby3d/form"
)
type (
TokenExchangeRequest struct {
ClientID domain.ClientID `form:"client_id"`
RedirectURI domain.URL `form:"redirect_uri"`
GrantType domain.GrantType `form:"grant_type"`
Code string `form:"code"`
CodeVerifier string `form:"code_verifier"`
ClientID domain.ClientID `form:"client_id"`
RedirectURI domain.URL `form:"redirect_uri"`
GrantType grant.Type `form:"grant_type"`
Code string `form:"code"`
CodeVerifier string `form:"code_verifier"`
}
TokenRefreshRequest struct {
// The client ID that was used when the refresh token was issued.
ClientID domain.ClientID `form:"client_id"`
GrantType domain.GrantType `form:"grant_type"` // refresh_token
GrantType grant.Type `form:"grant_type"` // refresh_token
// The refresh token previously offered to the client.
RefreshToken string `form:"refresh_token"`

View File

@ -15,6 +15,8 @@ import (
"source.toby3d.me/toby3d/auth/internal/common"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/grant"
"source.toby3d.me/toby3d/auth/internal/domain/response"
"source.toby3d.me/toby3d/auth/internal/user"
)
@ -31,11 +33,11 @@ type (
Microsub domain.URL `json:"microsub"`
Issuer domain.URL `json:"issuer"`
Micropub domain.URL `json:"micropub"`
GrantTypesSupported []domain.GrantType `json:"grant_types_supported,omitempty"`
GrantTypesSupported []grant.Type `json:"grant_types_supported,omitempty"`
IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported,omitempty"`
RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"`
ScopesSupported []domain.Scope `json:"scopes_supported,omitempty"`
ResponseTypesSupported []domain.ResponseType `json:"response_types_supported,omitempty"`
ResponseTypesSupported []response.Type `json:"response_types_supported,omitempty"`
CodeChallengeMethodsSupported []domain.CodeChallengeMethod `json:"code_challenge_methods_supported"`
AuthorizationResponseIssParameterSupported bool `json:"authorization_response_iss_parameter_supported,omitempty"`
}

12
main.go
View File

@ -37,6 +37,8 @@ import (
clienthttprepo "source.toby3d.me/toby3d/auth/internal/client/repository/http"
clientucase "source.toby3d.me/toby3d/auth/internal/client/usecase"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/grant"
"source.toby3d.me/toby3d/auth/internal/domain/response"
healthhttpdelivery "source.toby3d.me/toby3d/auth/internal/health/delivery/http"
metadatahttpdelivery "source.toby3d.me/toby3d/auth/internal/metadata/delivery/http"
"source.toby3d.me/toby3d/auth/internal/middleware"
@ -286,12 +288,12 @@ func (app *App) Handler() http.Handler {
domain.ScopeRead,
domain.ScopeUpdate,
},
ResponseTypesSupported: []domain.ResponseType{
domain.ResponseTypeCode,
ResponseTypesSupported: []response.Type{
response.Code,
},
GrantTypesSupported: []domain.GrantType{
domain.GrantTypeAuthorizationCode,
domain.GrantTypeTicket,
GrantTypesSupported: []grant.Type{
grant.AuthorizationCode,
grant.Ticket,
},
CodeChallengeMethodsSupported: []domain.CodeChallengeMethod{
domain.CodeChallengeMethodMD5,

View File

@ -2,6 +2,7 @@
{% import (
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/response"
"source.toby3d.me/toby3d/auth/web/template/layout"
) %}
@ -9,7 +10,7 @@
layout.BaseOf
Scope domain.Scopes
CodeChallengeMethod domain.CodeChallengeMethod
ResponseType domain.ResponseType
ResponseType response.Type
Client *domain.Client
Me *domain.Me
RedirectURI *domain.URL

View File

@ -7,28 +7,29 @@ package template
//line web/template/authorize.qtpl:3
import (
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/response"
"source.toby3d.me/toby3d/auth/web/template/layout"
)
//line web/template/authorize.qtpl:8
//line web/template/authorize.qtpl:9
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line web/template/authorize.qtpl:8
//line web/template/authorize.qtpl:9
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line web/template/authorize.qtpl:8
//line web/template/authorize.qtpl:9
type Authorize struct {
layout.BaseOf
Scope domain.Scopes
CodeChallengeMethod domain.CodeChallengeMethod
ResponseType domain.ResponseType
ResponseType response.Type
Client *domain.Client
Me *domain.Me
RedirectURI *domain.URL
@ -38,74 +39,74 @@ type Authorize struct {
State string
}
//line web/template/authorize.qtpl:22
//line web/template/authorize.qtpl:23
func (p *Authorize) StreamTitle(qw422016 *qt422016.Writer) {
//line web/template/authorize.qtpl:22
//line web/template/authorize.qtpl:23
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:23
//line web/template/authorize.qtpl:24
if p.Client.Name != "" {
//line web/template/authorize.qtpl:23
//line web/template/authorize.qtpl:24
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:24
//line web/template/authorize.qtpl:25
p.StreamT(qw422016, "Authorize %s", p.Client.Name)
//line web/template/authorize.qtpl:24
//line web/template/authorize.qtpl:25
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:25
//line web/template/authorize.qtpl:26
} else {
//line web/template/authorize.qtpl:25
//line web/template/authorize.qtpl:26
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:26
//line web/template/authorize.qtpl:27
p.StreamT(qw422016, "Authorize application")
//line web/template/authorize.qtpl:26
//line web/template/authorize.qtpl:27
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:27
//line web/template/authorize.qtpl:28
}
//line web/template/authorize.qtpl:27
//line web/template/authorize.qtpl:28
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
}
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
func (p *Authorize) WriteTitle(qq422016 qtio422016.Writer) {
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
qw422016 := qt422016.AcquireWriter(qq422016)
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
p.StreamTitle(qw422016)
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
qt422016.ReleaseWriter(qw422016)
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
}
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
func (p *Authorize) Title() string {
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
qb422016 := qt422016.AcquireByteBuffer()
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
p.WriteTitle(qb422016)
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
qs422016 := string(qb422016.B)
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
qt422016.ReleaseByteBuffer(qb422016)
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
return qs422016
//line web/template/authorize.qtpl:28
//line web/template/authorize.qtpl:29
}
//line web/template/authorize.qtpl:30
//line web/template/authorize.qtpl:31
func (p *Authorize) StreamBody(qw422016 *qt422016.Writer) {
//line web/template/authorize.qtpl:30
//line web/template/authorize.qtpl:31
qw422016.N().S(`
<header>
`)
//line web/template/authorize.qtpl:32
//line web/template/authorize.qtpl:33
if p.Client.Logo != nil {
//line web/template/authorize.qtpl:32
//line web/template/authorize.qtpl:33
qw422016.N().S(`
<img class=""
crossorigin="anonymous"
@ -115,73 +116,73 @@ func (p *Authorize) StreamBody(qw422016 *qt422016.Writer) {
loading="lazy"
referrerpolicy="no-referrer-when-downgrade"
src="`)
//line web/template/authorize.qtpl:40
//line web/template/authorize.qtpl:41
qw422016.E().S(p.Client.Logo.String())
//line web/template/authorize.qtpl:40
//line web/template/authorize.qtpl:41
qw422016.N().S(`"
alt="`)
//line web/template/authorize.qtpl:41
//line web/template/authorize.qtpl:42
qw422016.E().S(p.Client.Name)
//line web/template/authorize.qtpl:41
//line web/template/authorize.qtpl:42
qw422016.N().S(`"
width="140">
`)
//line web/template/authorize.qtpl:43
//line web/template/authorize.qtpl:44
}
//line web/template/authorize.qtpl:43
//line web/template/authorize.qtpl:44
qw422016.N().S(`
<h2>
`)
//line web/template/authorize.qtpl:46
//line web/template/authorize.qtpl:47
if p.Client.URL != nil {
//line web/template/authorize.qtpl:46
//line web/template/authorize.qtpl:47
qw422016.N().S(`
<a href="`)
//line web/template/authorize.qtpl:47
//line web/template/authorize.qtpl:48
qw422016.E().S(p.Client.URL.String())
//line web/template/authorize.qtpl:47
//line web/template/authorize.qtpl:48
qw422016.N().S(`">
`)
//line web/template/authorize.qtpl:48
//line web/template/authorize.qtpl:49
}
//line web/template/authorize.qtpl:48
//line web/template/authorize.qtpl:49
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:49
//line web/template/authorize.qtpl:50
if p.Client.Name != "" {
//line web/template/authorize.qtpl:49
//line web/template/authorize.qtpl:50
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:50
//line web/template/authorize.qtpl:51
qw422016.E().S(p.Client.Name)
//line web/template/authorize.qtpl:50
//line web/template/authorize.qtpl:51
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:51
//line web/template/authorize.qtpl:52
} else {
//line web/template/authorize.qtpl:51
//line web/template/authorize.qtpl:52
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:52
//line web/template/authorize.qtpl:53
qw422016.E().S(p.Client.ID.String())
//line web/template/authorize.qtpl:52
//line web/template/authorize.qtpl:53
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:53
//line web/template/authorize.qtpl:54
}
//line web/template/authorize.qtpl:53
//line web/template/authorize.qtpl:54
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:54
//line web/template/authorize.qtpl:55
if p.Client.URL != nil {
//line web/template/authorize.qtpl:54
//line web/template/authorize.qtpl:55
qw422016.N().S(`
</a>
`)
//line web/template/authorize.qtpl:56
//line web/template/authorize.qtpl:57
}
//line web/template/authorize.qtpl:56
//line web/template/authorize.qtpl:57
qw422016.N().S(`
</h2>
</header>
@ -189,9 +190,9 @@ func (p *Authorize) StreamBody(qw422016 *qt422016.Writer) {
<main>
<aside>
`)
//line web/template/authorize.qtpl:62
//line web/template/authorize.qtpl:63
if p.CodeChallengeMethod != domain.CodeChallengeMethodUnd && p.CodeChallenge != "" {
//line web/template/authorize.qtpl:62
//line web/template/authorize.qtpl:63
qw422016.N().S(`
<p class="with-icon">
<span class="icon"
@ -199,16 +200,16 @@ func (p *Authorize) StreamBody(qw422016 *qt422016.Writer) {
aria-label="closed lock with key">🔐</span>
`)
//line web/template/authorize.qtpl:68
//line web/template/authorize.qtpl:69
p.StreamT(qw422016, `This client uses %sPKCE%s with the %s%s%s method.`, `<abbr title="Proof of Key Code Exchange">`,
`</abbr>`, `<code>`, p.CodeChallengeMethod, `</code>`)
//line web/template/authorize.qtpl:69
//line web/template/authorize.qtpl:70
qw422016.N().S(`
</p>
`)
//line web/template/authorize.qtpl:71
//line web/template/authorize.qtpl:72
} else {
//line web/template/authorize.qtpl:71
//line web/template/authorize.qtpl:72
qw422016.N().S(`
<details>
<summary class="with-icon">
@ -217,26 +218,26 @@ func (p *Authorize) StreamBody(qw422016 *qt422016.Writer) {
aria-label="unlock">🔓</span>
`)
//line web/template/authorize.qtpl:78
//line web/template/authorize.qtpl:79
p.StreamT(qw422016, `This client does not use %sPKCE%s!`, `<abbr title="Proof of Key Code Exchange">`, `</abbr>`)
//line web/template/authorize.qtpl:78
//line web/template/authorize.qtpl:79
qw422016.N().S(`
</summary>
<p>
`)
//line web/template/authorize.qtpl:81
//line web/template/authorize.qtpl:82
p.StreamT(qw422016, `%sProof of Key Code Exchange%s is a mechanism that protects against attackers in the middle hijacking `+
`your application's authentication process. You can still authorize this application without this protection, `+
`but you must independently verify the security of this connection. If you have any doubts - stop the process `+
` and contact the developers.`, `<dfn id="PKCE">`, `</dfn>`)
//line web/template/authorize.qtpl:84
//line web/template/authorize.qtpl:85
qw422016.N().S(`
</p>
</details>
`)
//line web/template/authorize.qtpl:87
//line web/template/authorize.qtpl:88
}
//line web/template/authorize.qtpl:87
//line web/template/authorize.qtpl:88
qw422016.N().S(`
</aside>
@ -250,215 +251,215 @@ func (p *Authorize) StreamBody(qw422016 *qt422016.Writer) {
target="_self">
`)
//line web/template/authorize.qtpl:99
//line web/template/authorize.qtpl:100
if p.CSRF != nil {
//line web/template/authorize.qtpl:99
//line web/template/authorize.qtpl:100
qw422016.N().S(`
<input type="hidden"
name="_csrf"
value="`)
//line web/template/authorize.qtpl:102
//line web/template/authorize.qtpl:103
qw422016.E().Z(p.CSRF)
//line web/template/authorize.qtpl:102
//line web/template/authorize.qtpl:103
qw422016.N().S(`">
`)
//line web/template/authorize.qtpl:103
//line web/template/authorize.qtpl:104
}
//line web/template/authorize.qtpl:103
//line web/template/authorize.qtpl:104
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:105
//line web/template/authorize.qtpl:106
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/template/authorize.qtpl:110
//line web/template/authorize.qtpl:111
qw422016.N().S(`
<input type="hidden"
name="`)
//line web/template/authorize.qtpl:112
//line web/template/authorize.qtpl:113
qw422016.E().S(key)
//line web/template/authorize.qtpl:112
//line web/template/authorize.qtpl:113
qw422016.N().S(`"
value="`)
//line web/template/authorize.qtpl:113
//line web/template/authorize.qtpl:114
qw422016.E().S(val)
//line web/template/authorize.qtpl:113
//line web/template/authorize.qtpl:114
qw422016.N().S(`">
`)
//line web/template/authorize.qtpl:114
//line web/template/authorize.qtpl:115
}
//line web/template/authorize.qtpl:114
//line web/template/authorize.qtpl:115
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:116
//line web/template/authorize.qtpl:117
if len(p.Scope) > 0 {
//line web/template/authorize.qtpl:116
//line web/template/authorize.qtpl:117
qw422016.N().S(`
<fieldset>
<legend>`)
//line web/template/authorize.qtpl:118
//line web/template/authorize.qtpl:119
p.StreamT(qw422016, "Scopes")
//line web/template/authorize.qtpl:118
//line web/template/authorize.qtpl:119
qw422016.N().S(`</legend>
`)
//line web/template/authorize.qtpl:120
//line web/template/authorize.qtpl:121
for _, scope := range p.Scope {
//line web/template/authorize.qtpl:120
//line web/template/authorize.qtpl:121
qw422016.N().S(`
<div>
<label>
<input type="checkbox"
name="scope[]"
value="`)
//line web/template/authorize.qtpl:125
//line web/template/authorize.qtpl:126
qw422016.E().S(scope.String())
//line web/template/authorize.qtpl:125
//line web/template/authorize.qtpl:126
qw422016.N().S(`"
checked>
`)
//line web/template/authorize.qtpl:128
//line web/template/authorize.qtpl:129
qw422016.E().S(scope.String())
//line web/template/authorize.qtpl:128
//line web/template/authorize.qtpl:129
qw422016.N().S(`
</label>
</div>
`)
//line web/template/authorize.qtpl:131
//line web/template/authorize.qtpl:132
}
//line web/template/authorize.qtpl:131
//line web/template/authorize.qtpl:132
qw422016.N().S(`
</fieldset>
`)
//line web/template/authorize.qtpl:133
//line web/template/authorize.qtpl:134
} else {
//line web/template/authorize.qtpl:133
//line web/template/authorize.qtpl:134
qw422016.N().S(`
<aside>
<p>`)
//line web/template/authorize.qtpl:135
//line web/template/authorize.qtpl:136
p.StreamT(qw422016, `No scopes is requested: the application will only get your profile URL.`)
//line web/template/authorize.qtpl:135
//line web/template/authorize.qtpl:136
qw422016.N().S(`</p>
</aside>
`)
//line web/template/authorize.qtpl:137
//line web/template/authorize.qtpl:138
}
//line web/template/authorize.qtpl:137
//line web/template/authorize.qtpl:138
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:139
//line web/template/authorize.qtpl:140
if p.CodeChallenge != "" {
//line web/template/authorize.qtpl:139
//line web/template/authorize.qtpl:140
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:140
//line web/template/authorize.qtpl:141
for key, val := range map[string]string{
"code_challenge": p.CodeChallenge,
"code_challenge_method": p.CodeChallengeMethod.String(),
} {
//line web/template/authorize.qtpl:143
//line web/template/authorize.qtpl:144
qw422016.N().S(`
<input type="hidden"
name="`)
//line web/template/authorize.qtpl:145
//line web/template/authorize.qtpl:146
qw422016.E().S(key)
//line web/template/authorize.qtpl:145
//line web/template/authorize.qtpl:146
qw422016.N().S(`"
value="`)
//line web/template/authorize.qtpl:146
//line web/template/authorize.qtpl:147
qw422016.E().S(val)
//line web/template/authorize.qtpl:146
//line web/template/authorize.qtpl:147
qw422016.N().S(`">
`)
//line web/template/authorize.qtpl:147
//line web/template/authorize.qtpl:148
}
//line web/template/authorize.qtpl:147
//line web/template/authorize.qtpl:148
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:148
//line web/template/authorize.qtpl:149
}
//line web/template/authorize.qtpl:148
//line web/template/authorize.qtpl:149
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:150
//line web/template/authorize.qtpl:151
if p.Me != nil {
//line web/template/authorize.qtpl:150
//line web/template/authorize.qtpl:151
qw422016.N().S(`
<input type="hidden"
name="me"
value="`)
//line web/template/authorize.qtpl:153
//line web/template/authorize.qtpl:154
qw422016.E().S(p.Me.String())
//line web/template/authorize.qtpl:153
//line web/template/authorize.qtpl:154
qw422016.N().S(`">
`)
//line web/template/authorize.qtpl:154
//line web/template/authorize.qtpl:155
}
//line web/template/authorize.qtpl:154
//line web/template/authorize.qtpl:155
qw422016.N().S(`
`)
//line web/template/authorize.qtpl:156
//line web/template/authorize.qtpl:157
if len(p.Providers) > 0 {
//line web/template/authorize.qtpl:156
//line web/template/authorize.qtpl:157
qw422016.N().S(`
<select name="provider"
autocomplete
required>
`)
//line web/template/authorize.qtpl:161
//line web/template/authorize.qtpl:162
for _, provider := range p.Providers {
//line web/template/authorize.qtpl:161
//line web/template/authorize.qtpl:162
qw422016.N().S(`
<option value="`)
//line web/template/authorize.qtpl:162
//line web/template/authorize.qtpl:163
qw422016.E().S(provider.UID)
//line web/template/authorize.qtpl:162
//line web/template/authorize.qtpl:163
qw422016.N().S(`"
`)
//line web/template/authorize.qtpl:163
//line web/template/authorize.qtpl:164
if provider.UID == "mastodon" {
//line web/template/authorize.qtpl:163
//line web/template/authorize.qtpl:164
qw422016.N().S(`selected`)
//line web/template/authorize.qtpl:163
//line web/template/authorize.qtpl:164
}
//line web/template/authorize.qtpl:163
//line web/template/authorize.qtpl:164
qw422016.N().S(`>
`)
//line web/template/authorize.qtpl:165
//line web/template/authorize.qtpl:166
qw422016.E().S(provider.Name)
//line web/template/authorize.qtpl:165
//line web/template/authorize.qtpl:166
qw422016.N().S(`
</option>
`)
//line web/template/authorize.qtpl:167
//line web/template/authorize.qtpl:168
}
//line web/template/authorize.qtpl:167
//line web/template/authorize.qtpl:168
qw422016.N().S(`
</select>
`)
//line web/template/authorize.qtpl:169
//line web/template/authorize.qtpl:170
} else {
//line web/template/authorize.qtpl:169
//line web/template/authorize.qtpl:170
qw422016.N().S(`
<input type="hidden"
name="provider"
value="direct">
`)
//line web/template/authorize.qtpl:173
//line web/template/authorize.qtpl:174
}
//line web/template/authorize.qtpl:173
//line web/template/authorize.qtpl:174
qw422016.N().S(`
<button type="submit"
@ -466,9 +467,9 @@ func (p *Authorize) StreamBody(qw422016 *qt422016.Writer) {
value="deny">
`)
//line web/template/authorize.qtpl:179
//line web/template/authorize.qtpl:180
p.StreamT(qw422016, "Deny")
//line web/template/authorize.qtpl:179
//line web/template/authorize.qtpl:180
qw422016.N().S(`
</button>
@ -477,47 +478,47 @@ func (p *Authorize) StreamBody(qw422016 *qt422016.Writer) {
value="allow">
`)
//line web/template/authorize.qtpl:186
//line web/template/authorize.qtpl:187
p.StreamT(qw422016, "Allow")
//line web/template/authorize.qtpl:186
//line web/template/authorize.qtpl:187
qw422016.N().S(`
</button>
<aside>
<p>`)
//line web/template/authorize.qtpl:190
//line web/template/authorize.qtpl:191
p.StreamT(qw422016, `You will be redirected to %s%s%s`, `<code>`, p.RedirectURI, `</code>`)
//line web/template/authorize.qtpl:190
//line web/template/authorize.qtpl:191
qw422016.N().S(`</p>
</aside>
</form>
</main>
`)
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
}
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
func (p *Authorize) WriteBody(qq422016 qtio422016.Writer) {
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
qw422016 := qt422016.AcquireWriter(qq422016)
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
p.StreamBody(qw422016)
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
qt422016.ReleaseWriter(qw422016)
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
}
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
func (p *Authorize) Body() string {
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
qb422016 := qt422016.AcquireByteBuffer()
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
p.WriteBody(qb422016)
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
qs422016 := string(qb422016.B)
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
qt422016.ReleaseByteBuffer(qb422016)
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
return qs422016
//line web/template/authorize.qtpl:194
//line web/template/authorize.qtpl:195
}

View File

@ -2,6 +2,7 @@
{% import (
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/response"
"source.toby3d.me/toby3d/auth/web/template/layout"
) %}
@ -54,7 +55,7 @@
{% for name, value := range map[string]string{
"client_id": p.Client.ID.String(),
"redirect_uri": p.Client.RedirectURI[0].String(),
"response_type": domain.ResponseTypeCode.String(),
"response_type": response.Code.String(),
"scope": domain.Scopes{domain.ScopeEmail, domain.ScopeProfile}.String(),
"state": p.State,
} %}

View File

@ -7,157 +7,158 @@ package template
//line web/template/home.qtpl:3
import (
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/internal/domain/response"
"source.toby3d.me/toby3d/auth/web/template/layout"
)
//line web/template/home.qtpl:8
//line web/template/home.qtpl:9
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line web/template/home.qtpl:8
//line web/template/home.qtpl:9
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line web/template/home.qtpl:8
//line web/template/home.qtpl:9
type Home struct {
layout.BaseOf
Client *domain.Client
State string
}
//line web/template/home.qtpl:15
//line web/template/home.qtpl:16
func (p *Home) StreamHead(qw422016 *qt422016.Writer) {
//line web/template/home.qtpl:15
qw422016.N().S(` `)
//line web/template/home.qtpl:16
qw422016.N().S(` `)
//line web/template/home.qtpl:17
p.BaseOf.StreamHead(qw422016)
//line web/template/home.qtpl:16
qw422016.N().S(` `)
//line web/template/home.qtpl:17
qw422016.N().S(` `)
//line web/template/home.qtpl:18
for i := range p.Client.RedirectURI {
//line web/template/home.qtpl:17
//line web/template/home.qtpl:18
qw422016.N().S(` <link rel="redirect_uri" href="`)
//line web/template/home.qtpl:19
//line web/template/home.qtpl:20
qw422016.E().S(p.Client.RedirectURI[i].String())
//line web/template/home.qtpl:19
//line web/template/home.qtpl:20
qw422016.N().S(`"> `)
//line web/template/home.qtpl:20
//line web/template/home.qtpl:21
}
//line web/template/home.qtpl:20
//line web/template/home.qtpl:21
qw422016.N().S(` `)
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
}
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
func (p *Home) WriteHead(qq422016 qtio422016.Writer) {
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
qw422016 := qt422016.AcquireWriter(qq422016)
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
p.StreamHead(qw422016)
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
qt422016.ReleaseWriter(qw422016)
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
}
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
func (p *Home) Head() string {
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
qb422016 := qt422016.AcquireByteBuffer()
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
p.WriteHead(qb422016)
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
qs422016 := string(qb422016.B)
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
qt422016.ReleaseByteBuffer(qb422016)
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
return qs422016
//line web/template/home.qtpl:21
//line web/template/home.qtpl:22
}
//line web/template/home.qtpl:23
//line web/template/home.qtpl:24
func (p *Home) StreamBody(qw422016 *qt422016.Writer) {
//line web/template/home.qtpl:23
//line web/template/home.qtpl:24
qw422016.N().S(` <header class="h-app h-x-app"> `)
//line web/template/home.qtpl:25
//line web/template/home.qtpl:26
if p.Client.Logo != nil {
//line web/template/home.qtpl:25
//line web/template/home.qtpl:26
qw422016.N().S(` <img class="u-logo" src="`)
//line web/template/home.qtpl:27
//line web/template/home.qtpl:28
qw422016.E().S(p.Client.Logo.String())
//line web/template/home.qtpl:27
//line web/template/home.qtpl:28
qw422016.N().S(`" alt="`)
//line web/template/home.qtpl:28
//line web/template/home.qtpl:29
qw422016.E().S(p.Client.Name)
//line web/template/home.qtpl:28
//line web/template/home.qtpl:29
qw422016.N().S(`" crossorigin="anonymous" decoding="async" height="140" importance="high" referrerpolicy="no-referrer-when-downgrade" width="140"> `)
//line web/template/home.qtpl:35
//line web/template/home.qtpl:36
}
//line web/template/home.qtpl:35
//line web/template/home.qtpl:36
qw422016.N().S(` <h1> <a class="p-name u-url" href="`)
//line web/template/home.qtpl:39
//line web/template/home.qtpl:40
qw422016.E().S(p.Client.URL.String())
//line web/template/home.qtpl:39
//line web/template/home.qtpl:40
qw422016.N().S(`"> `)
//line web/template/home.qtpl:41
//line web/template/home.qtpl:42
qw422016.E().S(p.Client.Name)
//line web/template/home.qtpl:41
//line web/template/home.qtpl:42
qw422016.N().S(` </a> </h1> </header> <main> <form class="" method="get" action="/authorize" enctype="application/x-www-form-urlencoded" accept-charset="utf-8" target="_self"> `)
//line web/template/home.qtpl:54
//line web/template/home.qtpl:55
for name, value := range map[string]string{
"client_id": p.Client.ID.String(),
"redirect_uri": p.Client.RedirectURI[0].String(),
"response_type": domain.ResponseTypeCode.String(),
"response_type": response.Code.String(),
"scope": domain.Scopes{domain.ScopeEmail, domain.ScopeProfile}.String(),
"state": p.State,
} {
//line web/template/home.qtpl:60
//line web/template/home.qtpl:61
qw422016.N().S(` <input type="hidden" name="`)
//line web/template/home.qtpl:62
//line web/template/home.qtpl:63
qw422016.E().S(name)
//line web/template/home.qtpl:62
//line web/template/home.qtpl:63
qw422016.N().S(`" value="`)
//line web/template/home.qtpl:63
//line web/template/home.qtpl:64
qw422016.E().S(value)
//line web/template/home.qtpl:63
//line web/template/home.qtpl:64
qw422016.N().S(`"> `)
//line web/template/home.qtpl:64
//line web/template/home.qtpl:65
}
//line web/template/home.qtpl:64
//line web/template/home.qtpl:65
qw422016.N().S(` <input type="url" name="me" placeholder="https://example.com/" inputmode="url" autocomplete="url" required> <button type="submit">`)
//line web/template/home.qtpl:73
//line web/template/home.qtpl:74
p.StreamT(qw422016, "Sign In")
//line web/template/home.qtpl:73
//line web/template/home.qtpl:74
qw422016.N().S(`</button> </form> </main> `)
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
}
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
func (p *Home) WriteBody(qq422016 qtio422016.Writer) {
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
qw422016 := qt422016.AcquireWriter(qq422016)
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
p.StreamBody(qw422016)
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
qt422016.ReleaseWriter(qw422016)
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
}
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
func (p *Home) Body() string {
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
qb422016 := qt422016.AcquireByteBuffer()
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
p.WriteBody(qb422016)
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
qs422016 := string(qb422016.B)
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
qt422016.ReleaseByteBuffer(qb422016)
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
return qs422016
//line web/template/home.qtpl:76
//line web/template/home.qtpl:77
}