Server Side Swift with Vapor: Authentication with | Ray Wenderlich

In this Server Side Swift with Vapor screencast, you will learn how to set up username and password-based authentication with Turnstile: a security framework for Swift.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5016-server-side-swift-with-vapor-authentication-with-turnstile

Make that book a reality!

@rwenderlich A book would be great. Maybe 1/2 about creating a fully fledged API and the other about consuming it.

Assuming that most of the people who come to RW.com are iOS developers, I feel like we are not used to the amount of “choice” that is available for the web compared to iOS. For example, for front-end, there’s Angular, React, Ember, etc. I think it would be really cool to see how to combine Vapor with one of those front-end frameworks. Again, as an iOS developer, having to piece multiple third-party frameworks together is not something I’m very comfortable with. I don’t think you need to go in depth on any of those front-end frameworks (there’s lots of resources for those), but just getting a project started and connected properly would be really neat to see.

1 Like

Would be great a book with topic such as API, OAuth/JWT, file upload, etc. But not only covering Vapor, Kitura or Perfect are awesome frameworks too.

@rwenderlich @anibalrodriguez Whats the difference between Kitura, Vapor and Perfect?

Which one to learn, why to learn that and what are the advantages?

@rwenderlich Looks like the linked materials are not correct eg til/login missing.
Could you update them ? Thanks.

Great insight! How I wish swift will take over most backend jobs. Guys use Swift everywhere. one Suggestion is there anyway to make swift and PHP work together? so you can call php modules in swift and call swift modules in php? That would be a huge bam

This is great stuff here and I have been following every single one. I have really been interested in using swift for server side coding.

I think a book would be very interesting to have as a resource, and if not, at the least could do a more in depth video series for subscribers and continuing to create a full fledged website after just this stuff.

I already see how much more potential there is.

Thanks again for providing such valuable content!

@davidvpe @anthony_lockett @czeluff @anibalrodriguez @odany Thanks for the encouragement and excellent suggestions! We will definitely keep those in mind for the book :]

@harsh I will be making some screencasts on Perfect soon (maybe Kitura at some point too, we’ll see); if you want you can watch both and decide for yourself!

@agreensh Oops - sorry about that! If you refresh the page you should be able to get the correct materials now; let me know if you have any further issues.

@gutenberg Hmm… I could be wrong, but I doubt there is a way to do this easily. If anyone knows differnetly let me know.

Hi there @rwenderlich as always it a pleasure to watch your tutorials, a book about Vapor would defiantly be useful, as an iOS developer i’m always looking for a great front-end framework to work on that would work seamlessly with my app and vapor looks promising.

looking forward to have this book on my shelf.
i would be glad to suggest some ideas for the book, maybe a poll would be a good idea too.

Thanks
Yoel Lev

Hi Ray. What vapour version are you using ? When I register, and then login, routes to “/til” but then gives

Uncaught Error: Error.prepare(“Unknown column 'acronyms.acronym_id' in 'where clause'”). Use middleware to catch this error and provide a better response.

+1 for making a book on Vapor.

I’d love to see some of the book dedicated toward building a foundation for a clean, maintainable, and scalable application Vapor application. What I mean is that most tutorials focus on basic functionality (i.e. throw all methods in to one controller) and don’t concern themselves with design issues like:

  • What methods should make up a controller?
  • What types of methods should be put in to a model?
  • Handling unsupported Fluent data types (Dates)
  • If I want to abstract something out in to a service object, whats the best way to accomplish that?

Coming from the very opinionated Rails world, providing some context and best practices for constructing an application would go a long way for the beginner.

If the book comes out within 6 weeks, I’m pledging to buy it! :slight_smile:
Otherwise I might already dig out all the bits I need out of the docs by then :frowning:

@rwenderlich - would it be possible to put together a chronological list of the Vapor tutorials? I’ve watched a couple of them, but lost track, and would love to watch from beginning to end.

And mega-dittos on the book!

Edit: Actually, I just found the entire list of screencasts, so I can figure it out on my own. But if you were so inclined, putting together a separate list like you have for other tutorials might not be a bad idea.

I got the same problem,I found that problem seams to be solved by below:
In TILController file, to fix indexView method,to do try catch the Acronym which can be thrown Error!
BTW,I use vapor 1.5.0 version

func indexView(request: Request) throws → ResponseRepresentable {

let user = try? request.auth.user() as! TILUser

var acronyms: [Acronym]? = nil
if let user = user {
    do {
         acronyms = try user.acronyms()
    }catch {
        acronyms = []
    }
  
}

let parameters = try Node(node: [
  "acronyms": acronyms?.makeNode(),
  "authenticated": user != nil,
  "user": user?.makeNode()
])
return try drop.view.make("index", parameters)

}

Finally,in TILUser file ,to fix acronyms helper method within extension of TILUser,you must need to give an foreignKey string “tiluser_id”.If you give nil foreignKey string ,it will replaced by default(the actually wrong is happened here).

func acronyms() throws → [Acronym] {

return try children("tiluser_id", Acronym.self).all()

}

Nice tutorials,Love you ,Ray is great <3

1 Like

Great tutorials, thank you!
Apart from what’s already been suggested, it would be great if you also covered unit-testing Vapor apps. It seems to be quite complicated and badly described in the official docs.

Hi Ray, I’ve enjoyed following these screencasts very much, thank you for making them!
As an iOS Developer I sometimes find the amount of different options to construct webapps, databases, API’s etc. slightly bewildering.
Getting to know Vapor in this way has helped me understand some concepts better.

I think a book would be an excellent idea. Maybe something to possibly also consider would be to dive a little bit deeper into server side Swift versus Swift used in iOS. Some of the things we can do with Swift on iOS are not possible in Vapor.
And how would one go about creating something like Vapor?
Thanks,
Filip

Great series, thank you! Definitely do the book. I agree that a section needs to be devoted to writing a simple swift app to consume the API.

Hi @rwenderlich,
thx you for all this incredible work.

Book is a great idea :wink:

I think it’s a good idea to compare the existing framework for swift server. There are 4 well-known : Vapor, Kitura, Perfect and Zero.

Keep doing great tutorial :slight_smile:

Loïc

1 Like