Skip to content

Commit

Permalink
Merge pull request #135 from solid/revert-134-133
Browse files Browse the repository at this point in the history
Revert "Solves #133: add client_name, logo_uri and contacts fields to client …"
  • Loading branch information
jaxoncreed committed Oct 21, 2019
2 parents 2009db9 + 093fa22 commit c528f3c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 80 deletions.
25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,31 +155,6 @@ and emits the following events:
- `logout ()` when a user logs out
- `session (session: Session | null)` when a user logs in or out

### Client registration

`SolidAuthClient` automatically registers your OIDC client application if it is
unknown to the authorization server, following
[the registration request spec](https://openid.net/specs/openid-connect-registration-1_0.html#RegistrationRequest).

You can specify some fields of this registration request by passing them to the
`loginSession` parameter of `solid.auth.login`.

Supported fields are:

* `client_name` and internationalized variants (`clientName` property)
* `contacts` (`contacts` property)
* `logo_uri` (`contacts` property)

**Example**:

```js
solid.auth.login(idp, {
clientName: 'My Example',
'clientName#ja-Jpan-JP': 'クライアント名',
logoUri: 'https://client.example.org/logo.png',
contacts: ['ve7jtb@example.org', 'mary@example.org']
})
````

## Advanced usage

Expand Down
30 changes: 0 additions & 30 deletions src/__test__/solid-auth-client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,36 +195,6 @@ describe('login', () => {
expect(location.searchParams.get('scope')).toEqual('openid')
expect(location.searchParams.get('client_id')).toEqual('the-client-id')
})

it('performs the client registration the the correct provided registration parameters', async () => {
let requestBody = {}
nock('https://localhost/')
.get('/.well-known/openid-configuration')
.reply(200, oidcConfiguration)
.get('/jwks')
.reply(200, jwks)
.post('/register', body => {
requestBody = body
return true
})
.reply(200, oidcRegistration)

await instance.login('https://localhost', {
clientName: 'My Example',
'clientName#ja-Jpan-JP': 'クライアント名',
logoUri: 'https://client.example.org/logo.png',
contacts: ['ve7jtb@example.org', 'mary@example.org']
})

expect(requestBody).toMatchObject({
client_name: 'My Example',
'client_name#ja-Jpan-JP': 'クライアント名',
contacts: ['ve7jtb@example.org', 'mary@example.org'],
logo_uri: 'https://client.example.org/logo.png'
})

expect.assertions(1)
})
})
})

Expand Down
3 changes: 0 additions & 3 deletions src/solid-auth-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const globalFetch = fetch

export type loginOptions = {
callbackUri: string,
clientName?: string,
contacts?: Array<string>,
logoUri?: string,
popupUri: string,
storage: AsyncStorage
}
Expand Down
27 changes: 5 additions & 22 deletions src/webid-oidc.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,34 +125,18 @@ async function storeRp(
return rp
}

function registerRp(idp: string, opts: loginOptions): Promise<RelyingParty> {
const { storage, callbackUri } = opts
function registerRp(
idp: string,
{ storage, callbackUri }: loginOptions
): Promise<RelyingParty> {
const responseType = 'id_token token'

const clientNameI18n = {}
Object.entries(opts)
.filter(([key, _]) => key.startsWith('clientName#'))
.forEach(
([key, value]) =>
(clientNameI18n[key.replace('clientName#', 'client_name#')] = value)
)

const supplementaryOptions = {
logo_uri: opts.logoUri,
contacts: opts.contacts,
client_name: opts.clientName
}

const registration = {
issuer: idp,
grant_types: ['implicit'],
redirect_uris: [callbackUri],
response_types: [responseType],
scope: 'openid profile',
...clientNameI18n,
...supplementaryOptions
scope: 'openid profile'
}

const options = {
defaults: {
authenticate: {
Expand All @@ -162,7 +146,6 @@ function registerRp(idp: string, opts: loginOptions): Promise<RelyingParty> {
},
store: storage
}

return RelyingParty.register(idp, registration, options)
}

Expand Down

0 comments on commit c528f3c

Please sign in to comment.