概要
Firebase Authenticationを使用して、@keio.jpドメイン制限付きの認証システムを実装する。
前提条件
タスク一覧
1. Firebase Authentication プロバイダー設定
2. AuthService の実装
3. AuthGuard の実装
4. 認証コンポーネントの作成
5. ユーザー管理の基盤
実装仕様
AuthService の主要メソッド
@Injectable({ providedIn: 'root' })
export class AuthService {
user$ = this.afAuth.authState;
async signInWithGoogle(): Promise<void>
async signOut(): Promise<void>
private validateKeioEmail(email: string): boolean
getCurrentUser(): Observable<User | null>
}
ドメイン制限ロジック
private validateKeioEmail(email: string): boolean {
return email.endsWith('@keio.jp');
}
async signInWithGoogle() {
const result = await this.afAuth.signInWithPopup(new GoogleAuthProvider());
if (\!this.validateKeioEmail(result.user?.email || '')) {
await this.signOut();
throw new Error('慶應義塾大学のメールアドレスでログインしてください');
}
}
Firestore Security Rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isKeioUser() {
return request.auth \!= null &&
request.auth.token.email.matches('.*@keio.jp');
}
match /users/{userId} {
allow read, write: if isKeioUser() && request.auth.uid == userId;
}
match /subjects/{subjectId} {
allow read: if isKeioUser();
allow write: if false; // 管理者のみ
}
}
}
UI/UX 要件
Acceptance Criteria
テスト項目
セキュリティ考慮事項
参照
次のステップ
Issue #5: 環境変数・セキュリティ設定の完了確認
概要
Firebase Authenticationを使用して、@keio.jpドメイン制限付きの認証システムを実装する。
前提条件
タスク一覧
1. Firebase Authentication プロバイダー設定
2. AuthService の実装
src/app/core/auth/auth.service.tsの作成3. AuthGuard の実装
src/app/core/guards/auth.guard.tsの作成4. 認証コンポーネントの作成
src/app/features/auth/login/login.component.tsの作成5. ユーザー管理の基盤
src/app/core/services/user.service.tsの作成実装仕様
AuthService の主要メソッド
ドメイン制限ロジック
Firestore Security Rules
UI/UX 要件
Acceptance Criteria
テスト項目
セキュリティ考慮事項
参照
次のステップ
Issue #5: 環境変数・セキュリティ設定の完了確認