Skip to content

Commit

Permalink
Switch to using FedCM IdP type matching
Browse files Browse the repository at this point in the history
  • Loading branch information
anderspitman committed Jun 14, 2024
1 parent 81114c6 commit 1874f40
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions fedcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ type FedCmWebId struct {
}

type FedCmConfig struct {
AccountsEndpoint string `json:"accounts_endpoint,omitempty"`
ClientMetadataEndpoint string `json:"client_metadata_endpoint,omitempty"`
IdAssertionEndpoint string `json:"id_assertion_endpoint,omitempty"`
LoginUrl string `json:"login_url,omitempty"`
AccountsEndpoint string `json:"accounts_endpoint,omitempty"`
ClientMetadataEndpoint string `json:"client_metadata_endpoint,omitempty"`
IdAssertionEndpoint string `json:"id_assertion_endpoint,omitempty"`
LoginUrl string `json:"login_url,omitempty"`
Types []string `json:"types"`
}

type FedCmAccounts struct {
Expand Down Expand Up @@ -108,6 +109,9 @@ func NewFedCmHandler(db *Database, storage Storage, loginEndpoint string) *FedCm
//ClientMetadataEndpoint: fmt.Sprintf("%s/fedcm/client-metadata", uri),
IdAssertionEndpoint: fmt.Sprintf("%s/fedcm/id-assertion", uri),
LoginUrl: fmt.Sprintf("%s%s", uri, loginEndpoint),
Types: []string{
"indieauth",
},
}

w.Header().Set("Content-Type", "application/json")
Expand Down
2 changes: 1 addition & 1 deletion templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
return raw ? parseInt(raw[2], 10) : false;
}

if (window["IdentityProvider"] && IdentityProvider.register != undefined && getChromeVersion() >= 126) {
if (window["IdentityProvider"] && IdentityProvider.register != undefined && getChromeVersion() >= 128) {
const fedcmBtn = document.getElementById('og-register-fedcm-button');
fedcmBtn.classList.remove('og-remove');
fedcmBtn.addEventListener('click', () => {
Expand Down
3 changes: 2 additions & 1 deletion templates/login-fedcm.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
context: "signin",
providers: [
{
configURL: "any",
configURL: 'any',
type: "indieauth",
clientId: window.location.origin,
nonce: "fake-nonce",
},
Expand Down

0 comments on commit 1874f40

Please sign in to comment.