From eb884721bb35dc19d0f2e8edc0033621493b752f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:08:28 +0900 Subject: [PATCH] =?UTF-8?q?enhance(SSO):=20Attribute=E3=81=AE=E8=AA=BF?= =?UTF-8?q?=E6=95=B4=20(MisskeyIO#555)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/sso/JWTIdentifyProviderService.ts | 4 +++- .../server/sso/SAMLIdentifyProviderService.ts | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/server/sso/JWTIdentifyProviderService.ts b/packages/backend/src/server/sso/JWTIdentifyProviderService.ts index 182b6af04..2671a7fcb 100644 --- a/packages/backend/src/server/sso/JWTIdentifyProviderService.ts +++ b/packages/backend/src/server/sso/JWTIdentifyProviderService.ts @@ -172,7 +172,9 @@ export class JWTIdentifyProviderService { const roles = await this.roleService.getUserRoles(user.id); const payload: JWTPayload = { - name: user.name ?? user.username, + name: user.name ? `${user.name} (@${user.username})` : `@${user.username}`, + given_name: user.name ?? undefined, + family_name: `@${user.username}`, preferred_username: user.username, profile: `${this.config.url}/@${user.username}`, picture: user.avatarUrl ?? undefined, diff --git a/packages/backend/src/server/sso/SAMLIdentifyProviderService.ts b/packages/backend/src/server/sso/SAMLIdentifyProviderService.ts index 96c32291f..15ca1eecc 100644 --- a/packages/backend/src/server/sso/SAMLIdentifyProviderService.ts +++ b/packages/backend/src/server/sso/SAMLIdentifyProviderService.ts @@ -492,20 +492,28 @@ export class SAMLIdentifyProviderService { '#text': user.id, }, }, - { - '@Name': 'displayname', + ...(user.name ? [{ + '@Name': 'firstName', '@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', 'saml:AttributeValue': { '@xsi:type': 'xs:string', - '#text': user.name ?? user.username, + '#text': user.name, + }, + }] : []), + { + '@Name': 'lastName', + '@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', + 'saml:AttributeValue': { + '@xsi:type': 'xs:string', + '#text': `@${user.username}`, }, }, { - '@Name': 'name', + '@Name': 'displayName', '@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', 'saml:AttributeValue': { '@xsi:type': 'xs:string', - '#text': user.username, + '#text': user.name ? `${user.name} (@${user.username})` : `@${user.username}`, }, }, {