In freeradius, is there a way to refer to LDAP attributes in post-auth section? - ldap

We're using PEAP with mschapv2 using ntlm command line. We want to assign users ip's from LDAP
After we get a reply back from ActiveDirectory, we're doing an authorization check by binding to LDAP and looking at their groups:
post-auth {
if (network-auth-LDAP-Group == "xxxcompany-vpn") {
noop
} else {
reject
}
Post-Auth-Type REJECT {
attr_filter.access_reject
}
}
We'd like to pull 10.1.2.3 from an LDAP Attribute. We tried doing what the documentation says by putting this in the LDAP config:
update {
reply:Framed-IP-Address := 'radiusFramedIPAddress'
}
In LDAP, we imported the schema and set radiusFramedIPAddress on the user to 10.1.2.3
However, we can't see the Framed-IP-Address value being updated in the log.
We'd like to set Framed-Ip-Address on the reply:
post-auth {
if (network-auth-LDAP-Group == "xxxcompany-vpn") {
update reply {
Framed-Ip-Address := 10.1.2.3
}
} else {
reject
}
Post-Auth-Type REJECT {
attr_filter.access_reject
}
}
That works however ^ Is there a way to refer to LDAP attributes in the post-auth section? Something like this?
post-auth {
if (network-auth-LDAP-Group == "xxxcompany-vpn") {
update reply {
Framed-Ip-Address := %{ldap:'radiusFramedIpAddress'}
}
} else {
reject
}
Post-Auth-Type REJECT {
attr_filter.access_reject
}
}

Related

Can you include an attributes based on type in GraphQL?

I have this GraphQL query which retrieved the pull requests' 3 types of timeline items from Github API. Within each type alias that I have(dismissed as an example) I'm getting all the other types but as empty objects(because I'm not querying any field in case it's not from the type I want) is there a way to exclude objects that aren't of the types I needed, maybe something like #include if(__typename = something)
query ($name: String!, $owner: String!, $pr: Int!) {
repository(name: $name, owner: $owner) {
pullRequest(number: $pr) {
timelineItems(first: 100) {
dismissed: nodes {
... on ReviewDismissedEvent {
actor {
login
}
review {
author {
login
}
}
}
}
removed: nodes {
... on ReviewRequestRemovedEvent {
actor {
login
}
requestedReviewer {
... on User {
name
login
id
}
}
}
}
added: nodes {
... on ReviewRequestedEvent {
actor {
login
}
requestedReviewer {
... on User {
name
login
id
}
}
}
}
}
}
}
}

How to synchronize Azure Mobile Services Offline Sync from an Xamarin app

