UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

WKWebView containing a login form

Forums > SwiftUI

Hi all

Loving the 100 days of SwiftUI challenge and really enjoying learning. Apart from advancing my knowledge, I am learning so that I can develop an app for my workplace for our customers to find parts, place orders etc.

I would like to implement a login feature into the app and wondered what the best approach from a security and coding perspective would be. I considered just using a form which would send an API request to authenticate the user and if all was well, setting a key in UserSettings to persist the session (although I don't know if this is the proper way).

From reading around online, it seems that the more secure way would be to load a login form from the server that will be doing the authentication within a WebView and somehow passing the fact that the user authenticated successfully there into the same session (keychain?). I am usually quite good a googling for answers but all I seem to be able to find are posts where people are trying to inject a username and password into a WebView to pre-authenticate a user so am a little stuck.

So I am hoping somebody here can help. As I am relatively new to this, I want to make sure I am doing this in the most secure and efficient way, I can get the first method to work but am sending username and password data over the internet. Could I ask people's opinions on the best way to implement this feature and some code examples if possible please

Thanks in advance :)

1      

Bump

Would appreciate any input on this as I am a little stuck

1      

Friendly bump

1      

@Bnerd  

You could consider Firebase to control your authentication?

1      

I haven't done anything that requires actual user authentication, as I have also just been working through the courses on this site, and haven't actually produced any actual production apps. I assume that most of the people who frequent these forums are in the same boat, so I'm not sure if many of the people here will have the answer to this that you need. Although, I'm sure somebody has some experience with it.

But, if you are not finding your answer here, I might suggest using r/swift or r/iOSProgramming subreddits on reddit.com. I have sometimes been able to find answers there to some of the questions that I didn't get answers to here.

1      

I can't use Firebase authentication as we want to allow our users to utilise the same username and password they have registered with on the website, this means it either has to be an API call or a WebView.

Appreciate where you are coming from on but this is a SwiftUI forum with some experienced developers frequenting it so I don't think it is a bad place to post this question

1      

I wasn't trying to say that this is an inappropriate or bad place to post this question. This website is still my first go-to spot for any Swift related questions. But I was just suggesting that after a week with no responses (and now over 2 weeks) I thought you might want to try another place as well. I just suggested those subreddits because I have had luck with posting questions there in the past, and I thought it might be helpful to you. But you don't have to post there if you prefer not to. It was just a suggestion.

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.