सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
Simple Auth एक हल्का Flutter पैकेज है जिसका उद्देश्य ऐप्स और APIs के लिए उपयोगकर्ता प्रमाणीकरण को सुविधाजनक बनाना है। यह लॉगिन प्रवाह, टोकन प्रबंधन और कई प्लेटफॉर्मों पर सत्र स्थायित्व के लिए एक सरल, स्थिर इंटरफ़ेस प्रदान करता है। एकीकरण की आसानी के लिए बनाया गया, यह ओएथ2, जेवीटी और कस्टम लॉगिन वर्कफ़्लो के जैसे सामान्य प्रमाणीकरण विधियों का समर्थन करता है। पैकेज जटिल कार्यान्वयन विवरणों को छिपाता है, जिससे यह बॉयलरप्लेट कोड के बिना न्यूनतम लेकिन प्रभावी प्रमाणीकरण समाधान चाहने वाले डेवलपर्स के लिए आदर्श है।
उपयोग
OAuth2 के साथ उपयोगकर्ता लॉगिन
API टोकन प्रबंधन
सत्र स्थिरता
कस्टम प्रमाणीकरण प्रवाह
क्रॉस-प्लेटफॉर्म प्रमाणीकरण
त्वरित प्रोटोटाइपिंग
मुख्य विशेषताएँ
न्यूनतम सेटअप
कई प्रकार के प्रमाणीकरण समर्थित हैं
प्लेटफॉर्म के अनुकूलता
टोकन स्टोरेज उपकरण
साफ एपीआई डिज़ाइन
एम्बेडेड सत्र प्रबंधन
इनके लिए उपयुक्त
शुरुआती Flutter विकासकर्ता
मूल ऑथेंटिकेशन की आवश्यकता वाले ऐप्स
त्वरित एप्लिकेशन विकास
बहुप्लेटफॉर्म प्रोजेक्ट
सरलता को प्राथमिकता देने वाली टीमें
विचार योग्य बातें
सीमित उन्नत विशेषताएं
एंटरप्राइज स्केल के लिए उपयुक्त नहीं
कोई बिल्ट-इन UI घटक नहीं है
बाहरी प्रमाणीकरण प्रदाता पर निर्भर करता है
लो-लेवल लॉजिक पर कम नियंत्रण
केवल सरल उपयोग के मामलों के लिए सबसे अच्छा
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Most apps need to make API calls. Every API needs authentication, yet no developer wants to deal with authentication. Simple Auth embeds authentication into the API so you dont need to deal with it.
And of course any standard OAuth2/Basic Auth server.
Usage
var api = new simpleAuth.GoogleApi(
"google", "client_id",clientSecret: "clientSecret",
scopes: [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
]);
var request = newRequest(HttpMethod.Get, "https://www.googleapis.com/oauth2/v1/userinfo?alt=json");
var userInfo = await api.send<UserInfo, UserInfo>(request);
That's it! If the user is not logged in, they will automatically be prompted. If their credentials are cached from a previous session, the api call proceeds! Expired tokens even automatically refresh.
Flutter Setup
Call SimpleAuthFlutter.init(); in your Main.Dart. Now Simple Auth can automatically present your login UI
Redirect
Google requires the following redirect: com.googleusercontent.apps.YOUR_CLIENT_ID
Simple Auth by default uses SFSafari on iOS and Chrome Tabs on Android.
This means normal http redirects cannot work. You will need to register a custom scheme for your app as a redirect. For most providers, you can create whatever you want. i.e. com.myapp.foo:/redirct
Android Manifest
you would then add the following to your Android manifest
Note, if you want to avoid Apples mandatory user consent dialog
"foo" Wants to use "bar.com" to Sign In
This allows the app and website to share information about you.
add the lines above and set FooAuthenticator.useSSO = false; which will not use SFAuthenticationSession on iOS, and ASWebAuthenticationSession on macOS. This is the default behavior for the Keycloak provider.
Serialization
Json objects will automatically serialize if you conform to JsonSerializable
If you use the generator and you objects have the factory factory JsonSerializable.fromJson(Map<String, dynamic> json) your api calls will automatically Serialize/Deserialize
Or you can pass your own Converter to the api and handle conversion yourself.