previously, there was the possibility of creating an app services in azure that allowed you to connect an SQL database through the creation of "Easy Tables" but this will be deleted on November 11 (https://aka.ms/easydeprecation), but you can no longer add more tables this way, but you have to do it by the App Service Editor (preliminary version).
I can create the table as the link attached says, the problem is that when I synchronize my data from my xamarin app it says that the resource does not exist or has been removed, that it has been changed or that it is temporarily unavailable.
I think the problem is some configuration or package or extension that I must install in this new app services but I cannot identify it.
My code C #
public async Task SyncAllAsync(bool SyncForce = false)
{
ReadOnlyCollection<MobileServiceTableOperationError> syncErrors = null;
long PendingChanges = CurrentClient.SyncContext.PendingOperations;
try
{
await CurrentClient.SyncContext.PushAsync();
await PatientTable.PullAsync("SyncPatientAsync", PatientTable.CreateQuery());
}
catch (MobileServicePushFailedException exc)
{
if (exc.PushResult != null)
{
syncErrors = exc.PushResult.Errors;
}
}
// Simple error/conflict handling. A real application would handle the various errors like network conditions,
// server conflicts and others via the IMobileServiceSyncHandler.
if (syncErrors != null)
{
foreach (MobileServiceTableOperationError error in syncErrors)
{
if (error.OperationKind == MobileServiceTableOperationKind.Update && error.Result != null)
{
//Update failed, reverting to server's copy.
await error.CancelAndUpdateItemAsync(error.Result);
}
else
{
// Discard local change.
await error.CancelAndDiscardItemAsync();
}
string message = "Error executing sync operation. Item: " + error.TableName + " (" + error.Item["id"] + "). Operation discarded.";
Debug.WriteLine(message);
}
}
}
Patient.json
{
"softDelete" : true,
"autoIncrement": false,
"insert": {
"access": "anonymous"
},
"update": {
"access": "anonymous"
},
"delete": {
"access": "anonymous"
},
"read": {
"access": "anonymous"
},
"undelete": {
"access": "anonymous"
}}
Patient.js
var table = module.exports = require('azure-mobile-apps').table();
// table.read(function (context) {
// return context.execute();
// });
// table.read.use(customMiddleware, table.operation);
The Easy Tables is just a Web API - each table is at https://yoursite.azurewebsites.net/tables/yourtable and the pull operation basically does something like GET https://yoursite.azurewebsites.net/tables/yourtable?filter=(UpdatedAt ge datetimeoffset'some-iso-date'). Enable logging on your Xamarin host (details here plus the end of the same file) to see the actual HTTP requests that are happening.
The error you are receiving is probably a 404. Common issues:
You specified http instead of https in the client
The name of the table is wrong

How do I write a Firebase security rule where unauthenticated users can write but only my trusted server can read?

I would like to write a rule where persons submitting a form from the webpage (unauthenticated) can .write and only the server can .read messages that are newer than two minutes old.
The server (App Engine Python-Flask instance) polls Firebase every two minutes., but I keep getting a JSON feedback {error: Permission Denied}, instead of my requested data.
The Security Rules look like this:
{
"rules": {
"leads": {
".write": true,
"$user_id": {
".write": true,
".read": "auth !== null && $user_id === auth.uid && data.child('CREATED').val() > (now - 120000)"
}
}
}
}
The simulator tells me:
Attempt to read /leads with auth={"provider":"custom","uid":"lead_checker"}
/
/leads
No .read rule allowed the operation.
Read was denied.
Can anyone spot what I am doing wrong or provide a suitable replacement?
When you have a clause like $user_id === auth.uid in your read rule, it says: this data can be read when the current user's uid matches the node name. So for your user lead_checker is means that it can read the node named lead_checker.
What you're probably looking to do is to allow lead_checker read access to each user node:
{
"rules": {
"leads": {
"$user_id": {
".write": true,
".read": "auth.uid == 'lead_checker'"
}
}
}
}
With this the lead checker can reach each node under leads. Note that it still can't read the leads node itself. If that is needed, move the read rule one level up:
{
"rules": {
"leads": {
".read": "auth.uid == 'lead_checker'"
"$user_id": {
".write": true,
}
}
}
}

How do I define the response to a missing claim in NancyFX?

I have a module meant to enable administrators to manage users. Of course, this module requires not only authentication but also a specific claim. I have discovered that, if you are missing the claim in question, you actually get only a blank page as a response to your request. This isn't ideal.
How can I change that?
Module code below (if anyone needs to look)...
public class UserModule : NancyModule
{
public UserModule()
: base("/users")
{
this.RequiresAnyClaim(new[] { "evil-dictator" });
Get["/"] = _ =>
{
ViewBag.UserName = Context.CurrentUser.UserName;
return Negotiate.WithView("Index");
};
// Generate an invitation for a pre-approved user
Get["/invite"] = _ =>
{
throw new NotImplementedException();
};
}
}
You can use an After hook to alter the response in case the claim is missing. Note that the response you get when you do not have the required claim has HTTP status code 403 Forbidden. Check for that in the After hook and alter the response as needed.
E.g. the following will redirect to the root - "/" - of the application, when the user does have the evil dictator claim:
public class UserModule : NancyModule
{
public UserModule()
: base("/users")
{
After += context =>
{
if (ctx.Response.StatusCode == HttpStatusCode.Forbidden)
ctx.Response = this.Response.AsRedirect("/");
}
this.RequiresAnyClaim(new[] { "evil-dictator" });
Get["/"] = _ =>
{
ViewBag.UserName = Context.CurrentUser.UserName;
return Negotiate.WithView("Index");
};
// Generate an invitation for a pre-approved user
Get["/invite"] = _ =>
{
throw new NotImplementedException();
};
}
}

Add Login provider to meteor

I need to use an in-house user management system to authenticate my users. This system also holds the user's membership to groups and roles and tenants which is most useful when doing the authorization stuff.
I looked at the code for accounts-persona but it does not work for me. Hence I deduce that I am doing something wrong.
On the server there is a new LoginHandler:
Meteor.startup( function () {
var config = Accounts.loginServiceConfiguration.findOne( {service: 'sertal'} );
if ( !config ) {
Accounts.loginServiceConfiguration.insert( { service: 'sertal' } );
}
} );
Accounts.registerLoginHandler( function ( options ) {
if ( !options.sertal && !options.assertion )
return undefined; // don't handle
var url = "http://dev.sertal.ch/checkCredential";
var request = {
params: {
uname: options.email,
pword: options.password
}
};
var result = Meteor.http.get( url, request );
if ( result.statusCode !== 200 ) {
throw new Meteor.Error( Accounts.LoginCancelledError.numericError, 'Sertal Login Failed' );
} else {
var user = result.data.userrec;
user.groups = result.data.grprec;
user.id = user._id;
return Accounts.updateOrCreateUserFromExternalService( 'sertal', user );
}
} );
On the client I use this code after the login button has been pressed:
Accounts.callLoginMethod( {
methodName: 'login',
methodArguments: {sertal: true,
email: $( '#sertal-email' ).val(),
password: $( '#sertal-password' ).val(),
resume: false
},
userCallback: function ( error ) {
if ( error ) {
console.log( "error: " + error );
} else {
$( "#sertalLoginFormDiv" ).dropdown( 'toggle' );
}
}
} );
But it does not trigger the LoginHandler. There must be something missing but I can't figure it out.
I could not find any documentation on the subject. An answer could also be to point out some documentation which explains the process.
Based on my testing, the methodArguments must be an array of objects.
Also, from what I see in the logs, if methodArguments object includes a password at the root of the object, then Meteor throws an error with "Failed Login { type: 'password',..."
I was able to make this work by putting all of the handler's arguments as part of an object.
Something like this, on the client:
loginRequest = {myLogin:{email: email, password: password}};
Accounts.callLoginMethod({
methodArguments: [loginRequest],
userCallback: callback
});
When executed on the client, meteor calls my server code:
Accounts.registerLoginHandler( function("someName", loginRequest{
if(loginRequest.myLogin){
// I get the loginRequestObject, and can attempt to sign in...
}
});
Note, I am using Meteor 1.0.