GithubHelp home page GithubHelp logo

giovannicandido / angular-spa Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 4.0 448 KB

Angular security, logger, components and other stuff that makes professional Single Pages Application awesome.

License: MIT License

JavaScript 12.04% TypeScript 87.96%
angular single-page-app

angular-spa's People

Contributors

giovannicandido avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

angular-spa's Issues

Logger module

Finish the logger module and document the usage

  • Plug in message storage
  • Cache messages before sending back to storage (could be a cloud storage or a do it yourself internal service). This makes the module resilent to network conditions.
  • Provide events to developers like: onErrorLogged, onSyncStart, onSyncEnd. This could be used for nice user feedback.
  • Global error interceptor (Investigate angular for this)

Security Directives not updating in all components

Suppose we have a topbar and two routes:

  • home
  • profile

Profiles is protected, home is not
top bar is part of app

Problem: The security directives work only inside profile, if topbar has directives it is not updated.
Looks like databind between AuthService (where login and logout is stored) and the directives is not trigged in some situation.

Needs investigation and tests

Docs: Keycloak Listener

Document keycloak listener.

Before I would like to think if this listerner should be maintained because someone could inject the AuthService and listen to the events.

Docs: Account

Document Account class.

Before that, getLoginAccount() return a keycloak JSON object and not a Account object. The methods: isAccountInRole(role: string) and *hasAuthority(authority: string): boolean * are not present

Role based authentication directives

Provide API's and directives to hide information based on security credentials

Proposal

As a developer, I would like to query information about the current user and:

  • Hide or display an element from the DOM
  • Apply a class to an element on the DOM

The type of queries I would like:

  • User is authenticated
  • User is not authenticated
  • User is part of a ROLE
  • User is part of any ROLE (list of roles)
  • User is part of all ROLES (list of roles)
    I would also like to Negate the expression (like user on any role except this ones)

This requirement focus on ROLE base authentication. For fine granted permissions, keycloak has Authorization services that enforce polices, which is way more flexible. See: https://keycloak.gitbooks.io/documentation/authorization_services/topics/overview/overview.html

A new feature must be open to provide integration with the authorization services of keycloak.

Syntax

  • secIsAuthenticated
  • secIsNotAuthenticated
  • secHasRole="ROLE_NAME"
  • secHasAllRoles="ROLE_NAME, ROLE_NAME"
  • secHasAnyRoles="ROLE_NAME, ROLE_NAME"
  • secHasNotRoles="ROLE_NAME, ROLE_NAME"

Every directive has the configurations:

  • secAction - The action to perform. Allowed values: hide, remove, addClass
  • secClass - The class to be added, you don't need to specify secAction="addClass"

The configuration is tracked by #11

Examples:

<p secIsNotAuthenticated></p> <!-- Hide element from dom if user is not authenticated -->
<p secHasRole="ADMIN" secClass="green"></p> <!-- add class green if user has role ADMIN -->
<p secHasRole="ADMIN" secAction="remove"></p> <!-- remove the element from DOM if user has role ADMIN -->
<p secHasNotRoles="ADMIN" secClass="disabled"></p> <!-- add class disabled if user has role ADMIN -->

LoginGuard refresh performance

When refreshing browser the route LoginGuard takes a time to get the state of logged user, and looks like is refreshing the page more then once?

Investigate how to keep that super fast, this is annoying while developing.

Review KeycloakListener and saveToken method

KeycloakListener is saving the token with sessionStorage, but this saved token is used nowhere.

Maybe if the token is used to not initiate a new login on every page refresh...

Report Component

A modern report component module, that generates views to export in PDF.

The idea is a alternative to JasperReports (without the IDE).

Possible features:

  • Master template file
  • Orientation (vertical horizontal)
  • Support for different paper sizes (A4, A3 etc...)
  • Diferent styles
  • Common sections (header, footer, detail, etc..)
  • Different datasources
  • Different format exports (excel, CVS)

checkLoginIframe cause angular zone and application to stop working

When using checkLoginIframe keycloak try to load a iframe page. If that operation return 400 the entire application stops.

Error:

TypeError: Cannot read property 'originalError' of undefined

The library should wrap errors operations and handle it to not break angular.

Dynamic configuration

Problem: Some apps need access to configuration variables that are in the environment, for example: URL for the api server in a cloud or docker cluster, keycloak url, realm and clientId.

This are not so much sensitive data, but are dynamic.

A nice solution would be to expose env variables to the client, that way the container could override the variable on startup and the client will pick up.

This feature need support from the server.

Auth does not return a Account object

getLoginAccount() return a keycloak JSON object and not a Account object. The methods: isAccountInRole(role: string) and *hasAuthority(authority: string): boolean * are not present

VM2081:1 GET http://localhost:9080/auth/realms/master/protocol/openid-connect/login-status-iframe.html

When keycloak is not online injecting AuthService cause the issue:

VM2081:1 GET http://localhost:9080/auth/realms/master/protocol/openid-connect/login-status-iframe.html

VM2081:1 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost:9080') does not match the recipient window's origin ('null').l @ VM2081:1(anonymous function) @ VM2081:1setSuccess @ VM2081:1C.onload @ VM2081:1wrapFn @ zone.js:698ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154ZoneTask.invoke @ zone.js:335

This makes all aplication to stop working, as angular zone is not protected against exceptions.

The solution is make keycloak run outside the zone

Docs: keycloak.js is included in dependencies

Keycloak.js is included in dependencies, but the docs say its not.

This module depends on keycloak.js javascript adapter, which is not included as a dependency, because you have many options in how to add it.

Create a AuthTestingModule

To facilitate writing tests, inspired on RouterTestingModule from angular.

This should:

  • Provide a fake AuthService
  • API to fake user and roles

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.