4

Angular Authentication: Best Practices ๐Ÿ†

 2 years ago
source link: https://dev.to/nikosanif/angular-authentication-best-practices-3h8h
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

An Angular application that demonstrates best practices for user authentication flow.

By @nikosanif

GitHub logo nikosanif / angular-authentication

An Angular application that demonstrates best practices for user authentication.

Angular Authentication

An Angular application that demonstrates best practices for user authentication flow.

By @nikosanif

Table of Contents

Live Demo

Live application: angular-authentication.netlify.app

Getting Started

Prerequisites

Setup & Usage

  • Clone this repository: git clone [email protected]:nikosanif/angular-authentication.git
  • cd angular-authentication
  • Install dependencies: npm install
  • Serve the Angular app: npm start
  • Open your browser at: http://localhost:4200

Useful Commands

  • npm start - starts a dev server of Angular app
  • npm run build - builds full prod build
  • npm run lint - linting source code of this project
  • npm run format:check - runs prettier to check for formatting errors
  • npm run format:write - runs prettier to format whole code base
  • npm run release - runs standard-version to create new release

Features

Authentication Flows

Other Features

  • Lazy loading of Angular modules
  • API requests with @ngrx/effects
  • Responsive design
  • In-memory Web API

Tech Stack

Live Demo

Live application: angular-authentication.netlify.app

Getting Started

Prerequisites

Setup & Usage

  • Clone this repository: git clone [email protected]:nikosanif/angular-authentication.git
  • cd angular-authentication
  • Install dependencies: npm install
  • Serve the Angular app: npm start
  • Open your browser at: http://localhost:4200

Useful Commands

  • npm start - starts a dev server of Angular app
  • npm run build - builds full prod build
  • npm run lint - linting source code of this project
  • npm run format:check - runs prettier to check for formatting errors
  • npm run format:write - runs prettier to format whole code base
  • npm run release - runs standard-version to create new release

Features

Authentication Flows

Other Features

  • Lazy loading of Angular modules
  • API requests with @ngrx/effects
  • Responsive design
  • In-memory Web API

Tech Stack

High-level Design

Below is the high-level structure of the application.

./src
โ”œโ”€โ”€ app
โ”‚   โ”œโ”€โ”€ app # root app component
โ”‚   โ”‚   โ”œโ”€โ”€ app.component.html
โ”‚   โ”‚   โ”œโ”€โ”€ app.component.scss
โ”‚   โ”‚   โ””โ”€โ”€ app.component.ts
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ app-routing.module.ts
โ”‚   โ”œโ”€โ”€ app.module.ts
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ auth # includes authentication logic
โ”‚   โ”‚   โ”œโ”€โ”€ auth.module.ts
โ”‚   โ”‚   โ”œโ”€โ”€ auth.service.ts
โ”‚   โ”‚   โ”œโ”€โ”€ guards
โ”‚   โ”‚   โ”œโ”€โ”€ interceptors
โ”‚   โ”‚   โ”œโ”€โ”€ login
โ”‚   โ”‚   โ””โ”€โ”€ store
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ core # includes core utilities
โ”‚   โ”‚   โ”œโ”€โ”€ core.module.ts
โ”‚   โ”‚   โ”œโ”€โ”€ fake-api
โ”‚   โ”‚   โ””โ”€โ”€ services
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ features # all features of application
โ”‚   โ”‚   โ”œโ”€โ”€ about
โ”‚   โ”‚   โ”œโ”€โ”€ home
โ”‚   โ”‚   โ””โ”€โ”€ secured-feat
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ shared # shared UI modules and utilities
โ”‚       โ”œโ”€โ”€ ui
โ”‚       โ””โ”€โ”€ util
โ”‚
โ”œโ”€โ”€ assets
โ”‚   โ”œโ”€โ”€ ...
โ”‚
โ”œโ”€โ”€ environments
โ”‚   โ”œโ”€โ”€ environment.prod.ts
โ”‚   โ””โ”€โ”€ environment.ts
โ”‚
โ”œโ”€โ”€ ...
โ”‚
โ””โ”€โ”€ theme # global theme styles
    โ”œโ”€โ”€ _components.scss
    โ”œโ”€โ”€ _typography.scss
    โ””โ”€โ”€ index.scss
Enter fullscreen modeExit fullscreen mode

Contributing

Who is for this? I would love for you to contribute to Angular Authentication! Before you start, please read the Contributor Guide.

If you have found any bug in the source code or want to request a new feature, you can help by submitting an issue at GitHub. Even better, you can fork this repository and submit a PR with the fix or the new feature description.

Support

  • Star this repository โญ๏ธ
  • Help it spread to a wider audience: Tweet

Author: Nikos Anifantis โœ๏ธ

  • Fullstack Software Engineer - Iโ€™m currently working on Angular & Node.js application development.
  • I write stuff at dev.to/nikosanif and nikosanif.medium.com
  • How to reach me:

License

Feel free to use this repository, but please star and put a reference to this repository. ๐Ÿ™ โค๏ธ

MIT

Discussion (2)

pic

CollapseExpand

That's very helpful, will definitely implement it

Thanks for sharing!

Comment button Reply

CollapseExpand

Author

โ€ข

Nov 11

Thanks for your feedback! I am very happy to hear that! ๐Ÿคฉ

Comment button Reply


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK