« first day (2146 days earlier)      last day (2810 days later) » 

5:00 PM
 
I want to slap this developer, but Linq isn't as efficient as a simple for loop.
The performance is negligible, whom cares? Unless you need to push it that much, do you really care? Especially for the sacrifice in expressive code!
 
> whom cares
lel
 
@KendallFrey ?
 
@Greg ¿
 
Just saw this article now and wow, this is so stupid: blog.expensify.com/2011/03/25/…
Albeit things have changed in 5 years lol
 
War
5:14 PM
0
Q: AesEncryption doesn't appear to decrypt right?

WarI wrote this class to allow me to encrypt and decrypt the json representation of objects but it doesn't appear to work as the MSDN documentation (here: https://msdn.microsoft.com/en-us/library/system.security.cryptography.aesmanaged%28v=vs.95%29.aspx?f=255&MSPPError=-2147217396) suggests it shoul...

 
@KalaJ jesus
things haven't changed that much in 5 years
That guy clearly doesn't know what the hell he's talking about
 
Yeah it's crazy
I love the part where he ends up needing to hire a .NET dev
 
5:31 PM
@KalaJ this is cringetastic
 
It is and it's depressing because a lot of people have this mentality.
Esp. people in startups that don't know anything about .net stack
They're like oh it's not open source, it's old, it's crap
 
That's the silliest part of all
 
it's complex
 
My first job was at a startup programming in .NET
*first programming job
 
I get that from people in NYC startups that do python, ruby or JS and think they're all that
Hmm interesting
 
5:33 PM
Granted it was a biotech company, not a software company but still
 
Now that Unity3D is more popular in NYC, people are learning more about C#
and they're like wow, I can make games with it
LOL
Mike, I work for a startup now and we're using .NET too
One of the few startups :P
I love it when I tell people I use Windows 10 at work. They're amazed... Like they're omg not mac or linux? Are you crazy?
You're not legit until you learn bash or commandline
 
War
@mikeTheLiar my first programming job was with a cmopany that built their own content management system in .Net ... I was building all the custom stuff on top of it for the clients
@KalaJ jeez ... its like 40 years ago sinc the command line was invented ... I hate it when people think it's cool to do everything in a shitty command window
I basically told my old boss before I left that he was a moron for building a process for devs that resulted in them spending all fucking day in a command window / powershell just to do trivial shit like check code in ...
I actually timed it one day ... from the point I wanted to check in 1 line of code to the point that line of code was no longer my responsibility (handed off to a tester) took 5 hours
most of that was in powershell
I'm not exactly a slow typer either so for a junior that's like 2 to 3 days work to hand off 1 line of code
 
5:54 PM
Yeah completely agree @War. Also at the bootcamps, they stress how important commandline is and it's the end all, be all lol.
 
War
@KalaJ that guy needs to be shot
 
I'm trying to come up with a way of forcing methods in a class I have created (an SDK for my project's API) to call an authentication method (sets the authorization header for outgoing requests) at the start of the method execution (or before, that would be fine too).

Currently I just call that method at the start of the methods that need it, which is fine, I just have a nagging feeling there's a cleaner/more abstracted-away way of doing it - I was thinking an Attribute but I don't think that will work... Any ideas?
 
War
forcing in what way @ChrisThompson ?
for example if you have some form of api in to your lib you could enforce that all requests in to your API are implementations of an interface or derive from some base
 
