Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
angular-eha.couchdb-auth
Advanced tools
A simple Angular.js CouchDB auth interface. Works great directly with a CouchDB instance, works even better with a CouchDB proxy/wrapper API.
Install with npm:
npm install --save angular-eha.couchdb-auth
Or alternatively bower:
bower install --save angular-eha.couchdb-auth
If you're using wiredep, then all you need to do is add eha.couchdb-auth
as an angular module dependency somewhere sensible in your app. In the absense of wiredep, you'll need to manually bundle dist/couchdb-auth.js
.
The module can be configured through the ehaCouchDbAuthServiceProvider
via a config
block:
app.config(function(ehaCouchDbAuthServiceProvider) {
ehaCouchDbAuthServiceProvider.config({
url: 'http://mycouchdb.com', // CouchDB/Proxy URL exposing _session endpoints
localStorageNamespace: 'mnutrition', // Namespace for localstorage (default: lf)
adminRoles: ['admin'], // 'Admin' CouchDB role. (default: `['_admin']`)
userRoles: ['data_provider', 'analyst'],// Roles other than admin roles
interceptor: { // Enable HTTP Interceptor (default: false)
hosts: [ // Configure hostnames that should be intercepted
'http://mycouchdb.com'
]
}
});
});
Note: userRoles
can be camelcase, or hyphenized strings (with '_' or '-' but not with both).
signIn(params)
Promise/A+ Attempt to create a new CouchDB session with given credentials.
name
password
signOut()
Promise/A+ Attempt to destroy a CouchDB sessions and reset local authenitcation status.
resetPassword(params)
Promise/A+ Password reset features. Typical pattern; request reset token by email, follow link, change password.
n.b. CouchDB does not provide this functionality. To leverage this functionality you require a compatible 'backend'
resetToken
should be appended to in order to complete the flowresetToken
Calling resetPassword()
with email
and callbackUrl
parameters will initiate the password reset token request flow.
Calling resetPassword()
with a valid token
and a new password
will initiate the change password flow.
getSession()
Promise/A+ Makes a GET request to the _session/
endpoint of the CouchDB url provided during configuration. Returns a promise.
getCurrentUser()
Promise/A+ Checks the local environment for a user, failing that checks local storage and finally attempts to GET the _session/
endpoint of the CouchDB url.
Returns a promise
on(EVENT, handler)
Event subscription handler
unauthenticated
- fired whenever an unauthenticated user / session attempts to access a resource that requires authentication.unauthorized
- fired whenever the current user / session is unauthorised to access a resourceauthenticationStateChange
- fired whenever there is a change in authenticate state.requireAdminUser
Promise/A+ Check if the user is an admin (has one of the adminRoles
provided in the config).
require<role-name>User
E.g. the function for the data_provider
role will be requireDataProviderUser
.
Promise/A+ Check if the user has a particular role.
Note: These functions are created dynamically during the configuration of the module. These can cause problems when using the function within angular-ui-router
if the routes are loaded before configuring the module. This can be avoided by providing the configuration for the roles when initializing the routes:
.config(function($stateProvider, ehaCouchDbAuthServiceProvider) {
ehaCouchDbAuthServiceProvider.config({
userRoles: [
'data_provider',
'analyst'
]
});
$stateProvider
.state('upload', {
url: '/upload',
resolve: {
isDataProvider: ehaCouchDbAuthServiceProvider.requireDataProviderUser
},
views: {
...
}
});
}
requireAuthenticatedUser
Promise/A+ Check if the user is authenticated.
eha-show-authenticated
directiveA simple directive to hide dom elements and show only for authenticated sessions.
e.g:
<div eha-show-authenticated>Only show me for authenticated sessions</div>
eha-show-for-role
directiveA simple directive to hide/show dom elements for users depending on their access control (role) level. Accepts either a single string or an array of strings.
e.g:
<!-- single string. must be an expression. n.b. `'`s are required -->
<div eha-show-for-role="'admin'"></div>
<!-- an array of strings -->
<div eha-show-for-role="['role1', 'role2']"></div>
Copyright 2015 Matt Richards matt.richards@ehealthnigeria.org
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
CouchDB auth wrapper
We found that angular-eha.couchdb-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.