2022-01-31 15:00:28 +00:00
|
|
|
package domain
|
|
|
|
|
2023-01-02 01:15:11 +00:00
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
"testing"
|
|
|
|
)
|
2022-02-15 20:07:39 +00:00
|
|
|
|
2022-01-31 15:00:28 +00:00
|
|
|
type Metadata struct {
|
|
|
|
// The server's issuer identifier. The issuer identifier is a URL that
|
|
|
|
// uses the "https" scheme and has no query or fragment components. The
|
|
|
|
// identifier MUST be a prefix of the indieauth-metadata URL. e.g. for
|
|
|
|
// an indieauth-metadata endpoint
|
|
|
|
// https://example.com/.well-known/oauth-authorization-server, the
|
|
|
|
// issuer URL could be https://example.com/, or for a metadata URL of
|
|
|
|
// https://example.com/wp-json/indieauth/1.0/metadata, the issuer URL
|
|
|
|
// could be https://example.com/wp-json/indieauth/1.0
|
2023-01-14 21:27:37 +00:00
|
|
|
Issuer *url.URL
|
2022-01-31 15:00:28 +00:00
|
|
|
|
|
|
|
// The Authorization Endpoint.
|
2023-01-02 01:15:11 +00:00
|
|
|
AuthorizationEndpoint *url.URL
|
2022-01-31 15:00:28 +00:00
|
|
|
|
|
|
|
// The Token Endpoint.
|
2023-01-02 01:15:11 +00:00
|
|
|
TokenEndpoint *url.URL
|
2022-02-17 15:12:34 +00:00
|
|
|
|
|
|
|
// The Ticket Endpoint.
|
2023-01-02 01:15:11 +00:00
|
|
|
TicketEndpoint *url.URL
|
2022-02-17 15:12:34 +00:00
|
|
|
|
|
|
|
// The Micropub Endpoint.
|
2023-01-02 01:15:11 +00:00
|
|
|
MicropubEndpoint *url.URL
|
2022-02-17 15:12:34 +00:00
|
|
|
|
|
|
|
// The Microsub Endpoint.
|
2023-01-02 01:15:11 +00:00
|
|
|
MicrosubEndpoint *url.URL
|
2022-02-17 15:12:34 +00:00
|
|
|
|
|
|
|
// The Introspection Endpoint.
|
2023-01-02 01:15:11 +00:00
|
|
|
IntrospectionEndpoint *url.URL
|
2022-02-17 15:12:34 +00:00
|
|
|
|
|
|
|
// The Revocation Endpoint.
|
2023-01-02 01:15:11 +00:00
|
|
|
RevocationEndpoint *url.URL
|
2022-02-17 15:12:34 +00:00
|
|
|
|
|
|
|
// The User Info Endpoint.
|
2023-01-02 01:15:11 +00:00
|
|
|
UserinfoEndpoint *url.URL
|
2022-02-17 15:12:34 +00:00
|
|
|
|
|
|
|
// URL of a page containing human-readable information that developers
|
|
|
|
// might need to know when using the server. This might be a link to the
|
|
|
|
// IndieAuth spec or something more personal to your implementation.
|
2023-01-02 01:15:11 +00:00
|
|
|
ServiceDocumentation *url.URL
|
2022-01-31 15:00:28 +00:00
|
|
|
|
|
|
|
// JSON array containing scope values supported by the IndieAuth server.
|
|
|
|
// Servers MAY choose not to advertise some supported scope values even
|
|
|
|
// when this parameter is used.
|
2022-02-17 15:12:34 +00:00
|
|
|
ScopesSupported Scopes
|
2022-01-31 15:00:28 +00:00
|
|
|
|
|
|
|
// JSON array containing the response_type values supported. This
|
|
|
|
// differs from RFC8414 in that this parameter is OPTIONAL and that, if
|
|
|
|
// omitted, the default is code.
|
2022-02-17 15:12:34 +00:00
|
|
|
ResponseTypesSupported []ResponseType
|
2022-01-31 15:00:28 +00:00
|
|
|
|
|
|
|
// JSON array containing grant type values supported. If omitted, the
|
|
|
|
// default value differs from RFC8414 and is authorization_code.
|
2022-02-17 15:12:34 +00:00
|
|
|
GrantTypesSupported []GrantType
|
2022-01-31 15:00:28 +00:00
|
|
|
|
|
|
|
// JSON array containing the methods supported for PKCE. This parameter
|
2023-07-06 23:11:53 +00:00
|
|
|
// differs from RFC8414 in that it is not optional as PKCE is REQUIRED.
|
2022-02-17 15:12:34 +00:00
|
|
|
CodeChallengeMethodsSupported []CodeChallengeMethod
|
|
|
|
|
|
|
|
// List of client authentication methods supported by this introspection endpoint.
|
|
|
|
IntrospectionEndpointAuthMethodsSupported []string // ["Bearer"]
|
|
|
|
|
|
|
|
RevocationEndpointAuthMethodsSupported []string // ["none"]
|
2022-01-31 15:00:28 +00:00
|
|
|
|
|
|
|
// Boolean parameter indicating whether the authorization server
|
|
|
|
// provides the iss parameter. If omitted, the default value is false.
|
|
|
|
// As the iss parameter is REQUIRED, this is provided for compatibility
|
|
|
|
// with OAuth 2.0 servers implementing the parameter.
|
2022-02-17 15:12:34 +00:00
|
|
|
AuthorizationResponseIssParameterSupported bool
|
2022-01-31 15:00:28 +00:00
|
|
|
}
|
2022-02-15 20:07:39 +00:00
|
|
|
|
|
|
|
// TestMetadata returns valid random generated Metadata for tests.
|
|
|
|
func TestMetadata(tb testing.TB) *Metadata {
|
|
|
|
tb.Helper()
|
|
|
|
|
|
|
|
return &Metadata{
|
2023-01-14 21:27:37 +00:00
|
|
|
Issuer: &url.URL{
|
|
|
|
Scheme: "https",
|
|
|
|
Host: "example.com",
|
|
|
|
Path: "/.well-known/oauth-authorization-server",
|
|
|
|
},
|
2023-01-02 01:15:11 +00:00
|
|
|
AuthorizationEndpoint: &url.URL{Scheme: "https", Host: "indieauth.example.com", Path: "/auth"},
|
|
|
|
TokenEndpoint: &url.URL{Scheme: "https", Host: "indieauth.example.com", Path: "/token"},
|
|
|
|
TicketEndpoint: &url.URL{Scheme: "https", Host: "auth.example.org", Path: "/ticket"},
|
|
|
|
MicropubEndpoint: &url.URL{Scheme: "https", Host: "micropub.example.com", Path: "/"},
|
|
|
|
MicrosubEndpoint: &url.URL{Scheme: "https", Host: "microsub.example.com", Path: "/"},
|
|
|
|
IntrospectionEndpoint: &url.URL{Scheme: "https", Host: "indieauth.example.com", Path: "/introspect"},
|
|
|
|
RevocationEndpoint: &url.URL{Scheme: "https", Host: "indieauth.example.com", Path: "/revocation"},
|
|
|
|
UserinfoEndpoint: &url.URL{Scheme: "https", Host: "indieauth.example.com", Path: "/userinfo"},
|
|
|
|
ServiceDocumentation: &url.URL{Scheme: "https", Host: "indieauth.net", Path: "/draft/"},
|
2022-02-15 20:07:39 +00:00
|
|
|
ScopesSupported: Scopes{
|
|
|
|
ScopeBlock,
|
|
|
|
ScopeChannels,
|
|
|
|
ScopeCreate,
|
|
|
|
ScopeDelete,
|
|
|
|
ScopeDraft,
|
|
|
|
ScopeEmail,
|
|
|
|
ScopeFollow,
|
|
|
|
ScopeMedia,
|
|
|
|
ScopeMute,
|
|
|
|
ScopeProfile,
|
|
|
|
ScopeRead,
|
|
|
|
ScopeUpdate,
|
|
|
|
},
|
|
|
|
ResponseTypesSupported: []ResponseType{
|
|
|
|
ResponseTypeCode,
|
|
|
|
ResponseTypeID,
|
|
|
|
},
|
|
|
|
GrantTypesSupported: []GrantType{
|
|
|
|
GrantTypeAuthorizationCode,
|
|
|
|
GrantTypeTicket,
|
|
|
|
},
|
|
|
|
CodeChallengeMethodsSupported: []CodeChallengeMethod{
|
|
|
|
CodeChallengeMethodMD5,
|
|
|
|
CodeChallengeMethodPLAIN,
|
|
|
|
CodeChallengeMethodS1,
|
|
|
|
CodeChallengeMethodS256,
|
|
|
|
CodeChallengeMethodS512,
|
|
|
|
},
|
2022-02-17 15:12:34 +00:00
|
|
|
IntrospectionEndpointAuthMethodsSupported: []string{"Bearer"},
|
|
|
|
RevocationEndpointAuthMethodsSupported: []string{"none"},
|
2022-02-15 20:07:39 +00:00
|
|
|
AuthorizationResponseIssParameterSupported: true,
|
|
|
|
}
|
|
|
|
}
|