I suppose forcing may be a bad phrase for it, I just feel there's something better than:
method(){
 
War
or you could require say an auth token ... that forces all clients to have been issued that token from you first
what are you trying to achieve?
 
6:02 PM
bah, new keyboard, keep hitting CTRL instead of SHIFT for enter x.x:
method(){
MethodCall();
Stuffs!
}
That's what ends up in most of my methods, and I just feel theres a way of moving that call to MethodCall() into something higher up...
 
War
I think you have a design problem here
what does this method call do ?
 
Well the MethodCall sets up the Authorization header for the request that will be made, based on the authentication cookie that exists already.
 
War
javascript on a web page?
you could do what I did and setup a beforesend function in the ajax setup
 
so a more descriptive example is
public async Task<T> SendRequest(){
SetAuthenticationHeader();
SendRequest();
ReadResponse();
return Response.Content();
}

It works fine with that system it just means every SDK method that makes a call to an API method that is decorated with [Authorize] has to call that method first.

No this is through an MVC application. The controllers call the SDK
 
War
I took a different approach to that
I use HttpClient
I created an extension method called Authenticate that accepts a username and password
when called it adds the auth token to the HttpClient Instance
I then created an AddAuthHeader method that allowed me to manually add it if I had it somewhere
now my api calls from MVC look something like ...
var result = new HttpClient()
   .WithBaseUrlFromConfig()
   .AddAuthFromSession()
   .GetAsync<SomeTypeOfResponse>("Foo/Bar");
the other way of going about it I suppose would be to derive from HttpClient yourself so you could implement those extra calls in the ctor ...
var result = new AuthentictedHttpClient()
   .GetAsync<SomeTypeOfResponse>("Foo/Bar");
I have considered that
 
6:11 PM
So you initialize a new HttpClient with each call? In that regard I have the SDK client (uses a company-made extension of HttpClient) as a field on each of my Controllers that is Ninjected into them.
 
War
not always I can reuse the client if need be ...
var api = new HttpClient()
   .WithBaseUrlFromConfig()
   .AddAuthFromSession();

var result = api.GetAsync<SomeTypeOfResponse>("Foo/Bar");
then just do that last bit again ( or another call of course)
 
Well true in the same method yeah but I'm wondering about how long/if it maintains the Authorization header?
 
War
it keeps the header for the life of the HttpClient object instance
or until you remove it
the headers are available in the default headers property ...
 
Hmm, I had had issues in the past where on POST requests it was losing the header, though I may have fixed that already so I'm gonna try without calling that method and see if it works real quick
 
War
var headers = api.DefaultHeaders;
@ChrisThompson calling what method ?
 
6:14 PM
My SetAuthentication method
that sets that header on every request
 
War
@ChrisThompson here are my extensions ...
@RoelvanUden I got stuck :(
0
Q: AesEncryption doesn't appear to decrypt right?

WarI wrote this class to allow me to encrypt and decrypt the json representation of objects but it doesn't appear to work as the MSDN documentation (here: https://msdn.microsoft.com/en-us/library/system.security.cryptography.aesmanaged%28v=vs.95%29.aspx?f=255&MSPPError=-2147217396) suggests it shoul...

 
Well it seems like either way I'll have to be adding it whenever I make a request (just tried it without those calls) from the SDK to the API, using the Token that gets stored on our Cookie, I just retrieve it from the cookie and set it in a very similar manner to your extensions. I just didn't know if there was a way of moving that code into a single place so that its out of sight and out of mind aside from maybe an attribute.
Perhaps because of the dependency injection, I'm not sure, but it isn't keeping the auth token header stored between different requests without code intervention.
 
War
create a gneeric getAsync like i did
at least then you only put it in one place
 
duh (at me)... that is pretty much exactly what I was trying to figure out how to do idk why I didn't just do a wrapper around the Get/Put/Post methods x.x
 
War
See my gist above ... Done!!!
 
6:32 PM
With Dapper, can you use it right on SqlConnection or should you convert it into a IDbConnection?
Rather than another class to basically hold the connection, I was thinking of doing:

using(var connection = new SqlConnection())
     return connection.Query<>();

Something like that.
Or should I do an extra layer like:
    public class DbCommandUtility : IDisposable
    {
        private bool disposed = false;
        private IDbConnection dbConnection;

        #region Constructor:

        public DbCommandUtility(string dbConnection)
        {
            using (var connection = new SqlConnection(dbConnection))
                this.dbConnection = connection;
        }

        #endregion

        #region Dispose:

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
 
6:52 PM
just do it right on the sql connection
also your utility class immediately closes the connection in the ctor
not very useful if you ask me
 
ADH
7:20 PM
Have you guys ever had a boss that you wonder if maybe he's drinking at lunch?
 
Some day I will be that boss.
 
ADH
That's funny
He's a nice guy. Just sometimes really seems drunk or something.
Have you ever met anyone that seems kinda drunk, but maybe is not drunk? What do you call someone like that?
Goofy?
 
Goals - Drunk on the job
 
@ADH drunk
 
ADH
7:36 PM
haha
 
7:46 PM
hello gentlemen
 
ADH
Hey Dave
 
We are looking to develop a web application with an angular2 frontend and a REST asp.net core backend. I am looking if it would be possible to secure the frontend site with windows authentication. I have done it in the past, but the backend and the frontend were only one site. Now we have two seperated site.
How would solve such a situation
Let's pretend we secure the frontend with windows auth. How would you then impersonate, aka. get the login username ? such a task is usally done with asp.net code isnt it ?
maybe I should post it as a question but I felt it was too awkward
 
Pets' the code
 
@StevenLiekens Kind of what I was thinking.
 
@Dave I haven't really thought about what you're asking, but I default to telling people about the double-hop problem when they mention windows authentication on webservers. blogs.msdn.microsoft.com/knowledgecast/2007/01/31/…
 
7:55 PM
@StevenLiekens Even if it didn't close, would it be useful?
 
@Dave window, AD login?
 
@SimonSvensson yes
yes*
@SimonSvensson Well maybe I dont need to impersonate here, only need to get the entered username in the windows auth popup
 
Auth0?
 
@juanvan ?
that looks like a form login ?
 
You still authenticate against a rest endpoint, so what's the big deal?
send credentials, get token in return.
 
8:05 PM
would supply the logged in user to authenticate
 
War
@Dave stop thinking of windows based with as a special case and use identity to build an sso endpoint to hand out tokens and your problem will go away
 
I'd go for asp.net identity, and putting in my own set of classes that authenticates/authorizes against windows / ad credentails.
what Wardy said
 
Anyone done any GoLang and how does it compare to C#?
 
Go should go away.
 
8:22 PM
anybody here use topshelf?
 
War
8:50 PM
Jeez ... Anybody here use c# ?
 
some days
 
9:05 PM
 
why should go go away? Or is that just for the pun?
 
Any language that thinks semi-colon insertion is a good idea is a bad language.
 
MVC programmers, I'm trying to use custom authorization that captures username and password and posts back as a model (ignore the terrible use of security. This is solely to get used to mvc). However, I cant for the life of me find out how to get the forms entries into my CustomAuthorisation. Anyone know how this stuff works?
 
I don't follow the semicolon thing
 
@borrrden Maybe he's implying python is a great language?
 
9:19 PM
Go's semicolons are optional though?
 
semicolons ruin the feng-shui of the code. away with them.
 
github.com/couchbase/sync_gateway/blob/master/db/crud.go <-- No semicolons in my coworkers' project
 
10:03 PM
Does anyone have a working Identity and Identity Server that will provide OAuth tokens, without Entity Framework and in Asp.Net Core 2.0 example?
 
Where would I find people familiar with MVC?
 
@borrrden Line 2. fix it!
 
lol take it up with the Apache Foundation
 
I feel like I'm looking for information on the most hidden topic ever... Why has no one created a functioning simple tutorial for something that's so common???
 
Because they haven't met you yet ;)
You are the one destined to make it
 
10:19 PM
Dude. I honestly feel like doing it. But i cant get the information myself. Every single "tutorial" so far skips an incredibly important step. Seriously. Every one I've found so far.
 
10:39 PM
What are you two talking about?
 
Summary of every single tutorial so far on mvc login:

How to set up a login tutorial for beginners:
step 1: Create a new project // Done this thousands of times
step 2: Create a controller class // Yea yea super easy
step 3: Create a view for the action in your controller class // Yep yeps. Keep going
step 4: Create a form for the login requiring username and password // easy peasy lemon squeesy
step 5: Create an HttpPost attribute for the same action so that this method will be called when user submits details // Ok good. next?
 
@betarunex The default MVC Template does a lot of it, I'm trying to do that right now for Core. But it doesn't exist.
 
@Greg I dont get where it pulls this out it's @SS. I understand everything. Just Every single tutorial skips the part where they actually say "Ok, Because model.username matches the DB.User.Username and password matches DB.User.Password, we'll set [insert unknown entity here] as admin. Then done. Now [enter session from unknown place] has access to authorized methods"
 
Or, you're talking about the authorization process.
 
11:01 PM
@KendallFrey They skip the whole [Authorized] attribute though...
 
@betarunex Skip it how? What part do you think should have mentioned it?
 
:32598414 Something like this:

[Authorize(Roles = "Admin, Super User")]
public ActionResult AdministratorsOnly()
{
return View();
}
Which allows only Admin or Super User to access the page. But I dont know what i have to say is an admin or super user...
 
That's covered in the article
It sounds like you already know how to use the attribute
And the article tells you how to define roles
 
11:18 PM
I'm pretty sure I know how to use it. I already covered the tutorial on how to even create my own authentication Attributes, But I have no idea what I'm setting to be "admin". I Looked through that article quickly. But I dont see it. That looks like an incredibly long explanation on something that I just want what's probably about a line long.

A breakdown:
I have a controller called HomeController. In HomeController I have 3 actions:
Login, LoggedIn and Hidden
LoggedIn is a post method that gets the model.
 
@betarunex You do know what roles are, right?
 
:32598537 I'm guessing just strings. Seeing as many tutorials have:
[Authorize(Roles="admin", Users="Bob, Alice")] // Roles is a string with value "admin"
public ActionResult Index()
{
   ...
}
 
@betarunex No, do you know what roles are? What they do, what they mean, how they relate to users?
 
@KendallFrey You mean like if a user is a customer, then he shouldn't have access to stock price but an employee should. That kind of thing?
 
11:24 PM
Ok then yea. I understand their function. I want to be able to use it. But Literally 1 part I'm stuck at. Where do I say the current user is admin or user? let's say I just want to make everyone admin. What am I setting to admin?
 
@betarunex "Where do I say the current user is admin or user?" <-- Roles
 
var Roles = "Admin";
Will disappear as soon as it reaches the closing brace.
 
No, for fuck's sake
Read the article
It tells you how to set up roles
 
Do i have to have a 20 page essay just to say that the guy who just logged in is an admin?
 
No, but clearly you need some more understanding of what roles are
Read the code snippets, they have the important stuff
 
11:30 PM
on the page @KendallFrey linked before it's under the Create default Role and Admin User section
I get where you're at with the tutorials. I found they went into a nice level of detail for many things and just glossed over other stuff and it made it hard to pick it all up.
but you do have to do some reading on your own ;)
 
@hsimah but that seems like an incredibly complex way of doing something that I was so sure should only be a line of code. I've even learnt how to Override the AuthorizeCore and feel very comfortable with that now even without being able to test it, because I cant find What I'm actually setting. For example, my code:
Controller action:
                [CustomAuthorisation(CustomRoles = "Admin")]
                public ActionResult Test()
                {
                    return Content("You have access");
                }

    With custom authorization:
        public class CustomAuthorisation : AuthorizeAttribute
        {
            public string UserRole { get; set; }

            protected override bool AuthorizeCore(HttpContextBase httpContext)
            {
                //CustomUser user = ????
 
I don't think it's overly complex. Creating roles is mostly something done once per application. roleManager.Create(new IdentityRole() { Name = "Admin" }); is just one line
what are you trying to do? Just run through a basic MVC application?
 
Yes. The most basic unsecured MVC app ever without any styling. If model.username="admin" and model.password="1234", then model.role="Admin". That's all I need. Then the user can access
[Authorized]
public static void Test()
 
@betarunex What did you think would be a line of code? It's a few lines of code to create a role, a line of code to add a user to a role, and a line of code to authorize against a role
 
11:47 PM
I know I'm probably just being incredibly stupid about this... But It just looks incredibly faulty and unmanageable...
 
lol
well it's not. in my work application (thousands of users) we have about 5 roles
add a user to the system and they default to a User, then we have a form to add roles for them, but that rarely happens
I know how you're feeling. It took me a while to 'get' it all too. I came from a VB background in a late-90s style spaghetti code base. This all seemed very simple and just... odd.
.net mvc is far superior
 
Ha ha. It's a horrible feeling. Like programming all makes sense. But this? It just feels like it's meant to be something like "if(model.myRole="Admin") model.Authorize=true;". I just cant wrap my head around this logic.
 
it is like that
but it's done via the attribute on the controller
 
@betarunex Roles don't belong there. They're part of the user.
Users can have multiple roles. Roles can have multiple users.
 
@KendallFrey That logic I get.
 
11:58 PM
do you understand how attributes work?
 
@hsimah If you had asked me a few hours ago, I would've said yes
 
in your custom one you pasted earlier, it does, logically, what the built in ones do
they check if a user has a role and allows access to the method accordingly
 

« first day (2146 days earlier)      last day (2810 days later) »